[英]WCF service, two-way communication - message security none
我已经为客户端创建了WCF服务以与ASP.NET应用程序进行通信。 该服务是在客户端上创建的,ASP.NET应用程序可以调用该服务。 目前,我在交流时没有使用任何安全性。
到目前为止,服务已创建并正在运行。 ASP.NET应用程序已经为其创建了ServiceReference,但是当尝试调用方法时,出现以下错误消息(调试时):
由于EndpointDispatcher上的ContractFilter不匹配,因此无法在接收方处理带有操作' http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue '的消息。 这可能是由于合同不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配造成的。 检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如,消息,传输,无)。
很简单,app.config出现问题。 我似乎无法找出问题所在,因为我已将app.config从WCF主机复制到ASP。 应用。
客户端(WCF主机)的App.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_Interface" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="infinite" enabled="false" />
<security mode="None">
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/WCF/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Interface" contract="WCFProject.IInterface" name="WSHttpBinding_Interface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="WCFProject.Interface" behaviorConfiguration="WCFProject.InterfaceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="WCFProject.IInterface" bindingConfiguration="WSHttpBinding_Interface" name="WCFProject.Interface.EndpointConfiguration">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFProject.InterfaceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
ASP应用程序的App.config(ServiceReference命名为InterfaceService):
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_Interface" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="infinite" enabled="false" />
<security mode="None">
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/WCF/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Interface" contract="InterfaceService.IInterface" name="WSHttpBinding_Interface">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
WCF服务在ASP应用程序中按以下方式启动,其中WCFUrl是WCF服务的URL:
//Create object of the Binding
System.ServiceModel.Channels.Binding binding = new System.ServiceModel.WSHttpBinding();
//Create endpointAddress of the Service
System.ServiceModel.EndpointAddress endpointAddress = new
System.ServiceModel.EndpointAddress(WCFUrl + "?wsdl");
//Create Client of the Service
InterfaceService.InterfaceClient cc = new InterfaceService.InterfaceClient(binding, endpointAddress);
//Call Service method using ServiceClient
string ss = cc.Ping();
向我指出正确方向的任何帮助均适用。 我已经坚持了几天。 谢谢。
更新:我还在两边都添加了以下内容:
<security mode="None">
<transport clientCredentialType="None"/>
<message establishSecurityContext="false"/>
</security>
这没有任何运气。
我认为您需要在客户端配置中配置绑定安全性的所有属性,以匹配服务器发送的内容。
<security>
<transport/>
<message/>
</security>
我的问题是我缺少端点下面的端点地址( http://local.host:8732/WCF/ )。 不好意思
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.