CXF SOAP JAX-WS WSS4JInInterceptor更改名称空间并导致Unmarshalling错误

时间:2014-12-14 13:35:56

标签: soap cxf unmarshalling saaj

我在我的端点中使用WSS4JInInterceptor来验证授权。

我在我的端点中有这个                                                                                                                                                                  

这是我的SOAP消息

<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>

我将消息跟踪到WSS4JInInterceptor中,并发现收到的SOAP消息被重写为:(替换的空白命名空间)

<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>

并导致解组错误。

BUT

如果我对我的SOAP消息进行一些更改(添加前缀)来发送它,WSS4JInInterceptor不会更改默认命名空间,并且将接受该消息。

<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>

有办法避免这种情况吗?第一条消息是有效的,因此应该被接受。我必须在我的xsd中放一些东西吗?我使用不合格。我使用的是CXF 3.0.0

1 个答案:

答案 0 :(得分:0)

更新到CXF 3.0.3并查看它是否仍然失败。我认为最近修复了一些与此相关的问题。如果仍然失败,请使用测试用例记录错误。