Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Changing <SOAP-ENV> prefix in SAAJ?

843834May 20 2003 — edited Aug 31 2005
I'm using the latest webservices pack from Sun and have hit a roadblock.

We have some external clients that are relying on the SOAP messages we send them to have the prefix namespace <SOAP>. The SAAJ implementation seems to be hardcoding <SOAP-ENV>.

Is there anyway to specify/override the default SOAP namespace prefix?

i.e.

<SOAP-ENV:Envelope> --> <SOAP:Envelope>

Thanks,
- Tim

Comments

843834
I didn't see anything in the API that jumped out at me. You could always use a replaceAll call to fix it after creating it with SAAJ.

It sucks that your clients are the kind of people that ask you to work around their inadequacies. I know how that is and its really frustrating. I feel for you.
843834
Yeah..I don't know which I hate more, the fact they are too lazy to fix their own problems or our company for saying we'd work around it.

Anyway, do you have an example of the replaceAll? I didn't see it in the SAAJ API.

Thanks,
- Tim
843834
Anyway, do you have an example of the replaceAll? I
didn't see it in the SAAJ API.
No, I meant String.replaceAll(). Of course you'll have to write it out to a String and write a simple regex. There may also be a way to change the namespace with DOM but I'm not going to delve into that right now.
843834
Thanks..I thought you might be referring to that.. :(

I've been looking at DOM, I'm already jumping in and out of DOM to support some missing things in SAAJ. But I didn't see anything jump out to fix this problem.
843834
I managed to change my SOAP-ENV but the problem then is that unless you declare the namespace in every tag it add a xmlns="" to the first non specified tag.
how I changed the SOAP-ENV is as follows


SOAPPart part = msg.getSOAPPart();
//get the envelope
SOAPEnvelope envelope = part.getEnvelope();
//add the soap declaration
envelope.addNamespaceDeclaration("soap","http://schemas.xmlsoap.org/soap/envelope/");
//remove the default SOAP-ENV
envelope.removeNamespaceDeclaration("SOAP-ENV");
//Set the prefix to soap instead of SOAP-ENV
envelope.setPrefix("soap");

Mike
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 28 2005
Added on May 20 2003
5 comments
806 views