我得到了这个例外:
由于 EndpointDispatcher 的 ContractFilter 不匹配,无法在接收器处处理具有 Action ' http://tempuri.org/IUserService/HelloWorld ' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
Web.Config如下
服务器
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehaviour" name="API.UserService">
<endpoint
name ="basic"
address=""
binding="basicHttpBinding"
bindingConfiguration ="basicBinding"
contract="API.IUserService" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicBinding"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None"></security>
<readerQuotas maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
客户
<client>
<endpoint
name ="basic"
address="http://localhost:8080/UserService.svc"
binding="basicHttpBinding"
bindingConfiguration ="basicBinding"
contract="API.IUserService" />
</client>
</system.serviceModel>