WSDL定义问题

时间:2010-10-12 10:10:45

标签: wsdl

我们已经获得了一个.wsdl文件(在下面列出),我们将使用它来生成在我们的应用程序中使用的c#代码。当我将文件加载到xmlspy时,我收到以下错误

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

它说它找不到类型,但这是在文件顶部的部分中定义的,所以我不确定它为什么找不到它。

任何帮助将不胜感激

干杯

理查德

<?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"        encodingStyle="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>

1 个答案:

答案 0 :(得分:2)

<types>下面的类型声明需要有自己的命名空间。我猜你的wsdl的供应商在测试他们编写的WSDL时使用的是非常宽松的解析器,或者依赖于某些代码的第一个WSDL生成工具来创建这个WSDL。在任何一种情况下,他们都有责任为您提供符合要求的WSDL和xsd。

以下是该WSDL的相关部分应该是什么样子的示例 - 在此处根据需要更改名称空间:

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

    ...