设置NetTcpBinding。我试图从服务器获取数据时出错。用WCFTestClient法进行检测。
我是WCF的新手。我可能错过了IIS设置,或者在绑定中出错。请帮助我们理解这个问题。
The message with To
'net.tcp://wssekbdev-5-loc.wss.loc/_layouts/WSS/WSSC.V4.DMS.TestWCF.WcfService1/Service3.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at
System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessagereqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at
IServiceContract.Login(String username) at
ServiceContractClient.Login(String username)

代码服务器
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class ServiceTest : IServiceContract
{
public string Login(string username)
{
return $"ok:{username}";
}
public void Message(string message, string userFrom)
{
}
}
[ServiceContract()]
public interface IServiceContract
{
[OperationContract]
string Login(string username);
[OperationContract(IsOneWay = true)]
void Message(string message, string userFrom);
}配置
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
<system.web>
<httpRuntime />
<customErrors mode="RemoteOnly" />
<compilation targetFramework="4.5" />
<identity impersonate="false" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TestBinding" sendTimeout="00:01:00">
<reliableSession ordered="true" enabled="false" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="WSSC.V4.DMS.TestWCF.WcfService1.ServiceTest">
<endpoint binding="netTcpBinding" contract="WSSC.V4.DMS.TestWCF.WcfService1.IServiceContract"
bindingConfiguration="TestBinding"
/>
<endpoint binding="wsHttpBinding" contract="WSSC.V4.DMS.TestWCF.WcfService1.IServiceContract"/>
<endpoint address = "mex" binding = "mexTcpBinding" contract = "IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>


发布于 2020-08-24 05:44:15
如果您的服务在中运行,则无法配置netTcpBinding。原因是只支持HTTP。
您需要更改项目属性如下:

您还可以告诉我在调用服务时发生了什么错误,我可以帮助您解决它。
我根据您提供的信息创建了部署在IIS中的WCF项目,但没有发现任何错误。
确保以下服务正在运行:

如果问题仍然存在,请随时通知我。
发布于 2020-08-24 15:42:41
正确指定了项目设置。我重新启动了IIS,重新启动了服务,并且它成功了。非常感谢你的帮助。
https://stackoverflow.com/questions/63549980
复制相似问题