GeeCON Prague 2014*
The moose likes Web Services and the fly likes How to disable encoding in javax.xml.SOAP   message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "How to disable encoding in javax.xml.SOAP   message" Watch "How to disable encoding in javax.xml.SOAP   message" New topic
Author

How to disable encoding in javax.xml.SOAP message

Abhi Barik
Greenhorn

Joined: Feb 16, 2011
Posts: 2
Hi,

I am trying to create a SOAP message by javax.xml.SOAP package.
for one attribute we need to set the value as CreateTime >'10/10/2011' . so that our SOAP element of the request will look like below.

<ns:keys query=" CreateTime >'10/10/2011'"/>


I have used below code to form this soap element of the request .

String query = "CreateTime" + ">" + "'10/10/2011'";
QName keysName = new QName("keys");
SOAPElement keysElement = modelElement.addChildElement(keysName);
keysElement.setAttribute("query",query); // adding the query


This code creates the the SOAP request as below.

keys query="CreateTime & gt;'10/10/2011'

The web service does not recognize this SOAP request , because of > replaced by '>' in the SOAP request.

Could any one help me to disable this kind of encoding by javax.xml.SOAP. I need & gt; or & lt; in my request instead of > or <

Thanks,
Abhi

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
First of all, I do not think you can disable the kind of rewriting of characters such as '>' and '<' in XML data that you are talking about.
Second, I do not see anything wrong with the '>' character being replaced in your string, since the string in question is the value of an attribute, namely the query attribute.
Finally, I would like to see a complete SOAP message that you are trying to create in order to be able to give further advise - I suspect that you are trying to do something that perhaps can be done in a better way.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

Your example is not valid XML, but the encoded string is. So let the XML generator do its work, and write a proper parser to handle the encoded strings.
 
GeeCON Prague 2014
 
subject: How to disable encoding in javax.xml.SOAP message