2017-06-13 6 views
0

Ayons un simple fichier WSDL:Comment mettre à jour le WSDL pour traiter une réponse

<?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> 

Pour ce WSDL, le message suivant est une réponse valide:

<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> 

Que/Comment ai-je besoin de changer le WSDL pour accepter le message suivant que la réponse de fonctionnement Connexion message au lieu:

<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> 

... le LoginResponse est w/OAN définition d'espace.

J'ai un WS avec WSDL inconnu qui ne fournit pas le WSDL. Celui ci-dessus a été en quelque sorte reconstruit par quelqu'un d'autre dans l'histoire. Cependant le vrai WS que j'ai besoin d'utiliser fournit la 2ème réponse qui est cependant refusée par la librairie Java Apache CXF.

Merci.

Répondre

0

La question fondamentale semble venir avec la définition de targetNamespace

dans votre code: <xs:schema targetNamespace="http://www.test.com"> lorsqu'ils sont remplacés par: <xs:schema targetNamespace="">

XML SOAP doit être sans préfixe.

Il peut exiger également définir l'espace de noms vide ou par défaut au wsdl: binding et wsdl: niveau de service:

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

Vous pourriez avoir construit quelques bouts de code basé sur ce WSDL, vous devez mettre à jour aussi ce code généré.