[英]Setting Up NetTcpBinding
設置 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>
項目設置已正確指定。 我重新啟動了 IIS,重新啟動了服務,它工作正常。 非常感謝你的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.