我得到了以下错误..有什么问题?
由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action '' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
WSModules.svc
<%@ ServiceHost language="C#" Service="WS.Modules.ServiceContracts.WSModules"%>
WS模块
namespace WS.Modules.ServiceContracts { [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] public class WSModules : IWSModules { public string XmlData(string id) { return "You requested product" + id; } } }
IWS 模块
namespace WS.Interfaces.ServiceContracts { [ServiceContract] public interface IWSModules { [OperationContract] [WebGet(UriTemplate = "XmlData?id={id}")] string XmlData(string id); } }
网页配置
<system.serviceModel> <behaviors> <serviceBehaviors> <!-- ### WSModules --> <behavior name="WSModulesBehavior"> <serviceMetadata httpGetEnabled="True" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceThrottling maxConcurrentCalls="24" maxConcurrentSessions="24" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="web"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <services> <!-- ### WSModules Service--> <service behaviorConfiguration="WSModulesBehavior" name="WS.Modules.ServiceContracts.WSModules"> <endpoint address="" binding="webHttpBinding" contract="WS.Interfaces.ServiceContracts.IWSModules"/> <host> <baseAddresses> <add baseAddress="http://xxx.xxx.xxx/commonwebsol/wswsdl" /> </baseAddresses> </host> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="True"/> </system.serviceModel>
我打开浏览器并输入 http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc - 工作正常。我得到了“svcutil.exe http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc?wsdl 然后如果我点击” http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc? wsdl " 我得到了 xml
但是,如果我在浏览器中输入 http://xxx.xxx.xxx/commonwebsol/WSWSDL/WSModules.svc?XmlData?id=123 我收到以下错误...
<Text xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</Text>