wood burning stoves 2.0*
The moose likes Web Services and the fly likes Conversion of special characters in a SOAP WebService Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Conversion of special characters in a SOAP WebService Client" Watch "Conversion of special characters in a SOAP WebService Client" New topic
Author

Conversion of special characters in a SOAP WebService Client

Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Hi All,

I had thought that a SOAP wsdl generated client would be able to handle special character conversions when it sent data to the WebService.
But, I am seeing a problem that makes me think this is not correct.

Example:
A wsdl generated class has a method that takes a string which is a peice of data to be sent to the WebService.
The string is "!&*45ty$$" (without quotes).

Do the special characters need to be converted by me before I pass them to a wsdl generated class?

thanks,
Tyler


SCJP SCJD
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

I believe it's the ampersand & that is causing you a problem.

XML has issues with those.

WP
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

Normally code which generates XML will also be responsible for ensuring that the XML it generates is well-formed. So normally that code will escape ampersands in text nodes as it generates them. And normally code which is simply responsible for providing text to be included in the XML should not be responsible for escaping ampersands and so on.

Now, this may or may not be relevant to your question. I can't tell because you just have this mysterious undescribed problem. Perhaps you could provide some more details about this problem, to help us answer it better?
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
I guess I did not make my question clear.

Example:

A WS client, generated from a SOAP WSDL, has a generated class:




The code I wrote accepts a string "!&*45ty$$" from another source. My code then instantiates SendMe and then invokes send( "!&*45ty$$" ) and gets the ResponseObject back.

The question is, do I need to do conversion of the special characters in the string "!&*45ty$$" or can I pass it raw and expect the WS generated class SendMe to do the conversion?

I hope this is clearer...

Tyler
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

I don't know what kind of "conversion" you have in mind there, so it's pretty hard to answer that. What happened when you tried it?
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
I should have said " do I need to escape special characters or will the client side WS generated class do it for me? "

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

Paul Clapham wrote:And normally code which is simply responsible for providing text to be included in the XML should not be responsible for escaping ampersands and so on.


I'm assuming that's what you meant by "special characters". I ask again, what happened when you tried it?
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Let me give you more.

We have a provisioning system that communicates with another system (from another company, they gave us a WSDL we generated the client from it).
For a year everything has worked fine. Then they issued us a new password. The old password had no special characters in it (xml special characters) only characters and ordinals and dots.
eXAMPLE: r8.KLu90tY

The new password has special characters in it. When I tried to use our system to talk to theirs I get a 403 error (Forbidden).
I have called the other company and they confirmed the new password was correct. Multiple tries have failed.
I called them and asked them to set the password to one with no special characters and everything went back to working.

So, my theory is that the client classes generated from a SOAP WSDL do not (by default) do character escaping.

I am trying to confirm this with someone who knows more about the SOAP protocol, WSDLs, and WS than I do.

If soap classes generated from a WSDL are supposed to do character escaping (by some spec), then I can tell the other company about the problem and we don't need to do anything.
We are the only user of their software for this product.
If the strings need to be escaped in our code then OK, I can do that. Actually, I did not write this code, I have was awarded Thursday morning and I have been trying to figure it out.

I do not have a lab to test this in as this is their standby production system.
So, I am trying to determine which side the problem is on so I can not look to stupid to my boss.

I cannot just write a new class an deploy it to our server to test because that is against policy. It would have to be an authorized deployment.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

I think that before you try to fix anything, you should identify the problem more precisely.

So far you have a theory about "special characters". Let's try to make that more precise. Try some passwords which contain a variety of what you think are "special characters" and see whether they get incorrectly rejected or not.

Again, I'm pretty sure that it's WSDL's responsibility to do XML escaping and not yours. There's even a possibility that your server company is processing the web service request wrong and not doing escaping when it should be. But that's just speculation until you can pin down the problem better.
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
Hi Paul,

Thanks for you help.

I'm pretty sure that it's WSDL's responsibility to do XML escaping and not yours.

That's what I had thought, but I wanted to hear "absolutely" it is the WSDL's job.

I did get them to set it back to the original password and that worked fine.
But, when they set it to "!&*45ty$$", I got the 403 Forbidden SOAP response.

I can't just keep asking them to change their password and then retry. That makes us look like idiots.
Oh, well, I will keep researching the issue.

If you find anything that explicitly says the WSDL is supposed to handle escaping characters, I would appreciate it very much.

Actually, I just looked at the password that it was reset to, I mistyped it in the post. It should be: "/!&*45ty$$".

Thanks for your thoughts...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

Tyler Wright wrote:I can't just keep asking them to change their password and then retry. That makes us look like idiots.


Not necessarily. Tell them (truthfully) that you need to do that to research a problem. You could hint that the problem might be theirs. But don't hint that too strongly, because it's only one possibility among many. You could also tell them straight out (once you have confirmed it by some more testing) that ampersands don't work in your passwords, and ask them why that might be.
Tyler Wright
Ranch Hand

Joined: Jun 25, 2009
Posts: 40
hmmm...well, you know, I can do that.

I know one of their engineers who work with me to get this whole system to work together.
He may be able to help out...that's worth a try...maybe even if he can't, he may have an in with someone who can help.

Good Idea!
 
 
subject: Conversion of special characters in a SOAP WebService Client