Java 来自WSDL的Web服务XML请求格式
我刚开始使用web服务,我刚刚遇到了一个疑问。我有WSDL文件,我想开发web服务。我已经试用过Axis2和CXF,不知道问题是概念性的还是技术性的 我的导师给我这个wsdl文件:Java 来自WSDL的Web服务XML请求格式,java,xml,web-services,soap,wsdl,Java,Xml,Web Services,Soap,Wsdl,我刚开始使用web服务,我刚刚遇到了一个疑问。我有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:n
<?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>
基拉
约翰·史密斯
123456789
但我收到一个错误,如:
...
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client</faultcode>
<faultstring>No such operation 'NewDog'</faultstring>
...
。。。
ns1:客户端
没有这样的“新狗”行动
...
我不知道我是否错了,但是,像下面这样的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>
提前非常感谢:)周末快乐 您提供的WSDL不完整。你能在这里发布整个WSDL吗?无论如何,从我所看到的,没有NewDog操作,所以如果你能发布整个WSDL,我会看一看。它已经改变了。谢谢从WSDL的外观来看,
NewDog
应该是InsertDog
。您使用什么生成请求负载?是的,您是对的,应该是这样的,但是消息格式与第一个wsdl不匹配。我必须更改模式和名称空间,使其正常工作,现在可以正常工作了。这种消息格式是否可以与wsdl一起使用?我想说不是。。。谢谢你的回复