File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes remove namespace from webservice response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "remove namespace from webservice response" Watch "remove namespace from webservice response" New topic
Author

remove namespace from webservice response

Rajendar Chintala
Greenhorn

Joined: Jan 14, 2009
Posts: 5
Hi ,

Recently we moved to Z/Linux with WAS6.1 from Z/OS with WAS5.1.

one of my webservice clients are reporting there application is breaking because of its adding namspces infront of tags like below.
there are using raw xml formats for request and response not like beans.

how can i get rid of name spaces infront of tags from webservice response or how can I set a standard name space.

is it some with with was6.1 or Z/Linux?

Please help me with good solution.

Thanks in Advance.

-Raj





<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p624:createOverageShortageResponse xmlns:p624="http://v1_0.returns.services.view.jdpoint.parts.deere.com">
<p624:createOverageShortageReturn>
<p181:setCaseId xmlns:p181="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0100S00679</p181:setCaseId>
<p181:statusCode xmlns:p181="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0000</p181:statusCode>
<p181:statusMessage xmlns:p181="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">Creation Successful.</p181:statusMessage>
</p624:createOverageShortageReturn>
</p624:createOverageShortageResponse>
</soapenv:Body>
</soapenv:Envelope>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

If you don't want prefixes on the names of elements which are in a namespace, then you would have to make that namespace the default namespace. That would involve declaring the namespace in the root element like this:



Or you could declare this namespace as the default namespace in each element where it applies, rather like the example you posted did.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Rajendar Chintala wrote:how can i get rid of namespaces in front of tags from webservice response or how can I set a standard name space.

Unfortunately you rarely have that level of control on the XML that is generated by your SOAP stack. Chances are that in terms of XML the old and the new versions are equivalent. I'm not aware of any SOAP stack that lets you control the namespace prefixes and/or default namespace.

one of my webservice clients are reporting their application is breaking because of its adding namespaces infront of tags like below.

It is adding prefixes - the "namespaces" always have been part of the of the element names.

Appearently your client is hoping for:

and is simply scraping for the element's local names while ignoring the element namespaces.

For example: in terms of XML "setCaseId" is actually {http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com}setCaseId.
<setCaseId xmlns="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0100S00679</setCaseId>
is identical to
<p181:setCaseId xmlns:p181="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0100S00679</p181:setCaseId>
or
<tns:setCaseId xmlns:tns="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0100S00679</tns:setCaseId>
etc.
Ronald Bourret's XML Namespaces FAQ
James Clark: XML Namespaces

This strongly suggests that the client's "web service client program" is not sufficiently "namespace" aware. It needs to be updated to deal with arbitrary namespace prefixes.

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Yu Limin
Greenhorn

Joined: Dec 31, 2003
Posts: 2
You can implement handleResponse(MessageContext messageContext) method in the Web Services Handler, then remove the namespace and set the new Message without namespace to MessageContext

public class RemoveNameSpaceHandler extends GenericHandler
{
public boolean handleResponse(MessageContext messageContext)
{
//....


<a href="http://www.Java2Class.net" target="_blank" rel="nofollow">http://www.Java2Class.net</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: remove namespace from webservice response
 
Similar Threads
Soap format
How to make XML file from WebService responses?
SOAPHeader Actor and MustUnderStand
Error : Axis Engine Cudn't find the target
httpclient for accessing webservice