2013-04-04 15 views
8

Ho creato manualmente un WSDL che ha una sola operazione senza parametri di input e nessun parametro di output.Includere il tipo di schema nel file WSDL

sto ottenendo seguente errore quando provo a creare un client da questo WSDL:

Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Schema with target namespace ' http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/ ' could not be found. XPath to Error Source: //wsdl:definitions[@targetNamespace=' http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/ ']/wsdl:portType[@name='GAMEAssociateIntf'] C:\toolbox\BlueTest\BloodRedTest\BloodRedTest\Service

La types (da utilizzare nel client) devono essere generati dal XML presente nel WSDL. Penso che aggiungendo Service Reference, lo strumento non riesca a crearlo a causa di qualche errore nell'XML. Il xsd sembra essere il problema.

Quali modifiche devono essere apportate nel WSDL per creare il proxy?

Nota: sto tentando di includere i tipi xml definiti nello stesso WSDL. [Non ho bisogno di un file separato per lo schema defenition]

WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="GAMEAssociate" 
     targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
     xmlns:tns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:wsp="http://www.w3.org/ns/ws-policy" 
     > 

<types> 
<xsd:schema> 
</xsd:schema> 

<xsd:element name="myData"> 
    <xsd:complexType /> 
</xsd:element> 

<xsd:element name="myDataResponse"> 
    <xsd:complexType /> 
</xsd:element> 

</types> 

<message name="getAllVicePresidentsRequest"> 
<part element="tns:myData" name="getAllVicePresidentsRequest"/> 
</message> 

<message name="getAllVicePresidentsResponse"> 
<part element="tns:myDataResponse" name="getAllVicePresidentsResponse"/> 
</message> 

<portType name="GAMEAssociateIntf"> 
<operation name="getAllVicePresidents"> 
    <input message="tns:getAllVicePresidentsRequest"/> 
    <output message="tns:getAllVicePresidentsResponse"/> 
</operation> 
</portType> 

<binding name="GAMEAssociateIntfBinding" type="tns:GAMEAssociateIntf"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 

<operation name="getAllVicePresidents"> 
    <soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 
        style="document"/> 
    <input> 
    <soap:body use="literal"/> 
    </input> 
    <output> 
    <soap:body use="literal"/> 
    </output> 

</operation> 

</binding> 

<service name="GAMEAssociate"> 
<port binding="tns:GAMEAssociateIntfBinding" name="GAMEAssociateSOAP"> 
    <soap:address location="http://localhost:8014/associateservice/GAMEAssociate.svc"/> 
</port> 
</service> 

</definitions> 

RIFERIMENTI:

  1. WSDL - no input - best practice
  2. What does this WCF error mean: "Custom tool warning: Cannot import wsdl:portType"
  3. Writing a WSDL 1.1 Web Service Contract by Hand
  4. Writing Contract-First Web Services
  5. generate wcf server code from wsdl files
  6. How to get wsdl input and output names to appear
  7. Inline Schema
  8. Hand rolled SOAP request
+0

Hai detto che nessun parametro di ingresso e nessun parametro di output. Ma posso vedere che l'operazione sta definendo un input e un parametro di output. – IndoKnight

+0

@Indoknight Questi messaggi sono vuoti. Penso che abbiamo bisogno di questi messaggi come spiegato in http://stackoverflow.com/questions/1108736/wsdl-no-input-best-practice – Lijo

+1

Non ho lavorato su C#, ma WSDL sembra a posto. Ho controllato SOAPUI. – IndoKnight

risposta

1

Mi sono riferito a Inline Schema.Grazie anche a @Indoknight. Il contratto di lavoro WSDL è riportato di seguito.

Nota 1: Il prefisso XSD e targetNamespace è lì nello schema che viene utilizzato all'interno di WSDL type

Nota 2: nillable = "true" viene applicata per il tipo utilizzato nel messaggio di risposta

Nota3: Se stai ricevendo un'eccezione, assicurati che lo soapAction sia esattamente lo stesso nel contratto WSDL e il wsdl generato dal servizio WCF. Alcuni strumenti utilizzati per generare il codice di servizio possono modificare l'azione SOAP a proprio piacimento.

Faultcod: a:ActionNotSupported

Faultstring: The message with Action ' http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest ' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

SOAP Azione - Contratto WSDL

<soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 

SOAP Azione - WSDL generato

<soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/IGAMEAssociateIntf/getAllVicePresidents" 

contratto WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<definitions name="GAMEAssociate" 
    targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
    xmlns:tns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsp="http://www.w3.org/ns/ws-policy" 
    > 

<types> 
<xsd:schema targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" > 
    <xsd:element name="myData"> 
    <xsd:complexType /> 
    </xsd:element> 
    <xsd:element name="myDataResponse" nillable="true"> 
    <xsd:complexType /> 
    </xsd:element> 
</xsd:schema> 
</types> 

<message name="getAllVicePresidentsRequest"> 
<part element="tns:myData" name="getAllVicePresidentsRequest"/> 
</message> 

<message name="getAllVicePresidentsResponse"> 
<part element="tns:myDataResponse" name="getAllVicePresidentsResponse"/> 
</message> 

<portType name="GAMEAssociateIntf"> 
<operation name="getAllVicePresidents"> 
    <input message="tns:getAllVicePresidentsRequest"/> 
    <output message="tns:getAllVicePresidentsResponse"/> 
</operation> 
</portType> 

<binding name="GAMEAssociateIntfBinding" type="tns:GAMEAssociateIntf"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="getAllVicePresidents"> 
    <soap:operation soapAction="http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest" 
        style="document"/> 
    <input> 
    <soap:body use="literal"/> 
    </input> 
    <output> 
    <soap:body use="literal"/> 
    </output> 
</operation> 
</binding> 

<service name="GAMEAssociate"> 
<port binding="tns:GAMEAssociateIntfBinding" name="GAMEAssociateSOAP"> 
    <soap:address location="http://localhost:8014/associateservice/GAMEAssociate.svc"/> 
</port> 
</service> 

</definitions> 

Richiesta

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"> 
<soapenv:Header/> 
<soapenv:Body> 
    <ns:myData/> 
</soapenv:Body> 
</soapenv:Envelope> 

risposta

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <myDataResponse xsi:nil="true" xmlns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"/> 
</s:Body> 
</s:Envelope> 
6

ho trascorso qualche tempo cercando di scoprire i problemi. La tua sezione tipi di wsdl non è corretta, dovrebbe essere come sotto. Con questo, ora posso generare artefatti lato client in Java.

<types> 
<schema targetNamespace="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/" 
      xmlns="http://www.w3.org/2001/XMLSchema"> 
    <element name="myData"> 
    <complexType/> 
    </element> 

    <element name="myDataResponse"> 
    <complexType/> 
    </element> 
</schema></types> 

UPDATE

Basato sulla conversazione di seguito. Aggiunto un attributo nillable.

<element name="myDataResponse" nillable="true"> 
<complexType/> 
</element> 

Richiesta

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"> 
<soapenv:Header/> 
<soapenv:Body> 
    <ns:myData/> 
</soapenv:Body> 
</soapenv:Envelope> 

risposta

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <myDataResponse xsi:nil="true" xmlns="http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/"/> 
</s:Body> 
</s:Envelope> 
+0

Grazie. Quando l'ho provato con SOI UI, il 'myDataResponse' non appare nella risposta mentre' myData' è presente in input. Qualche idea del perché? – Lijo

+1

Ho creato il progetto SOAPUI con il wsdl modificato e creato anche un servizio di simulazione. Quindi ho ricevuto questa risposta IndoKnight

+1

State sparando la richiesta sul servizio web vera e propria ? Se sì, quale output stai vedendo? – IndoKnight

1

wsi.org ha una serie di strumenti di validazione, che sarebbe certamente la pena di provare.

Il vantaggio ulteriore dell'utilizzo di questi strumenti è che è possibile richiedere effettivamente la conformità alle specifiche WSDL.

Problemi correlati