我有一个 WSDL,我已经得到 wsimport 来为它生成好的代码。并且代码运行。“你好”操作(没有参数)做得很好。
但现在我正在调用“CreateSomething”操作。我的服务器代码抱怨请求中没有发送任何参数。但是我在我的服务器代码中将其注销,我就在那里看到它......
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:ABCDEFGRequest
xmlns:ns2="http://ray.com:55555/cgi-bin/WebObjects/App.woa/wa/abcsoap">
<AAA>999</AAA>
<BBB>Dept 999</BBB>
<CCC>Dept 999 password</CCC>
<DDD>abcNextTest</DDD>
</ns2:ABCDEFGRequest>
</S:Body>
</S:Envelope>
嘿,这对我来说看起来不错!最近怎么样?当我手动创建请求时,它可以工作。
所以,问题是
<AAA>999</AAA>
应该
<ns2:AAA>999</ns2:AAA>
但当然我不是在创建请求。JAX-WS 生成的代码是。那么,我如何告诉它参数也需要在命名空间中呢?这似乎有点基本。
下面是包含此操作的 WSDL 片段。
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://__HOST__/cgi-bin/WebObjects/__APP__.woa/wa/abcsoap"
targetNamespace="http://__HOST__/cgi-bin/WebObjects/__APP__.woa/wa/abcsoap">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://__HOST__/cgi-bin/WebObjects/__APP__.woa/wa/abcsoap">
<xsd:element name="ABCDEFGRequest">
<xsd:complexType>
<xsd:all>
<xsd:element name="AAA">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="3" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="BBB">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="40" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="CCC">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="40" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="DDD">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="8" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="ABCDEFGResponse">
<xsd:complexType>
<xsd:all>
<xsd:element name="AAA">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="3" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ABCDEFGRequestMessage">
<wsdl:part name="parameters" element="tns:ABCDEFGRequest"/>
</wsdl:message>
<wsdl:message name="ABCDEFGResponseMessage">
<wsdl:part name="parameters" element="tns:ABCDEFGResponse"/>
</wsdl:message>
<wsdl:portType name="LMSPortType">
<wsdl:operation name="ABCDEFG">
<wsdl:input name="ABCDEFGRequestMessage" message="tns:ABCDEFGRequestMessage"/>
<wsdl:output name="ABCDEFGResponseMessage" message="tns:ABCDEFGResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LMSBinding" type="tns:LMSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ABCDEFG">
<soap:operation soapAction="ABCDEFG"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LMSService">
<wsdl:port name="LMSPort" binding="tns:LMSBinding">
<soap:address location="http://__HOST__/cgi-bin/WebObjects/__APP__.woa/wa/abcsoap"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>