2015-06-06 36 views
0

我被一個問題困住了很長一段時間。我有一個我在CXF中託管的裸式WSDL。駱駝CXF處理裸式WSDL

下面是我的樣本SOAP請求:

<?xml version="1.0" encoding="UTF-8"?> 
<XpgIntegratedPaymentRequest 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> 
    <ClientId>RMHP</ClientId> 
    <InputParameters></InputParameters> 
</XpgIntegratedPaymentRequest> 

現在,當我打我得到了以下錯誤消息的服務:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <soap:Fault> 
      <faultcode>soap:Client</faultcode> 
      <faultstring>Unexpected element {http://schemas.xmlsoap.org/soap/envelope/}XpgIntegratedPaymentRequest found. Expected {http://test:9090/wsx/services/WemXpgPaymentService}XpgIntegratedPaymentRequest.</faultstring> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

下面是一個使用生成我的Web Service接口(SEI)的wsimport:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<wsdl:definitions name="PWS_WEM_XPG_INTEGRATION" targetNamespace="http://test:9090/wsx/services/WemXpgPaymentService" xmlns:impl="http://test:9090/wsx/services/WemXpgPaymentService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:hc="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"> 
    <wsdl:types> 
    <hc:schema xmlns:hc="http://www.w3.org/2001/XMLSchema">   <hc:element name="XpgIntegratedPaymentRequest" type="XpgIntegratedPaymentRequestType">    <hc:annotation>     <hc:documentation>Root Element</hc:documentation>    </hc:annotation>   </hc:element>   <hc:complexType name="XpgIntegratedPaymentRequestType">    <hc:sequence>     <hc:element minOccurs="0" name="ClientId" type="hc:string"/>     <hc:element maxOccurs="unbounded" minOccurs="0" name="InputParameters" type="hc:string"/>     <hc:element minOccurs="0" name="ReceiverID" type="hc:string"/>     <hc:element minOccurs="0" name="SecurityKey" type="hc:string"/>    </hc:sequence>   </hc:complexType>  </hc:schema> 
    <hc:schema xmlns:hc="http://www.w3.org/2001/XMLSchema">   <hc:element name="XpgIntegratedPaymentResponse" type="XpgIntegratedPaymentResponseType">    <hc:annotation>     <hc:documentation>Root Element</hc:documentation>    </hc:annotation>   </hc:element>   <hc:complexType name="XpgIntegratedPaymentResponseType">    <hc:sequence>     <hc:element maxOccurs="unbounded" minOccurs="0" name="ResponseCode" type="hc:string"/>     <hc:element minOccurs="0" name="ResponseMessage" type="hc:string"/>     <hc:element minOccurs="0" name="ErrorMessages" type="hc:string"/>    </hc:sequence>   </hc:complexType>  </hc:schema> 
    </wsdl:types> 
    <wsdl:message name="getWemXpgPaymentRequest"> 
    <wsdl:part name="parameters" element="XpgIntegratedPaymentRequest"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="getWemXpgPaymentRequestResponse"> 
    <wsdl:part name="parameters" element="XpgIntegratedPaymentResponse"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:portType name="WsTransactionImlMetroSoap11"> 
    <wsdl:operation name="getWemXpgPaymentRequest"> 
     <wsdl:input message="impl:getWemXpgPaymentRequest"> 
    </wsdl:input> 
     <wsdl:output message="impl:getWemXpgPaymentRequestResponse"> 
    </wsdl:output> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="WsTransactionImlMetroSoap11SoapBinding" type="impl:WsTransactionImlMetroSoap11"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="getWemXpgPaymentRequest"> 
     <soap:operation soapAction="http://test:9090/wsx/getWemXpgPaymentRequest" style="document"/> 
     <wsdl:input> 
     <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="WemXpgPaymentService_PWS_WEM_XPG_INTEGRATION"> 
    <wsdl:port name="WsTransactionImlMetroSoap11" binding="impl:WsTransactionImlMetroSoap11SoapBinding"> 
     <soap:address location="https://test:7443/wsx/services/WemXpgPaymentService_PWS_WEM_XPG_INTEGRATION"/> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

例外,我得到的是:

org.apache.cxf.interceptor.Fault: Unexpected element XpgIntegratedPaymentRequest found. Expected {http://test:9090/wsx/services/WemXpgPaymentService}XpgIntegratedPaymentRequest. 
at org.apache.cxf.interceptor.DocLiteralInInterceptor.validatePart 

回答

0

我建議您使用工具來生成SOAP請求,如SoapUI。很顯然,你不使用它應該像如下(未測試)有效的SOAP請求:

<?xml version="1.0"?> 
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" 
    soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 
    <soap:Body xmlns:wem="http://test:9090/wsx/services/WemXpgPaymentService"> 
     <wem:XpgIntegratedPaymentRequest> 
      <wem:ClientId>RMHP</wem:ClientId> 
      <wem:InputParameters></wem:InputParameters> 
     </wem:XpgIntegratedPaymentRequest> 
    </soap:Body> 
</soap:Envelope> 

注意周圍soap:Envelopesoap:Body標籤和wem前綴的適當的服務特定的命名空間定義(當然你也可以將前綴名稱更改爲您喜歡的任何值)。

其他推薦:如果可能,請更改Web服務的WSDL定義中的默認命名空間。它不應包含test:9090,而應包含貴組織的URI。

+0

嗨我能夠通過在SEI上設置以下屬性來使用沒有命名空間的請求「@EndpointProperty(key =」soap.no.validate.parts「,value =」true「)」。但是現在在響應中,body帶有前綴的命名空間我不想命名空間在肥皂響應either.Sample皁resposne發生 「 」 – user1540430

+0

@ user1540430我看到你打開了一個新問題http://stackoverflow.com/questions/30693238/removing-namespace-from-soap-response-camel-cxf –