ngType属性添加到UsernameToken的Nonce元素

ngType属性添加到UsernameToken的Nonce元素

本文介绍了如何在WSE 3.0(.NET)中将EncodingType属性添加到UsernameToken的Nonce元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WSE 3.0从MVC3 .NET Web应用程序调用Java Web服务.

I'm trying to call a Java Web Service from an MVC3 .NET web app using WSE 3.0.

但是,Web服务需要在UsernameToken的Nonce元素上具有"EncodingType"属性.以下是一个示例SOAP信封,它可以与此Java Web服务一起正常工作:

However, the web service requires an "EncodingType" attribute on the Nonce element of the UsernameToken. Following is a sample SOAP envelope that works correctly with this Java web service:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://schema.mydomain.org/sms/v1_0">
   <soap:Header>
     <wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
       <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsse:Username>myUsername</wsse:Username>
         <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
         <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">XQkp6oYc3DRv41cxkSTW8w==</wsse:Nonce>
         <wsu:Created>2011-09-13T20:50:08.355Z</wsu:Created>
       </wsse:UsernameToken>
    </wsse:Security>
  </soap:Header>
   <soap:Body>
      <v1:ping/>
   </soap:Body>
</soap:Envelope>

以下是从VS2010生成的代理生成的SOAP信封(捕获在Fiddler中):

Following is the SOAP envelope generated from the proxy that VS2010 produced (captured in Fiddler):

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 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">
  <env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope">
    <wsse:Security env:mustUnderstand="true">
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-111f922b-72c1-4057-bce4-f6555552ce6a">
        <wsse:Username>myUsername</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
        <wsse:Nonce>qYse3Lor9sAJ9pKPefgkKQ==</wsse:Nonce>
        <wsu:Created>2011-09-13T20:50:38Z</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>
  </env:Header>
  <soap:Body>
      <v1:ping/>
  </soap:Body>
</soap:Envelope>

如果缺少此属性,则此Web服务将返回提供了无效的安全令牌(处理用户名令牌时发生错误)"

If this attribute is missing, this web service returns, "An invalid security token was provided (An error happened processing a Username Token)"

如何添加EncodingType属性?

How do I add an EncodingType attribute?

推荐答案

我找到了可接受的解决方案...

I found an acceptable solution...

EncodingType标志根据WSSE用户名和令牌安全规范1.1,这是此Java Web Service使用的Apache CXF框架版本所要求的规范. .NET不符合该规范.幸运的是,CXF中有一个标志可以关闭需求.我们做到了,现在可以交流了.

The EncodingType flag is according to the WSSE Username and Token Security Spec 1.1, which is the spec required by the version of the Apache CXF framework that this Java Web Service is using. .NET does not meet that spec. Luckily there was a flag in CXF to turn off the requirement. We did that and are now able to communicate.

这篇关于如何在WSE 3.0(.NET)中将EncodingType属性添加到UsernameToken的Nonce元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 17:04