Morten Nyhaug [
https://community.jboss.org/people/morten.nyhaug] created the discussion
"JAX-WS fails to unmarshal payload due to strict namespaces"
To view the discussion, visit:
https://community.jboss.org/message/776631#776631
--------------------------------------------------------------
I have a web service that receives the following payload
{code:xml}
<soap-env:Envelope xmlns:soap-env="
http://schemas.xmlsoap.org/soap/envelope/
http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<mm7:DeliverReq xmlns:mm7="
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
<MM7Version>5.3.0</MM7Version>
</mm7:DeliverReq>
</soap-env:Body>
</soap-env:Envelope>
{code}
I have generated classes for the schema using xjc, and created a webservice with an
endpoint interface to receive it
{code}
@WebService(name = "deliver")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
org._3gpp.ftp.specs.archive._23_series._23_140.schema.rel_5_mm7_1_0.ObjectFactory.class
})
public interface Rel5Mm710ReceiverApi {
@WebMethod(action = "deliverRequest")
@WebResult(name = "DeliverRsp", targetNamespace = "
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...)
public DeliverRspType deliverRequest(
@WebParam(name = "DeliverReq", targetNamespace = "
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...)
DeliverReqType request);
}
{code}
{code}
@WebService(serviceName = "soap")
@HandlerChain(file = "handler.xml")
public class InboundApi implements Rel5Mm710ReceiverApi {
@Override
@WebMethod
public DeliverRspType deliverRequest(DeliverReqType request) {
...
}
}
{code}
When I deploy this service on jboss as 7.1 and test it with soap ui by sending in the
payload shown above, I get the following error:
{noformat}
10:52:56,107 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http--127.0.0.1-8080-1)
Interceptor for {
http://mms.tele2.returia.nrk.no/ http://mms.tele2.returia.nrk.no/}soap#{
http://api.mm7.returia.nrk.no/ http://api.mm7.returia.nrk.no/}deliverRequest has thrown
exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error:
unexpected element (uri:"", local:"MM7Version"). Expected elements are
<{
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:801)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:642)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
at
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:201)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
...
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"",
local:"MM7Version"). Expected elements are <{
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...>]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:434)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:371)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:348)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:778)
... 31 more
{noformat}
The funny thing is, if I try to unmarshal this using JAXB, I get no errors at all. If I
try to modify the payload so that it is like this:
{code:xml}
<mm7:DeliverReq xmlns:mm7="
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0
http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1...
<mm7:MM7Version>5.3.0</mm7:MM7Version>
</mm7:DeliverReq>
{code}
I also get no errors. Obviously changing the payload is not an option since I cant control
what 3rd parties are sending me.
How can I get rid of this error? How can I tell JAX-WS to not be so strict regarding
namespaces?
I have tried using a SOAPHandler to set some properties or other, but no amount of
googeling has led me to the correct solution. Since JAXB is able to unmarshal this, then
surly it must be possible to make JAX-WS do this as well?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/776631#776631]
Start a new discussion in JBoss Web Services Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]