Wednesday, 4 September 2013

Getting JAX-WS to generate code with parameters that have namespaces?

Getting JAX-WS to generate code with parameters that have namespaces?

I have a WSDL and I have gotten wsimport to generate good code for it. And
the code runs. And the "hello" operation (with no parameters) does just
fine.
But now I am calling a "CreateSomething" operation. My server code is
complaining that no parameters are being sent in the request. But I log it
out in my server code and I see it right there....
<?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>
Hey, that looks fine to me! So, what up? And when I manually create a
request, that works.
So, the problem is that
<AAA>999</AAA>
should be
<ns2:AAA>999</ns2:AAA>
But of course I am not creating the request. The JAX-WS-generated code is.
So, how do I tell it that the parameter needs to be in the namespace also?
This seems kind of basic.
The slice of my WSDL that contains this operation is below.
<?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>

No comments:

Post a Comment