<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
JAX-WS fails to unmarshal payload due to strict namespaces
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/morten.nyhaug">Morten Nyhaug</a> in <i>JBoss Web Services Development</i> - <a href="https://community.jboss.org/message/776631#776631">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I have a web service that receives the following payload</p><p>{code:xml}</p><p><span><soap-env:Envelope xmlns:soap-env="</span><a class="jive-link-external-small" href="http://schemas.xmlsoap.org/soap/envelope/" target="_blank">http://schemas.xmlsoap.org/soap/envelope/</a><span>"></span></p><p>    <soap-env:Header/></p><p>    <soap-env:Body></p><p><span>        <mm7:DeliverReq xmlns:mm7="</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>"></span></p><p>            <MM7Version>5.3.0</MM7Version></p><p>        </mm7:DeliverReq></p><p>    </soap-env:Body></p><p></soap-env:Envelope></p><p>{code}</p><p>I have generated classes for the schema using xjc, and created a webservice with an endpoint interface to receive it</p><p>{code}</p><p>@WebService(name = "deliver")</p><p>@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)</p><p>@XmlSeeAlso({</p><p>    org._3gpp.ftp.specs.archive._23_series._23_140.schema.rel_5_mm7_1_0.ObjectFactory.class</p><p>})</p><p>public interface Rel5Mm710ReceiverApi {</p><p>    @WebMethod(action = "deliverRequest")</p><p><span>    @WebResult(name = "DeliverRsp", targetNamespace = "</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>")</span></p><p>    public DeliverRspType deliverRequest(</p><p><span>            @WebParam(name = "DeliverReq", targetNamespace = "</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>")</span></p><p>            DeliverReqType request);</p><p>}</p><p>{code}</p><p>{code}</p><p>@WebService(serviceName = "soap")</p><p>@HandlerChain(file = "handler.xml")</p><p>public class InboundApi implements Rel5Mm710ReceiverApi {</p><p>    @Override</p><p>    @WebMethod</p><p>    public DeliverRspType deliverRequest(DeliverReqType request) {</p><p>        ...</p><p>    }</p><p>}</p><p>{code}</p><p>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:</p><p>{noformat}</p><p><span>10:52:56,107 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http--127.0.0.1-8080-1) Interceptor for {</span><a class="jive-link-external-small" href="http://mms.tele2.returia.nrk.no/" target="_blank">http://mms.tele2.returia.nrk.no/</a><span>}soap#{</span><a class="jive-link-external-small" href="http://api.mm7.returia.nrk.no/" target="_blank">http://api.mm7.returia.nrk.no/</a><span>}deliverRequest has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"MM7Version"). Expected elements are <{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}MMSRelayServerID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Content>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}ReplyChargingID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Priority>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Recipients>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}TimeStamp>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Sender>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}MM7Version>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}LinkedID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Subject> </span></p><p>    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:801)</p><p>    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:642)</p><p>    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)</p><p>    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:201)</p><p>    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)</p><p>    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)</p><p>    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)</p><p>    ...</p><p>Caused by: javax.xml.bind.UnmarshalException</p><p> - with linked exception:</p><p><span>[javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"MM7Version"). Expected elements are <{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}MMSRelayServerID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Content>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}ReplyChargingID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Priority>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Recipients>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}TimeStamp>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Sender>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}MM7Version>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}LinkedID>,<{</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>}Subject>]</span></p><p>    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:434)</p><p>    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:371)</p><p>    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:348)</p><p>    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:778)</p><p>    ... 31 more</p><p>{noformat}</p><p>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:</p><p>{code:xml}</p><p><span><mm7:DeliverReq xmlns:mm7="</span><a class="jive-link-external-small" href="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" target="_blank">http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0</a><span>"></span></p><p>    <mm7:MM7Version>5.3.0</mm7:MM7Version></p><p></mm7:DeliverReq></p><p>{code}</p><p>I also get no errors. Obviously changing the payload is not an option since I cant control what 3rd parties are sending me.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>How can I get rid of this error? How can I tell JAX-WS to not be so strict regarding namespaces?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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?</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/776631#776631">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2047">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>