I'm trying to create a DOC/LIT
style service that uses an object that contains getters and setters for a List
of objects.
The List contains RequestFormItemizedLine objects. The containing object, ItemizedRequestForm, looks like:
The List contains RequestFormItemizedLine objects. The containing object, ItemizedRequestForm, looks like:
public class
ItemizedRequestForm{
public List getItemizedLines()
public void setItemizedLines(List)
}
public List getItemizedLines()
public void setItemizedLines(List)
}
Anyway, I run the java2wsdl and get this in my
WSDL:
<complexType
name="ItemizedRequestForm">
<sequence>
....
<element maxOccurs="1" minOccurs="0" name="itemizedLines" nillable="true" type="impl:ArrayOf_tns1_RequestFormItemizedLine" />
....
</sequence>
</complexType
<sequence>
....
<element maxOccurs="1" minOccurs="0" name="itemizedLines" nillable="true" type="impl:ArrayOf_tns1_RequestFormItemizedLine" />
....
</sequence>
</complexType
<complexType name="ArrayOf_tns1_RequestFormItemizedLine">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:RequestFormItemizedLine" />
</sequence>
</complexType>
<complexType
name="RequestFormItemizedLine">
<sequence>
....
</sequence>
</complexType>
<sequence>
....
</sequence>
</complexType>
Then I run wsdl2java (have tried both wrapArrays=true/false) to generate the client stubs, and at runtime I get a SOAP request that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com">
.....
<itemizedLines>
<ns1:item xmlns:ns1="http://MomentumWebServices/service/ItemizedRequestFormService">
.....
</item>
</itemizedLines>
</ItemizedRequestForm4>
.....
</Body>
</Envelope>
When the SOAP message is being processed on the
server this results in an exception:
org.xml.sax.SAXException: SimpleDeserializer
encountered a child element, which is NOT expected, in something it was trying
to deserialize.
My first question has to do with the WSDL, why does it automatically use the name "item" when it's not a valid field in the object? My second question
is in the generated stubs, why does is assume the target namespace for item? This is incorrect since it doesn't corespond to any object in that namespace,
and it seem like on the server it can't find the deserializer for that combination and defaults to the SimpleDeserializer, which throws the error.
Shouldn't the SOAP request really look something like (assuming there were 3 RequestFormItemizedLine objects in the List):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ItemizedRequestForm4 xmlns="http://form.pe.domain.momentum.ams.com">
.....
<itemizedLines xmlns="http://MomentumWebServices/service/ItemizedRequestFormService">
<ns1:RequestFormItemizedLine xmlns:ns1="http://form.pe.domain.momentum.ams.com">
.....
</RequestFormItemizedLine>
<ns1:RequestFormItemizedLine xmlns:ns1="http://form.pe.domain.momentum.ams.com">
.....
</RequestFormItemizedLine>
<ns1:RequestFormItemizedLine xmlns:ns1="http://form.pe.domain.momentum.ams.com">
.....
</RequestFormItemizedLine>
</itemizedLines>
</ItemizedRequestForm4>
.....
</Body>
</Envelope>
Could someone please let me know if this is correct or not, and how to get the client to send the SOAP request in the correct way?
-Thanks in advance
Ben
