You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Mike Key <mi...@zenbitz.com> on 2012/02/27 03:44:20 UTC
JAXB qualified namespace not working
I apologize if this question has been answered before. I looked and have
seen similar questions asked but not need an answer.
I have a code first JAX-WS service built with CXF 2.5.2 with a simple login
service that takes a LoginType which I've annotated as follows:
@XmlRootElement(namespace = "http://mynamespace.com")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LoginType", propOrder = {
"loginObjectPayload"
})
public class LoginType
{
@XmlElement(name = "LoginObjectPayload", required = true)
public LoginObjectPayload loginObjectPayload;
…
}
The WSDL generated shows that namespace elements are set as qualified:
<wsdl:definitions xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="
http://mynamespace.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"name="MyEndpoint"
targetNamespace="http://mynamepsace">
<wsdl:types>
<xs:schema xmlns:tns="http://mynamespace" xmlns:xs="
http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified" targetNamespace="http://mynamepsace">
…
However when I try to send messages to this service via any tool such as
soapUI or any given client where I can send in raw XML that looks like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:mes="http://mynamespace.com">
<soapenv:Header/>
<soapenv:Body>
<mes:LoginRequest>
<mes:LoginObjectPayload>
...
</mes:LoginObjectPayload>
</LoginRequest>
</soapenv:Body>
</soapenv:Envelope>
I get an unmarshalling error from CXF. If I remove the qualified namespace
from ONLY the LoginRequest element it seems to work fine. This seems like
an anomaly to me, can someone tell me why this would occur and what I may
be doing wrong?
Thanks!
Re: JAXB qualified namespace not working
Posted by Daniel Kulp <dk...@apache.org>.
Any chance of whipping up a small example that shows the issue? I'm actually
kind of curious about how you got it to be elementFormDefault="qualified"
considering the default in CXF is unqualified. It can be done, but through
several code paths so I'm wondering which one might be the issue.
That said, this error is very strange. The direct children of soap:Body
must be namespace qualified so removing that namespace would result in an
invalid soap message. CXF definitely should not be expecting an invalid soap
message.
In anycase, an example would really help.
Dan
On Sunday, February 26, 2012 7:44:20 PM Mike Key wrote:
> I apologize if this question has been answered before. I looked and have
> seen similar questions asked but not need an answer.
>
> I have a code first JAX-WS service built with CXF 2.5.2 with a simple login
> service that takes a LoginType which I've annotated as follows:
>
> @XmlRootElement(namespace = "http://mynamespace.com")
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "LoginType", propOrder = {
> "loginObjectPayload"
> })
> public class LoginType
> {
>
> @XmlElement(name = "LoginObjectPayload", required = true)
> public LoginObjectPayload loginObjectPayload;
> …
> }
>
> The WSDL generated shows that namespace elements are set as qualified:
>
> <wsdl:definitions xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="
> http://mynamespace.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"name="MyEndpoint"
> targetNamespace="http://mynamepsace">
> <wsdl:types>
> <xs:schema xmlns:tns="http://mynamespace" xmlns:xs="
> http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
> elementFormDefault="qualified" targetNamespace="http://mynamepsace">
>
> …
>
> However when I try to send messages to this service via any tool such as
> soapUI or any given client where I can send in raw XML that looks like:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:mes="http://mynamespace.com">
> <soapenv:Header/>
> <soapenv:Body>
> <mes:LoginRequest>
> <mes:LoginObjectPayload>
> ...
> </mes:LoginObjectPayload>
> </LoginRequest>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I get an unmarshalling error from CXF. If I remove the qualified namespace
> from ONLY the LoginRequest element it seems to work fine. This seems like
> an anomaly to me, can someone tell me why this would occur and what I may
> be doing wrong?
>
> Thanks!
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: JAXB qualified namespace not working
Posted by Mike Key <mi...@zenbitz.com>.
Sorry that is a typo. The issue is that if I add the mes namespace to the
LoginRequest I get an unmarshalling error stating it is not expecting child
elements. However if I remove the mes namespace from LoginRequest it works
fine (as long as I do not remove the mes namespace from the child
elements).
So in short it would seem that even though both are in the same namespace,
the service does not seem to think that LoginRequest needs to be in a
qualified namespace.
On Sun, Feb 26, 2012 at 7:50 PM, Glen Mazza <gm...@talend.com> wrote:
> On 02/26/2012 09:44 PM, Mike Key wrote:
>
>> …
>>
>> However when I try to send messages to this service via any tool such as
>> soapUI or any given client where I can send in raw XML that looks like:
>>
>> <soapenv:Envelope xmlns:soapenv="http://schemas.**
>> xmlsoap.org/soap/envelope/ <http://schemas.xmlsoap.org/soap/envelope/>"
>> xmlns:mes="http://mynamespace.**com <http://mynamespace.com>">
>> <soapenv:Header/>
>> <soapenv:Body>
>> <mes:LoginRequest>
>> <mes:LoginObjectPayload>
>> ...
>> </mes:LoginObjectPayload>
>> </LoginRequest>
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>> I get an unmarshalling error from CXF. If I remove the qualified
>> namespace
>> from ONLY the LoginRequest element it seems to work fine. This seems like
>> an anomaly to me, can someone tell me why this would occur and what I may
>> be doing wrong?
>>
>>
> Your closing tag for LoginRequest is missing the mes: prefix, I suspect
> that is the problem. AFAIK either both or neither elements need to have it.
>
> Glen
>
> --
> Glen Mazza
> Talend Community Coders - coders.talend.com
> blog: www.jroller.com/gmazza
>
>
Re: JAXB qualified namespace not working
Posted by Glen Mazza <gm...@talend.com>.
On 02/26/2012 09:44 PM, Mike Key wrote:
> …
>
> However when I try to send messages to this service via any tool such as
> soapUI or any given client where I can send in raw XML that looks like:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:mes="http://mynamespace.com">
> <soapenv:Header/>
> <soapenv:Body>
> <mes:LoginRequest>
> <mes:LoginObjectPayload>
> ...
> </mes:LoginObjectPayload>
> </LoginRequest>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I get an unmarshalling error from CXF. If I remove the qualified namespace
> from ONLY the LoginRequest element it seems to work fine. This seems like
> an anomaly to me, can someone tell me why this would occur and what I may
> be doing wrong?
>
Your closing tag for LoginRequest is missing the mes: prefix, I suspect
that is the problem. AFAIK either both or neither elements need to have it.
Glen
--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza