dev@jax-ws.java.net

Namespace of webparam objects (wsimport generated stubs problem)

From: <malte.cornils_at_charite.de>
Date: Mon, 27 Jun 2011 13:01:36 +0000 (GMT)

Hello,

I'm facing a problem somewhat similar to JIRA issue 842
(http://java.net/jira/browse/JAX_WS-842), which already had
some helpful comments by Rama Pulavarthi leading my a little further.

We have an object (with fields containing references to other objects,
e.g. KeyValue)
called Event that has been given namespace annotations like this:

@XmlRootElement(namespace = "http://tmcc.charite.de")
@XmlType(namespace="http://tmcc.charite.de")
public class Event ... {

       @XmlElement(namespace = "http://tmcc.charite.de")
       public KeyValue[] getKeyvalue() {...

In our web service, we have a method called "listen" that takes one of
these as
a Webparam. We explicitly specify the namespace there:

@WebMethod(operationName = "listen")
       @WebResult(name = "event", targetNamespace =
"http://tmcc.charite.de")
       public Event listen(
                       @WebParam(name = "event", targetNamespace =
"http://tmcc.charite.de") Event event, ...

This (dual) specification of namespaces works e.g. for SoapUI, which
generates wire
soap messages containing this:

     <tmcc:listen>
        <tmcc:event>
           <tmcc:keyvalue> <!-- one of the sub-elements -->
           </tmcc:keyvalue>
        </tmcc:event>
     </tmcc:listen>

However, when using wsimport to generate stub code and calling the
listen method,
on the wire, the following is sent:

<ns2:listen xmlns:ns2="http://tmcc.charite.de"
xmlns:ns3="http://de.tembit.com/zpsd">
<event>
<ns2:keyvalue>

which is not accepted by the web service (probably since event is not
qualified).

When using package-info.java in the code containing the client to set
the elements
to qualified like this:

@XmlSchema( namespace = "http://tmcc.charite.de", elementFormDefault =
XmlNsForm.QUALIFIED )
package de.charite.tmcc.stubs;
import javax.xml.bind.annotation.XmlSchema;

I get the following over the wire:
<listen xmlns="http://tmcc.charite.de"
xmlns:ns2="http://de.tembit.com/zpsd">
<event>
<keyvalue>

That means the namespace prefixes are dropped from all the internal
elements.
However, since the default NS has been set and is thus also valid for
the
children elements, everything is fine. This is accepted by the stub
(Yay!).

However, unfortunately, we need the namespace prefixes to be there like
in the
SoapUI request.

Is there any way to force the JAX-WS generated client to prefix-qualify
all
the elements, especially the <event> element?

If it helps, I can send over a zipped eclipse project. Is there any
documentation
I have missed? The link to the architecture document and to the web
forums
seems to be dead, as well as some links in the wiki.

Do you have any idea where I can find documentation regarding this
behaviour, or better yet, example code how to get the JAX-WS client
to behave like SoapUI in this case?

Any help would be greatly appreciated; I'm also willing to write up
my experiences more fully and post them online so others won't
have the same problem.

Yours,
-Malte Cornils