You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Enrico Goosen <en...@ipay.co.za> on 2004/05/12 12:27:53 UTC
Serializer
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
Re: Serializer
Posted by Enrico Goosen <en...@ipay.co.za>.
Hi John,
I don't unfortunately have that book.
I tried the following, after looking at org.apache.axis.client.Call
source:
//First create an AxisServer using deploy.wsdd
InputStream is = getClass().getResourceAsStream("deploy.wsdd");
FileProvider provider = new FileProvider(is);
axisServer = new AxisServer(provider);
...
//Process response
Login_Response loginResBean = new Login_Response();
loginResBean.setCurrentVendorCredit(new CurrencyT(new
BigDecimal(777.00)));
MessageContext msgContext0 = new MessageContext( axisServer );
QName operationName = new
javax.xml.namespace.QName("http://www.nrs.eskom.co.za/XMLVend/",
"Login_Response");
RPCParam rpcParam = new RPCParam(
"http://www.nrs.eskom.co.za/XMLVend/",
"Login_RequestResponse", loginResBean);
RPCElement body = new RPCElement(
operationName.getNamespaceURI(),
operationName.getLocalPart(),
new Object [] {rpcParam});
org.apache.axis.message.SOAPEnvelope reqEnv = new
org.apache.axis.message.SOAPEnvelope(msgContext0.getSOAPConstants(),
msgContext0.getSchemaVersion());
org.apache.axis.Message reqMsg = new org.apache.axis.Message( reqEnv );
reqEnv.addBodyElement(body);
reqEnv.setMessageType(org.apache.axis.Message.RESPONSE);
return reqMsg;
Now I'm getting the following error:
java.io.IOException: No serializer found for class
za.co.eskom.nrs.xmlvend.Login_Response in registry
org.apache.axis.encoding.DefaultTypeMappingImpl@13043d2
Any ideas?
Regards,
Enrico
Excerpt from deploy.wsdd:
<typeMapping
xmlns:ns="http://www.nrs.eskom.co.za/XMLVend/"
qname="ns:Login_Response"
type="java:za.co.eskom.nrs.xmlvend.Login_Response"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
On Thu, 2004-05-13 at 00:53, John R Meloro wrote:
> If I understand what you are saying, you want to take the servers response
> and re-package it as a SOAP Message and send it somewhere else?
>
> If so, then you would need to write your own class which creates a SOAP
> Message. The following book will tell you how to create your own SOAP
> Message Builder:
>
> http://www.oreilly.com/catalog/javawebserv/
>
>
>
>
> ----- Original Message -----
> From: "Enrico Goosen" <en...@ipay.co.za>
> To: <ax...@ws.apache.org>
> Sent: Wednesday, May 12, 2004 6:27 AM
> Subject: Serializer
>
>
> > 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
> >
> >
> >
> >
>
Re: Serializer
Posted by John R Meloro <jm...@adelphia.net>.
If I understand what you are saying, you want to take the servers response
and re-package it as a SOAP Message and send it somewhere else?
If so, then you would need to write your own class which creates a SOAP
Message. The following book will tell you how to create your own SOAP
Message Builder:
http://www.oreilly.com/catalog/javawebserv/
----- Original Message -----
From: "Enrico Goosen" <en...@ipay.co.za>
To: <ax...@ws.apache.org>
Sent: Wednesday, May 12, 2004 6:27 AM
Subject: Serializer
> 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
>
>
>
>