2015-10-06 581 views
0

我需要帮助。我在工作中使用CXF Web服务,该服务在WebLogic服务器中运行得非常好。我最近被要求传递一些额外的参数(用于额外的身份验证)。我们希望这些额外的参数在标题中传播,而不是像普通参数那样。使用@WebParam时CXF Web服务问题(header = true)

我有两种不同的方案来解释。事实上,在场景编号1中,一切运行良好,我非常喜欢它,因为我的Web服务收到了标题参数,我可以验证它们。但是,在场景编号2中,在运行时间中,标题中的所有这些新参数均为NULL(并且正常参数已正确填充!)。所以我无法验证头文件。我需要场景2的工作,因为我们希望这些额外的参数在标题中。

为什么这个绑定不能在我的第二个场景中工作?有一个错误?我错过了什么吗?请帮帮我。在这里,我用一些代码来描述这两种情况以供说明:

1)这里一切正常。在我的CXF-servlet.xml文件我已经端点定义为:

<jaxws:endpoint id="omniWebService" 
       implementor="server.com.omnipay.webservice.webService.ServiceImpl" 
       address="/omniWS" /> 

和呼叫方的一个,我的CXF Web服务接口是产品是例如这一个在这里你可以看到3个参数头=真,而不是其他人。

@WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO 
getParent(
     @WebParam(header=true, name="callerId") String callerId, 
     @WebParam(header=true, name="timestamp") String timestamp, 
     @WebParam(header=true, name="signature") String signature, 
     @WebParam(name="institutionNumber") @XmlElement(required=true) String institutionNumber, 
     @WebParam(name="clientNumber") String clientNumber, 
     @WebParam(name="ourReference") String ourReference, 
     @WebParam(name="accessMerch") String accessMerch 
); 

就这样。我不认为我需要展现更多。这工作正常。我在WebLogic和我的客户端或soapUI中进行部署或调试,或者我做的任何事情,Web服务都会收到所有这些参数,我可以使用它们。

2)实际的端点我想在我的CXF-servlet.xml中使用如下:

<jaxws:endpoint id="omniWebService" 
       implementor="server.com.omnipay.webservice.webService.ServiceImpl" 
       address="/omniWS" wsdlLocation="WEB-INF/omniWebService.wsdl"> 
    <jaxws:properties> 
     <entry key="schema-validation-enabled" value="true" /> 
    </jaxws:properties> 
</jaxws:endpoint> 

,并使用这一个原因,是因为我需要一个“本地” WSDL,我可以编辑并进行更改。这种“本地” WSDL是在WebLogic我第一次部署以及加入这样的事情加上使用它们,而不是类型=后给我提供了确切的WSDL“XS:字符串”:

  <!-- Institution Number is a required 8 numeric positions IN parameter --> 
     <xs:simpleType name="institutionNumber"> 
      <xs:restriction base="xs:string"> 
       <xs:length value="8"/> 
       <xs:pattern value="[0-9]+"/> 
      </xs:restriction> 
     </xs:simpleType> 

这是,增加了一些限制,所以WSDL将验证用户输入。例如00000123是一个有效的机构号码,但000000XX不是。

此功能非常好。说实话,它迫使我维护一个我不喜欢的“本地”WSDL文件,但我没有找到任何其他方式来做到这一点。

这里是我的问题所在。即使我将“自动”WSDL作为“本地”WSDL放入(在没有任何更改的情况下原始的)原始WebLogic提供给我的确切内容,结果是在执行时间内,我的正常参数(机构编号,客户端数量等)正确填充,但我的3个头参数(callerId,时间戳和签名)是​​NULL。

请有什么建议吗?我做错了什么?这两种功能在不协同工作时都能很好地工作,但是当我把它们放在一起时,我遇到了这个问题。为什么绑定在场景1中工作正常,但在场景2中没有出现?

谢谢

回答

0

我发现了这个问题。好吧,我尝试了一些疯狂的东西,它很有用。我把3个头部参数放在最后,然后就可以工作了!我觉得这很奇怪。为什么我不能把它们放在开始?这可能是WebLogic的问题吗?我是否在使用旧的CXF类时遇到了错误?很奇怪,但很高兴现在已经修好了!

@WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO 
getParent(
     @WebParam(name="institutionNumber") @XmlElement(required=true) String institutionNumber, 
     @WebParam(name="clientNumber") String clientNumber, 
     @WebParam(name="ourReference") String ourReference, 
     @WebParam(name="accessMerch") String accessMerch, 
     @WebParam(header=true, name="callerId") String callerId, 
     @WebParam(header=true, name="timestamp") String timestamp, 
     @WebParam(header=true, name="signature") String signature 
);