2017-06-13 45 views
0

让我们有一个简单的WSDL文件:如何更新WSDL来处理响应

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions targetNamespace="http://www.test.com" 
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://www.test.com"> 
    <wsdl:types> 
     <xs:schema targetNamespace="http://www.test.com"> 
      <xs:element name="sessionId" type="xs:string"> 
      </xs:element> 
      <xs:element name="transactionId" type="xs:string"> 
      </xs:element> 
      <xs:element name="Login"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element name="userId" type="xs:string"> 
         </xs:element> 
         <xs:element name="pwd" type="xs:string"> 
         </xs:element> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="LoginResponse"> 
       <xs:complexType /> 
      </xs:element> 
     </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="Login"> 
     <wsdl:part name="parameters" element="Login"/> 
    </wsdl:message> 
    <wsdl:message name="LoginResponse"> 
     <wsdl:part name="parameters" element="LoginResponse"/> 
    </wsdl:message> 
    <wsdl:message name="HeaderSessionId"> 
     <wsdl:part name="header" element="sessionId"/> 
    </wsdl:message> 
    <wsdl:message name="HeaderTransactionId"> 
     <wsdl:part name="header" element="transactionId"/> 
    </wsdl:message> 
    <wsdl:portType name="MMCServicesPort"> 
     <wsdl:operation name="Login"> 
      <wsdl:input message="Login"/> 
      <wsdl:output message="LoginResponse"/> 
     </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="MMCServicesBinding" type="MMCServicesPort"> 
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
     <wsdl:operation name="Login"> 
      <wsdl:input> 
       <soap:body use="literal" /> 
      </wsdl:input> 
      <wsdl:output> 
       <soap:header message="HeaderSessionId" part="header" use="literal"/> 
       <soap:body use="literal" /> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="MMCServicesService"> 
     <wsdl:port name="MMCServicesService" binding="MMCServicesBinding"> 
      <soap:address location="/test"/> 
     </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

对于这个WSDL下面的消息是一个有效的回应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
     xmlns:test="http://www.test.com"> 
    <soapenv:Header> 
     <test:sessionId>xxx</test:sessionId> 
    </soapenv:Header> 
    <soapenv:Body> 
     <test:LoginResponse/> 
    </soapenv:Body> 
</soapenv:Envelope> 

什么/我该如何需要改变WSDL接受以下信息作为登录操作响应消息,而不是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Header> 
     <sessionId xmlns="http://www.test.com">xxx</sessionId> 
    </soapenv:Header> 
    <soapenv:Body> 
     <LoginResponse/> 
    </soapenv:Body> 
</soapenv:Envelope> 

...的LoginResponse为w/OAN amespace的定义。

我有一个未知WSDL WS不提供WSDL。上面的那个已经被历史上其他人重建了。然而,我需要使用的真正WS提供了第二个响应,但是Apache CXF java库拒绝了这个响应。

谢谢。

回答

0

的核心问题似乎来在你的代码的targetNamespace

的定义: <xs:schema targetNamespace="">

的SOAP XML应该是没有任何前缀: <xs:schema targetNamespace="http://www.test.com"> 时更换。

这可能需要同时在WSDL定义空或默认命名空间:binding和wsdl:服务级别:

<wsdl:binding name="MMCServicesBinding" type="MMCServicesPort" xmlns=""> ... <wsdl:service name="MMCServicesService" xmlns="">

你可能已经建立,那么你必须更新基于该WSDL一些代码存根也是这个生成的代码。