Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从WCF客户端连接到WSE 3.0 Web服务_Wcf_Web Services_Wse - Fatal编程技术网

从WCF客户端连接到WSE 3.0 Web服务

从WCF客户端连接到WSE 3.0 Web服务,wcf,web-services,wse,Wcf,Web Services,Wse,我无法从WCF客户端连接到第三方WSE 3.0 web服务。我已经实现了定制绑定类,如本文所示: 问题似乎与web服务-UsernameOverTransport使用的安全断言有关 当我尝试调用一个方法时,会出现以下异常: System.InvalidOperationException:异常 “WseHttpBinding”“。[命名空间]” 对客户具有约束力 “MyWebServiceSoap”。“[命名空间]” 合同配置了一个 需要验证的身份验证模式 传输级完整性和 保密性。然而,运输

我无法从WCF客户端连接到第三方WSE 3.0 web服务。我已经实现了定制绑定类,如本文所示:

问题似乎与web服务-UsernameOverTransport使用的安全断言有关

当我尝试调用一个方法时,会出现以下异常:

System.InvalidOperationException:异常 “WseHttpBinding”“。[命名空间]” 对客户具有约束力 “MyWebServiceSoap”。“[命名空间]” 合同配置了一个 需要验证的身份验证模式 传输级完整性和 保密性。然而,运输 无法提供完整性和 保密性

它需要用户名、密码和CN号码。在供应商提供给我们的示例代码中,这些凭据捆绑在Microsoft.Web.Services3.Security.Tokens.UsernameToken中。以下是供应商提供的示例:

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();
MyWebServiceWse proxy=newmywebservicewse();
UsernameToken token=新的UsernameToken(“用户名”、“密码”、PasswordOption.SendPlainText);
token.Id=“”;
proxy.SetClientCredential(令牌);
SetPolicy(新策略(新用户名OverTransportAssertion(),新RequireReactionHeaderAssertion());
MyObject mo=proxy.MyMethod();

这在安装了WSE 3.0的2.0应用程序中运行良好。以下是我的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
EndpointAddress address=新的EndpointAddress(新Uri(“”);
WseHttpBinding binding=新的WseHttpBinding();//这是我根据MSKB文章创建的自定义绑定
binding.SecurityAssertion=wsesesecurityassertion.UsernameOverTransport;
binding.EstablishSecurityContext=false;
//不确定下两个的值
binding.requiredrivedKeys=true;
binding.MessageProtectionOrder=MessageProtectionOrder.SignBeforeEncrypt;
MembershipServiceSoapClient代理=新的MembershipServiceSoapClient(绑定,地址);
//这就是我认为问题所在的地方——我似乎无法正确设置web服务所期望的安全凭据
proxy.ClientCredentials.UserName.UserName=“UserName”;
proxy.ClientCredentials.UserName.Password=“pwd”;
//如何提供CN号码?
MyObject mo=proxy.MyMethod();//这会引发异常

我在网上搜寻这个问题的答案。有些来源让我接近了(比如微软KB的文章),但我似乎无法克服困难。有人能帮我吗?

错误消息指的是传输级别的安全性,这通常意味着https


您尚未显示配置文件。但我猜您已经将安全性配置为传输(或者作为另一种选择的一致性,它是必需的),并使用了http而不是https的地址。

我在类似情况下成功地使用了以下绑定配置:

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


希望它也能对您起作用。

嗨,设拉子,谢谢您的回复。我在上面提供的代码中以编程方式将SecurityAssertion定义为UserNameOverTransport。web服务不使用https,因此我不认为这是问题所在。我认为这就是为什么会出现错误的原因。当您通过传输发送用户名/密码时,WCF会发现密码将通过未加密的线路传输,并拒绝启动服务。这似乎是WSE3.0和WCF之间的主要区别。我可以使用不带SSL的WSE 3.0客户端连接到我的WSE3服务,但WCF客户端不会使用Dave在其示例中收到的相同消息进行连接。请确保,您的第三方是否知道WSE已过时?您是否能够解决此问题?有人有主意吗?我现在也在做同样的事情。