Wsdl:命名空间中没有声明这样的元素

时间:2015-09-11 10:34:02

标签: xml wsdl

我尝试编写自己的wsdl。根据我的代码,我得到两个错误之一。 (在分析wsdl时使用:https://www.wsdl-analyzer.com

代码变体1

使用type

定义消息时
  <wsdl:message name="InstituteRequest">
    <wsdl:part name="instituteID" type="xs:string"/>
  </wsdl:message>

我收到此错误: The part of the message 'InstituteRequest' references a schema type instead of a schema element.但是解析器能够读取wsdl。

代码变体2

  <wsdl:message name="InstituteRequest">
    <wsdl:part name="instituteID" element="xs:string"/>
  </wsdl:message>

我收到错误:

The element reference 'xs:string' could not be resolved. There is no such element declared in the namespace 'http://www.w3.org/2001/XMLSchema'.

我基本上复制了现有Web服务的标题,所以我想知道为什么命名空间没有定义字符串?

整个代码

<?xml version="1.0" encoding="UTF-8"?>

<!-- Definition of the service -->
<!-- http://crunchify.com/basic-wsdl-structure-understanding-wsdl-explained/ -->
<!-- define own namespaces with xmlns:mynamespace (types can be used predefined in the web) -->
<wsdl:definitions  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost:3000/" targetNamespace="http://localhost:3000/">
  <!-- Define own data types -->
<!--   <wsdl:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://localhost:3000/">
      <xs:element name="HelloWorld">
        <xs:complexType/>
      </xs:element>
    </xs:schema>
  </wsdl:types> -->

  <!-- Parameters used in the webservice  -->
  <!-- Schmemas for elements: http://www.w3schools.com/schema/schema_simple.asp  -->
  <wsdl:message name="InstituteRequest">
    <wsdl:part name="instituteID" element="xs:string" type="xs:string"/>
  </wsdl:message>

  <wsdl:message name="InstituteResponse">
     <wsdl:part name="institute" element="xs:string" type="xs:string"/>
  </wsdl:message>

  <!-- Port types are combinations of methods (operations) and describe these-->
  <wsdl:portType name="ExampleManagerPort">
    <!-- Operations are the functions of the webservice, they expect in/-outputs -->
    <wsdl:operation name="GetInstitute">
      <wsdl:input message="tns:InstituteRequest"/>
      <wsdl:output message="tns:InstituteResponse"/>
    </wsdl:operation>

  </wsdl:portType>

  <!-- Bindings describe operations -->
  <wsdl:binding name="ExampleManagerBinding" type="tns:ExampleManagerPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="GetInstitute">
      <soap:operation soapAction="http://localhost:3000#GetInstitute" style="document"/>
        <wsdl:input>
          <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
          <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>

  </wsdl:binding>


  <!-- Service (api?) -->
  <wsdl:service name="ExampleManagerService">
    <!-- ports are endpointsd (respond to request) -->
    <wsdl:port name="ExampleManagerPort" binding="tns:ExampleManagerBinding">
      <soap:address location="http://localhost:3000/"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

0 个答案:

没有答案