WSDL中的Web Service XML请求格式

时间:2015-02-28 14:05:26

标签: java xml web-services soap wsdl

我开始使用网络服务,我刚刚遇到了疑问。我有WSDL文件,我想开发Web服务。我已尝试使用Axis2和CXF,但我不知道问题是概念性的还是技术性的。

我的导师给我这个wsdl文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://ws.unit4.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://ws.unit4.com">

    <wsdl:types>
        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.unit4.com">

            <xs:element name="InsertDog">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="param0" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

            <xs:element name="InsertDogResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

        </xs:schema>
    </wsdl:types>

    <wsdl:message name="InsertDogRequest">
        <wsdl:part name="parameters" element="ns:InsertDog"/>
    </wsdl:message>

    <wsdl:message name="InsertDogResponse">
        <wsdl:part name="parameters" element="ns:InsertDogResponse"/>
    </wsdl:message>

    <wsdl:portType name="InsertDogPortType">
        <wsdl:operation name="InsertDog">
            <wsdl:input message="ns:InsertDogRequest" wsaw:Action="urn:InsertDog"/>
            <wsdl:output message="ns:InsertDogResponse" wsaw:Action="urn:InsertDogResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="InsertDogSoap11Binding" type="ns:InsertDogPortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="InsertDog">
            <soap:operation soapAction="urn:InsertDog" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="InsertDogServ">
        <wsdl:port name="InsertDogHttpSoap11Endpoint" binding="ns:InsertDogTransSoap11Binding">
            <soap:address location="x.x.x.x"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

我的导师也告诉我,这个Web服务必须能够接收和XML文档,如:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://ws.unit4.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
      <NewDog xmlns="http://gfr.com/">
          <name>Kira</name> 
          <owner>John Smith</owner> 
          <contactNumber>123456789</contactNumber>
      </NewDog>
  </soapenv:Body>
</soapenv:Envelope>

但我收到的错误如下:

...      
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client</faultcode> 
<faultstring>No such operation 'NewDog'</faultstring> 
...

我不知道我是不是错了,但是,不应该像下面这样的wsdl架构部分来解决这个XML请求吗?

<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.unit4.com">

    <xs:element name="NewDog">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                <xs:element minOccurs="0" name="owner" nillable="true" type="xs:string"/>
                <xs:element minOccurs="0" name="contactNumber" nillable="true" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="InsertDogResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

非常感谢你提前:)和愉快的周末!!

0 个答案:

没有答案