CXF SOAP JAX-WS WSS4JInInterceptor change namespace and cause Unmarshalling error

↘锁芯ラ 提交于 2019-12-12 04:50:34

问题


I'm using WSS4JInInterceptor in my endpoint to validate the authorization.

I have that in my endpoint

Here it's my SOAP message

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
          <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                 <wsse:UsernameToken wsu:Id="UsernameToken-1">
                       <wsse:Username>username</wsse:Username>
                       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"/>
                 </wsse:UsernameToken>
          </wsse:Security>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
          <newAsset xmlns="http://api.com.acme/">
                 <date xmlns="">2018-02-04T14:35:59Z</date>
                 <assetId xmlns="">1</assetId>
          </newAsset>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I trace the message into WSS4JInInterceptor and find out that the SOAP Message received was rewrited to : (the blank namespace where replaced)

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
          <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                 <wsse:UsernameToken wsu:Id="UsernameToken-1">
                       <wsse:Username>username</wsse:Username>
                       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"/>
                 </wsse:UsernameToken>
          </wsse:Security>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
          <newAsset xmlns="http://api.com.acme/">
                 <date xmlns="http://api.com.acme/">2018-02-04T14:35:59Z</date>
                 <assetId xmlns="http://api.com.acme/">1</assetId>
          </newAsset>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and that cause an unmarshalling error.

BUT

if I do a little change(Add a prefix) into my SOAP message to send this instead, WSS4JInInterceptor won't change the default namespace and the message will be accepted.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
          <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                 <wsse:UsernameToken wsu:Id="UsernameToken-1">
                       <wsse:Username>username</wsse:Username>
                       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"/>
                 </wsse:UsernameToken>
          </wsse:Security>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
          <api:newAsset xmlns:api="http://api.com.acme/">
                 <date xmlns="">2018-02-04T14:35:59Z</date>
                 <assetId xmlns="">1</assetId>
          </api:newAsset>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

there is a way to avoid that ? The first message was valid, so it should be accepted. Do I have to put something in my xsd ? I used unqualified. I'm using CXF 3.0.0


回答1:


Update to CXF 3.0.3 and see if it still fails. I think there were some issues around this that were recently fixed. If it still fails, please log a bug with a testcase.



来源:https://stackoverflow.com/questions/27469863/cxf-soap-jax-ws-wss4jininterceptor-change-namespace-and-cause-unmarshalling-erro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!