wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "remove namespace from webservice response" Watch "remove namespace from webservice response" New topic

remove namespace from webservice response

Rajendar Chintala

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.


<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">
<p624:createOverageShortageResponse xmlns:p624="http://v1_0.returns.services.view.jdpoint.parts.deere.com">
<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>
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

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

Joined: Aug 19, 2005
Posts: 2922
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>
<tns:setCaseId xmlns:tns="http://beans.v1_0.returns.services.view.jdpoint.parts.deere.com">0100S00679</tns:setCaseId>
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.
Yu Limin

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
httpclient for accessing webservice
Error : Axis Engine Cudn't find the target
How to make XML file from WebService responses?
Soap format
SOAPHeader Actor and MustUnderStand