2015-10-06 43 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 
);