Wcf 需要一个;具有WSSE身份验证的SOAP客户端“。。。VisualStudio是否适合这种需要?

Wcf 需要一个;具有WSSE身份验证的SOAP客户端“。。。VisualStudio是否适合这种需要?,wcf,web-services,visual-studio-2008,authentication,Wcf,Web Services,Visual Studio 2008,Authentication,我需要连接的Web服务具有上述要求。我可以在VS2008中使用此web服务,但无法使用它,因为我不知道如何进行身份验证。我需要指定credentails,但是没有公开“header”方法。我尝试过以下方法: UltraDNSWebReference.UltraWebServiceService clientProxy = new UltraDNSWebReference.UltraWebServiceService(); clientProxy.Credentials = new S

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

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

clientProxy.Credentials = new System.Net.NetworkCredential(
    "MyUserName", "MYPassword");
//Create client object  
  ServiceReference1.UltraDNSClient client = new ServiceReference1.UltraDNSClient();
  client.ClientCredentials.UserName.UserName = "myUserName";
  client.ClientCredentials.UserName.Password = "myPassword";
但我仍然得到一个身份验证错误。我可以使用SOAPUI测试平台成功连接,因此我知道这不是错误的凭据或阻止的IP

此WebService API声明:

Neustar Ultra服务API 对用户进行身份验证,并使用 SOAP中的WSSE用户名令牌 标题

我可以在Visual Studio中使用此Web服务吗

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

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

clientProxy.Credentials = new System.Net.NetworkCredential(
    "MyUserName", "MYPassword");
//Create client object  
  ServiceReference1.UltraDNSClient client = new ServiceReference1.UltraDNSClient();
  client.ClientCredentials.UserName.UserName = "myUserName";
  client.ClientCredentials.UserName.Password = "myPassword";
因此,上面我有我的客户机对象,这个对象可以访问API中的所有方法。但是,我不能使用任何方法,因为我没有正确地进行身份验证。API不提供任何类型的“header()”类型方法。例如,对于我使用的另一个Web服务(是的,这使用了添加Web引用,但概念保持不变):

上面我使用了header()方法来指定我的凭据。如果WSDL不提供头方法,而只是声明必须在SOAP头中提供凭据,那么如何在Visual Studio中实现这一点

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>


如果它们的意思是“WS-Security”,则是。尝试使用“添加服务引用”。John,谢谢。我感谢VS确认支持他们的服务。然而,我仍然不清楚如何认证,并将感谢您的帮助。如何使用VisualStudio获取“SOAP头中的WSSE用户名令牌”?我告诉过你了。使用“添加服务引用”。你试过了吗?你现在可以编辑你的问题了。用四个空格缩进代码。我收到了UltraDNS支持部门的以下回复:“感谢您联系UltraDNS(www.UltraDNS.com)。所有UltraDNS客户都必须通过提供所有需要访问的IP地址请求访问SOAP API的权限。”