[英]Connecting to a WSE 3.0 Web Service From a WCF Client
I'm having difficulty connecting to a 3rd party WSE 3.0 web service from a WCF client. 我很难从WCF客户端连接到第三方WSE 3.0 Web服务。 I have implemented the custom binding class as indicated in this KB article: 我已经实现了这个知识库文章中指出的自定义绑定类:
http://msdn.microsoft.com/en-us/library/ms734745.aspx http://msdn.microsoft.com/en-us/library/ms734745.aspx
The problem seems to have to do with the security assertion used by the web service - UsernameOverTransport. 该问题似乎与Web服务使用的安全断言有关 - UsernameOverTransport。
When I attempt to call a method, I get the following exception: 当我尝试调用方法时,我得到以下异常:
System.InvalidOperationException: The 'WseHttpBinding'.'[namespace]' binding for the 'MyWebServiceSoap'.'[namespace]' contract is configured with an authentication mode that requires transport level integrity and confidentiality. System.InvalidOperationException:'WseHttpBinding'。'[namespace]'绑定'MyWebServiceSoap'。'[namespace]'契约配置了一种需要传输级别完整性和机密性的身份验证模式。 However the transport cannot provide integrity and confidentiality.. 但运输不能提供完整性和保密性。
It is expecting a username, password, and CN number. 它需要用户名,密码和CN号。 In the example code supplied to us by the vendor, these credentials are bundled in a Microsoft.Web.Services3.Security.Tokens.UsernameToken. 在供应商提供给我们的示例代码中,这些凭据捆绑在Microsoft.Web.Services3.Security.Tokens.UsernameToken中。 Here's the example supplied by the vendor: 以下是供应商提供的示例:
MyWebServiceWse proxy = new MyWebServiceWse();
UsernameToken token = new UsernameToken("Username", "password", PasswordOption.SendPlainText);
token.Id = "<supplied CN Number>";
proxy.SetClientCredential(token);
proxy.SetPolicy(new Policy(new UsernameOverTransportAssertion(), new RequireActionHeaderAssertion()));
MyObject mo = proxy.MyMethod();
This works fine from a 2.0 app w/ WSE 3.0 installed. 这适用于安装了WSE 3.0的2.0应用程序。 Here is a snippet of the code from my WCF client: 以下是我的WCF客户端的代码片段:
EndpointAddress address = new EndpointAddress(new Uri("<web service uri here>"));
WseHttpBinding binding = new WseHttpBinding(); // This is the custom binding I created per the MS KB article
binding.SecurityAssertion = WseSecurityAssertion.UsernameOverTransport;
binding.EstablishSecurityContext = false;
// Not sure about the value of either of these next two
binding.RequireDerivedKeys = true;
binding.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
MembershipServiceSoapClient proxy = new MembershipServiceSoapClient(binding, address);
// This is where I believe the problem lies – I can’t seem to properly setup the security credentials the web service is expecting
proxy.ClientCredentials.UserName.UserName = "username";
proxy.ClientCredentials.UserName.Password = "pwd";
// How do I supply the CN number?
MyObject mo = proxy.MyMethod(); // this throws the exception
I've scoured the web looking for an answer to this question. 我在网上搜索这个问题的答案。 Some sources get me close (like the MS KB article), but I can't seem to get over the hump. 一些消息来源让我接近(如MS KB文章),但我似乎无法克服困难。 Can someone help me out? 有人可以帮我吗?
I had success in a similar case with the following binding configuration: 我在以下绑定配置的类似情况下取得了成功:
<bindings>
<customBinding>
<binding name="FNCEWS40MTOMBinding">
<security enableUnsecuredResponse="true" authenticationMode="UserNameOverTransport"
allowInsecureTransport="true" messageProtectionOrder="SignBeforeEncrypt">
<secureConversationBootstrap />
</security>
<mtomMessageEncoding messageVersion="Soap12WSAddressingAugust2004"
maxBufferSize="2147483647" />
<httpTransport maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
Hope it works for you too. 希望它也适合你。
The error message is refering to Transport Level Security, this usually means https. 错误消息是指传输级别安全性,这通常表示https。
You have not shown your configuration files. 您尚未显示配置文件。 But I am guessing that you have configured security to be transport (or it is required as a consiquence of another choice) and used an address that is http instead of https. 但我猜你已经将安全配置为传输(或者需要作为另一种选择的后果)并使用了http而不是https的地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.