can't force SOAPClient to generate correct SOAP
tereus Feb 10, 2009 6:24 AMHi there,
I have a problem with SOAPClient. I use it to call a WebService, but the generated SOAP body doesn't contain the object graph I want it to contain.
First, a piece of WSDL:
<xs:element name="sendDRO" type="tns:sendDRO"/> <xs:element name="sendDROResponse" type="tns:sendDROResponse"/> <xs:complexType name="sendDRO"> <xs:sequence> <xs:element minOccurs="0" name="dro" type="tns:dro"/> </xs:sequence> </xs:complexType> <xs:complexType name="dro"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="dane" nillable="true" type="tns:odbiorca"/> <xs:element minOccurs="0" name="dataDo" type="xs:dateTime"/> <xs:element minOccurs="0" name="dataOd" type="xs:dateTime"/> </xs:sequence>
sendDRO is an operation i want to use. The "dro" type is my own class, as this WebService is mine, deployed on tomcat from web.xml.
Now I want to send a WS message containing this DRO object (which matches wsdl's dro type perfectly, as it was generated automatically from DRO type).
The question is : how should I attach the DRO object? I tried two ways:
1. the dro type.
public Message prepareDRO(Message msg) { Map<String,Object> map = new HashMap<String, Object>(); map.put("sendDRO.dro", ((DRO)msg.getBody().get(WSFacade.PAYLOAD_NAME))); msg.getBody().add(map); return msg; }
Here i tried to name this object "dro" insted of "sendDRO.dro" as well.
2. Generate wrapper class sendDRO (matching WSDL type) and do something like:
public Message prepareDRO(Message msg) { Map<String,Object> map = new HashMap<String, Object>(); map.put("sendDRO", new SendDRO(((DRO)msg.getBody().get(WSFacade.PAYLOAD_NAME)))); msg.getBody().add(map); return msg; }
For all those cases, the SOAP msg which SOAPClient was sending to WS was the same:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://webservice_producer/testingwsfacade"> <soapenv:Header/> <soapenv:Body> <tes:sendDRO> <!--Zero or more repetitions: - cloned--> </tes:sendDRO> </soapenv:Body> </soapenv:Envelope>
And, ofcourse, inside WS method the "dro" param was null.
Can anybody tell me what am I doing wrong?
Thanks