Include Schema Type in WSDL File

I created WSDL manually, which has only one operation with no input parameter and no output parameter.

I get the following error when trying to create a client from this WSDL:

Cannot import wsdl: portType Details: when starting the WSDL import extension, an exception was thrown: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: schema with target namespace http://www.xmlns.mycompany.com/GAME/service/Associate/1.1/ 'not 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

types (for use in the client) must be created from the XML present in the WSDL. I think by adding a Service Reference, the tool could not create it due to some XML error. Xsd problem.

What changes need to be done in WSDL to create a proxy?

Note. I am trying to include the xml types defined in the WSDL itself. [I do not need a separate file to limit the circuit]

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> 

LITERATURE

+8
wsdl web-services wcf xsd contract-first
source share
3 answers

I called the built-in circuit . Thanks @Indoknight as well. The following is the working WSDL protocol.

Note1: the prefix xsd and targetNamespace are in the scheme that is used inside the wsdl type

Note2: nilable = "true" applies to the type used in the response message

Note 3. If you get the following exception, make sure the soapAction exactly the same in the contract WSDL and wsdl generated from the WCF service. Some tools used to generate utility code can modify the SOAP action of their own free will.

Faultcod: a: ActionNotSupported

Faultstring: a message with the action " http://www.xmlns.mycompany.com/GAME/wsdl/AssociateIntf/1.4/getAllVicePresidentsRequest 'could not be processed at the receiver due to a ContractFilter mismatch in the EndpointDispatcher. This may be due to a contract mismatch (actions mismatch between the sender and the recipient) or binding / security mismatch between the sender and the recipient Make sure that the sender and the recipient have the same contract and the same binding (including security requirements, such as message, transport, no)

SOAP Action - WSDL contract

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

SOAP Action - Created by WSDL

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

WSDL contract

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

Request

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

answer

 <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> 
+1
source share

I spent some time trying to figure out the problems. Your <types> wsdl section is incorrect, it should look like this. Thanks to this, I can now create client-side artifacts 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

Based on the conversation below. Added nillable attribute.

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

Request

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

answer

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

wsi.org has a set of validation tools that are definitely worth a try.

An added benefit of using these tools is that you can actually require compliance with the WSDL specifications.

+1
source share

All Articles