aspose file tools
The moose likes Web Services and the fly likes JAXWS client SOAP manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "JAXWS client SOAP manipulation " Watch "JAXWS client SOAP manipulation " New topic
Author

JAXWS client SOAP manipulation

chinmay sagade
Greenhorn

Joined: Sep 04, 2008
Posts: 2
I have created stubs using a wsdl and posting a message to service.However i need to manipulate the SOAP message i am posting to this server.The problem i am facing is the client is adding default namespaces ex.ns2 in SOAP message which i don't want.
Do We have any way to do that in JAXWS?please guide.
Ivan Krizsan
Bartender

Joined: Oct 04, 2006
Posts: 2193
Hi!
To make sure I understand you correctly. The following is an example of XML generated by JAXB when marshalling a Java object.


So do you, from the above XML, wish to remove the following piece?
xmlns:ns2="http://www.ivan.com/calculator"

If this is the case you can:
1) Write a handler on the client side that processes all outgoing messages removing namespace declarations.
2) Do the marshalling of the request yourself and write the output to an XMLStreamWriter.
The XML stream writer is an instance of a class you write yourself that implements the XMLStreamWriter interface and delegates to another object implementing XMLStreamWriter. In your XML stream writer class there is one method that needs special attention:

By doing this, you ensure that there will be no namespace declarations in the XML document written. If you only want to remove selected namespaces, do filtering using the arguments of the method; arg0 is the namespace prefix and arg1 is the namespace URI.
The marshalling of a request object is done like this:

The problem now is how to fit the above solution into your generated classes. I'll get back later regarding that.
Best wishes!
chinmay sagade
Greenhorn

Joined: Sep 04, 2008
Posts: 2
exactly Ivan !!! can you please tell how to do that?
Ivan Krizsan
Bartender

Joined: Oct 04, 2006
Posts: 2193
I've been thinking about this a little and I feel that the simplest way is to skip using the generated client artifacts and generate the request yourself, using the JAXB generated classes. Then, to filter away the unnecessary namespace declaration, use the technique I outlined in my message above.
You also have to receive the request yourself, but JAXB will help you with the unmarshalling.

Alternatively, if you do not fear the overhead a handler will introduce, that option is still available.
Best regards!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JAXWS client SOAP manipulation
 
Similar Threads
JAXWS client: overwriting namespace prefixes
customizing soap messages
invoke a jaxws function by passing the HttpServletRequest
Help on JAX WS
need help tracing soap messages