开发者

WSDL Definition Problem

We have been given a .wsdl file (listing below) which we will be using to generate c# code for use in our app. When I load the file into xmlspy I get the following error

attribute 'type' in message part 'organisation' (message 'getOrganisationResponse') refers to type 'organisation' which is not defined within the WSDL file!

It says it can't find the type but this is defined in the section at the top of the file, so I'm not sure why it does not find it.

Any help would be appreciated

Cheers

Richard

<?xml version="1.0" encoding="UTF-8"?>
<definitions 
    xmlns:tns="http://www.xxxx.com/epp/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:ns1="http://xml.apache.org/xml-soap/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    name="Heiq" 
    targetNamespace="http://www.xxxx.com/epp/">


  <types>
  <!-- Organisation object -->
  <xsd:element name="organisation">
  <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="id" type="xsd:string" minOccurs="0"/>
     <xsd:element name="componentID" type="xsd:string" minOccurs="0"/>
     <xsd:element name="name" type="xsd:string" minOccurs="0"/>
     <xsd:element name="suburb" type="xsd:string" minOccurs="0"/>
     <xsd:element name="address1" type="xsd:string" minOccurs="0"/>
     <xsd:element name="address2" type="xsd:string" minOccurs="0"/>
     <xsd:element name="postcode" type="xsd:string"/>
     <xsd:element name="phone" type="xsd:string"/>
     <xsd:element name="fax" type="xsd:string"/>
     <xsd:element name="emailAddress" type="xsd:string"/>
     <xsd:element name="website" type="xsd:string"/>
     <xsd:element name="contactPersonName" type="xsd:string"/>
    </xsd:sequence>
   </xsd:complexType>
  </xsd:element>
 </types>


 <message name="getOrganisationRequest">
  <part name="token" type="xsd:string"/>
  <part name="organisationID" type="xsd:string"/>
 </message>

 <message name="getOrganisationResponse">
  <part name="organisation" type="organisation"/>
 </message>


  <portType name="xxxxPortType">
  <!-- Get organisation function -->
  <operation name="getOrganisation">
   <input message="tns:getOrganisationRequest"/>
   <output message="tns:getOrganisationResponse"/>
  </operation>
 </portType>


 <binding name="xxxxBinding" type="tns:xxxxPortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <!-- Get organisation function -->
  <operation name="getOrganisation">
   <input>
    <soap:body use="encoded"        encodi开发者_Python百科ngStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </input>
   <output>
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </output>
  </operation>
 </binding>


 <service name="xxxxService">
  <port name="xxxxPort" binding="tns:xxxxBinding">
   <soap:address location="http://www.xxxx.com/xxxx/application/soap.php"/>
  </port>
 </service>

</definitions>


Your type declarations underneath <types> need to be given their own namespace. I'm guessing that the supplier of your wsdl either used an extremely lax parser when testing the WSDL they wrote or relied on some code first WSDL generation tool to create this WSDL. In either case, the onus is on them to get you a properly conforming WSDL and xsd.

Here is an example of what the relevant parts of that WSDL should look like - change the namespaces here as you wish:

<?xml version="1.0" encoding="UTF-8"?>
<definitions 
    xmlns:tns="http://www.xxxx.com/epp/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:ns1="http://xml.apache.org/xml-soap/"
    xmlns:types="http://www.xxxx.com/types/"    
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    name="Heiq" 
    targetNamespace="http://www.xxxx.com/epp/">


    <types>
        <xsd:schema targetNamespace="http://www.xxxx.com/types/"
            xmlns="http://www.w3.org/2001/XMLSchema">
        <xsd:complexType name="organisation">
            <xsd:sequence>
                <xsd:element name="id" type="xsd:string" minOccurs="0"/>
                <xsd:element name="componentID" type="xsd:string" minOccurs="0"/>
                <xsd:element name="name" type="xsd:string" minOccurs="0"/>
                <xsd:element name="suburb" type="xsd:string" minOccurs="0"/>
                <xsd:element name="address1" type="xsd:string" minOccurs="0"/>
                <xsd:element name="address2" type="xsd:string" minOccurs="0"/>
                <xsd:element name="postcode" type="xsd:string"/>
                <xsd:element name="phone" type="xsd:string"/>
                <xsd:element name="fax" type="xsd:string"/>
                <xsd:element name="emailAddress" type="xsd:string"/>
                <xsd:element name="website" type="xsd:string"/>
                <xsd:element name="contactPersonName" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
        </xsd:schema>
    </types>


    <message name="getOrganisationRequest">
        <part name="token" type="xsd:string"/>
        <part name="organisationID" type="xsd:string"/>
    </message>

    <message name="getOrganisationResponse">
        <part name="organisation" type="types:organisation"/>
    </message>

    ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜