• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Escape Newline Characters

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have big problem URGENTLY when i try to send a SOAP request which include newline character to web service

If i substitue newline character with
the soap request in xml will look like this 
 (auto escaping for me)

If i substitue newline character with 

the soap request in xml will look like this 
 (auto escaping for me)

If i substitue newline character with ![CDATA[ ]]
the soap request in xml will look like this ![CDATA[ ]] BUT the web service server will take the value as it is ![CDATA[ ]]
I want to make sure the web service server interpret ti as \n
I need to explicitly specifiy this value in the soap request xml, so that the web service server process it as \n

How do i manage to do that?
Zillions thanks if anyone can help

 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Would encoding the string data containing the newline character(s) using base-64 be an option for you?
This would of course mean that the client must encode the string and that the string later must be decoded on the server side.
Best wishes!
 
Alex Lee
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
If i were to use data encoding Base64, then server side must change too, am i right?

In short, i just want to make sure in my SOAP request
i can have this value only 
 NOT 


Because only this value, the server side can interpret as newline

Thanks for all help.....
 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Software engineering or Software plumbing: The issue is Predefined entities in XML.

I don't know how on the client side, the soap request message is generated.
But can you just POST it as an "xml String" using java.net.URL or Apache client.

For example:


But even if it's OK for the client to successfully sent to the server 

I'm not sure how the server soap engine see it. I doubt it will preserve 

It will re-inprete/translate as 

Then it will forward that to the target endpoint which will see it as 
 (which is unwanted)

If possible, what/how is your client and server is using?

EDITED: to display the values: 
 

 
Alex Lee
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We are not sure what the server engine using. It is external party integration

We have tested by putting the value &#10 directly in the server side, the server know how to interpret it as \n (newline)

So now we want to make sure our client generated the SOAP request with value 
 NOT 


For client, we are using Axis.

So we don't take care of the URL.post (getSOAPRequestMessage)
We auto generated the client using Axis WSDL2Java, so we have classes like
WebService_ServiceLocator, WebServicePortBindingStub,WebService_PortType and etc




ARRGH , i wanna cry already... is that limitation of SOAP???

PLEASE HELP ANYONE


H Paul wrote: Software engineering or Software plumbing: The issue is Predefined entities in XML.

I don't know how on the client side, the soap request message is generated.
But can you just POST it as an "xml String" using java.net.URL or Apache client.

For example:


But even if it's OK for the client to successfully sent to the server 

I'm not sure how the server soap engine see it. I doubt it will preserve 

It will re-inprete/translate as 

Then it will forward that to the target endpoint which will see it as 
 (which is unwanted)

If possible, what/how is your client and server is using?

EDITED: to display the values: 
 


 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A. Possible options with the Soapful-based web service:

1. Construct the xml String and POST it using URL for example as the code sample shown.
The question is how big the SOAP message look like?

2. Construct the SOAP Message using SAAJ api and send the SOAP message using SAAJ.

3. Using WSDL2Java as you did BUT now you to find a way to let override
the underlying "Character Escaping Control of XML entities" of the SOAP engine, in your case AXIS
i.e look into AXIS api to look where you can do that,
i.e tell it NOT to convert the 
 to 


For option 3: even if you use another SOAP engine/toolkit/stack, you still have to
override the underlying "Character Escaping Control of XML entities"

4. Some one else see some thing else that I do not see.

B. Possible options with the Restful-based web service:

1. Ask if your third-party provide a Restful webservice where you can use JAX-RS client api
will make your life easier instead of A.1, A.2, A.3.

EDITED: to display the values: 
 

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic