Hi all,
I need some help with the following problem:
Overview:
My java object receives and parses a SOAP message (on a TCP/IP socket)
then calls an appropriate operation/method on a remote web service using
a client stub (RPC HTTP Request).
The remote web service returns a SOAP response message and the client
stub automatically deserializes the body element into a Java object.
(see below: Login_Response)
I need to return a SOAP message back onto the TCP/IP socket containing
the serialized Java Object in the SOAP body.
Message flow:
Web service client <- HTTP -> My Web service <- TCP/IP socket -> My
Transaction Server <- HTTP -> another Web service <- ??? -> Another
Server
I've found the following code which is sort of on the right track, but
the SOAP XML that it outputs is messy:
Login_Response response = stub.login_Request(null, null, msgID, null,
null, null);
MessageContext msgContext0 = new MessageContext(new AxisServer());
Writer stringWriter0 = new StringWriter();
SerializationContext context0 = new
SerializationContextImpl(stringWriter0, msgContext0);
QName qn0 = loginResBean.getTypeDesc().getXmlType();
BeanSerializer theBeanSe=(BeanSerializer)loginResBean.getSerializer("",
loginResBean.getClass(),qn0);
theBeanSe.serialize(qn0, null, loginResBean ,context0);
stringWriter0.close();
String s=stringWriter0.toString();
logger.info(s);
OUTPUT:
<ns1:Login_Response xmlns:ns1="http://www.nrs.eskom.co.za/XMLVend/">
<TerminalID xsi:type="ns2:TerminalIDT" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="http://nrs.eskom.co.za/XMLVend/schemas/2004/02"/>
<MsgId xsi:type="ns1:MsgIDComplexType" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<OperatorMsg xsi:type="ns3:MsgT" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns3="http://nrs.eskom.co.za/XMLVend/schemas/2004/02"/>
<Custom xsi:type="ns4:MsgT" xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns4="http://nrs.eskom.co.za/XMLVend/schemas/2004/02"/>
<CurrentVendorCredit href="#id0"/>
</ns1:Login_Response>
DESIRED OUTPUT:
<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>
<Login_RequestResponse xmlns="http://www.nrs.eskom.co.za/XMLVend/">
<Login_RequestResult>
<CurrentVendorCredit>10000</CurrentVendorCredit>
</Login_RequestResult>
</Login_RequestResponse>
</soapenv:Body>
</soapenv:Envelope>
The desired output above is somehow returned from the following Web
Service Test Class:
public class XMLVendServiceSoapImpl implements XMLVendServiceSoap{
public Login_Response login_Request(ClientIDT clientID, TerminalIDT
terminalID, MsgIDComplexType msgID, OpNameT opName, PasswordT password,
MsgT custom) throws java.rmi.RemoteException {
Login_Response res = new Login_Response();
res.setCurrentVendorCredit(new CurrencyT(new
BigDecimal(100.00)));
return res;
}
}
Any ideas how this is being achieved?
Regards,
Enrico