繁体   English   中英

需要“具有WSSE身份验证的SOAP客户端”...... Visual Studio是否符合此需求?

[英]Need a “SOAP Client with WSSE authentication” … does Visual Studio fit this need?

我需要连接的Web服务具有上述要求。 我可以在VS 2008中使用此Web服务但不能使用它,因为我不知道如何进行身份验证。 我需要指定credentails,但是没有公开“header”方法。 我尝试过以下内容:

UltraDNSWebReference.UltraWebServiceService clientProxy = 
    new UltraDNSWebReference.UltraWebServiceService();

clientProxy.Credentials = new System.Net.NetworkCredential(
    "MyUserName", "MYPassword");

但我仍然收到身份验证错误。 我可以使用SOAPUI测试平台成功连接,因此我知道它不是不正确的凭据或阻止的IP。

此WebService API指出:

Neustar Ultra Services API使用SOAP标头中的WSSE UserName标记对用户和请求进行身份验证。

我是否可以在Visual Studio中使用此Web服务???

我尝试过添加服务参考。 我可以成功使用WSDL并创建一个对象,但不知道如何提供身份验证。 例如,我尝试过以下方法:

//Create client object  
  ServiceReference1.UltraDNSClient client = new ServiceReference1.UltraDNSClient();
  client.ClientCredentials.UserName.UserName = "myUserName";
  client.ClientCredentials.UserName.Password = "myPassword";

所以,上面我有我的客户端对象,这个对象可以访问API中的所有方法。 但是,我不能使用任何方法,因为我没有正确验证。 API不提供任何类型的“header()”类型方法。 例如,对于我使用的另一个Web服务(是的,这使用了Add Web Reference,但概念保持不变):

//Use the Web Reference to create the header object
StockLogoWebService.Header headerObject = new StockLogoWebService.Header();

//Assign the username (Username is all Xignite requires for authentication)
headerObject.Username = "janedoe@yahoo.com";

//Assign this header to the proxy object
xLogogsTest.HeaderValue = headerObject;

//Use any exposed methods
xLogosTest.anyMethod()

上面我使用了header()方法来指定我的凭据。 如果WSDL没有提供头方法,并且只是声明必须在SOAP头中提供凭据,那么在Visual Studio中如何实现呢?

WSDL可以在以下位置找到:

http://ultra-api.ultradns.com:8008/UltraDNS_WS?wsdl

您可以在Web / app配置中将WSSE安全标头添加到服务端点:

 <system.serviceModel>
    <bindings>
        <customBinding>
          <! -- your binding details -->
        </customBinding>
    </bindings>
    <client>
      <endpoint <your endpoint details>>
        <headers>
          <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">
              <wsse:Username></wsse:Username>
              <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
            </wsse:UsernameToken>
          </wsse:Security>
        </headers>
      </endpoint>
    </client>
</system.serviceModel>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM