Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SOAP literal xml serialization  RSS feed

 
satish bhatia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I are stuck with an error
(java.lang.IllegalArgumentException: I only know how to serialize an org.w3c.dom.Element'. )
and am clueless abt solving it. I am a young student developing a soap application for the very first time and would greatly appreciate your guidance on how to solve this.
The really short code I am showing you below is passing two literal xml (org.w3c.dom.Element) parameters to another method via a soap call and expects an interger return value denoting succes or failure. However I keep getting the illegalArgumentException that i mentioned above. Can you please tell me what is wrong with my code.
thank you so much!!!
regards,
satish.

public synchronized short CalculateResults(org.w3c.dom.Element listinput,org.w3c.dom.Element listoutput) throws Exception
{
String targetObjectURI = "http://tempuri.org/message/";
String SOAPActionURI = "http://tempuri.org/action/ProcessRes.CalculateResults";
SOAPMappingRegistry smr = new SOAPMappingRegistry();
StringDeserializer sd = new StringDeserializer();
IntDeserializer intdeserialize = new IntDeserializer();
org.apache.soap.encoding.literalxml.XMLParameterSerializer xmlserialize = new org.apache.soap.encoding.literalxml.XMLParameterSerializer();


//call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setEncodingStyleURI("http://xml.apache.org/xml-soap/literalxml");
call.setTargetObjectURI(targetObjectURI);

smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","Result"),null,null,intdeserialize);

smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","listinput"),org.w3c.dom.Element.class,null,xmlserialize);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","listoutput"),org.w3c.dom.Element.class,null,xmlserialize);

Vector params = new Vector();

Parameter listinputParam = new Parameter("listinput", org.w3c.dom.Element.class, listinput, "http://xml.apache.org/xml-soap/literalxml");
params.addElement(listinputParam);

Parameter listoutputParam = new Parameter("listoutput", org.w3c.dom.Element.class, listoutput, "http://xml.apache.org/xml-soap/literalxml");
params.addElement(listoutputParam);


call.setParams(params);
call.setMethodName("CalculateResults");
call.setSOAPMappingRegistry(smr);

Response resp = call.invoke(getURL(), SOAPActionURI);
}
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that error message from the client or from the SOAP server?
Bill
 
satish bhatia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the error message
exception: [SOAPException: faultCode=SOAP-ENV:Client; msg=I only know how to serialize an 'org.w3c.dom.Element'.; targetException=java.lang.IllegalArgumentException: I only know how to serialize an 'org.w3c.dom.Element'.]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to send Document objects? That wont work, you need to get the Document root Element for SOAP to serialize it because a Document has extra stuff attached.
Element root = doc.getDocumentElement();
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!