如何解决WCF Restful Service .NET 4 IIS 7.5问题无法处理带有“\'\'的消息”
| 我有一个wcf restful服务并正在运行。如果使用WebServiceHost启动Web服务,则可以毫无问题地发出Get / Post。我尝试将wcf服务移至本地机器上的IIS 7.5,但似乎无法正常进行。 我尝试从wcf服务调用任何内容时都收到以下错误消息:(http:// wp9dbytr1k1:8081 / service.svc / AnythingHereForGETorPUT)。我在虚拟目录/设备中尝试过,但遇到了同样的问题。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).
如果我直接调用svc文件(http:// wp9dbytr1k1:8081 / service.svc),它会很高兴并告诉我
\“您已经创建了一项服务。
要测试此服务,您将需要创建一个客户端并使用它来调用该服务。您可以使用以下语法从命令行使用svcutil.exe工具执行此操作:
svcutil.exe http:// wp9dbytr1k1:8081 / FUU / service.svc?wsdl \“
跟踪查看器中的跟踪跟踪没有帮助:抱歉,必须添加链接,但尚不能发布图像。 (ImageLink)
这是我的web.config
<system.serviceModel>
<bindings>
<mexHttpsBinding>
<binding name=\"NewBinding0\" />
</mexHttpsBinding>
<webHttpBinding>
<binding name=\"WebBinding\">
<readerQuotas maxDepth=\"524288\" maxStringContentLength=\"524288\"
maxArrayLength=\"524288\" maxBytesPerRead=\"524288\" maxNameTableCharCount=\"524288\" />
<security mode=\"None\">
<transport clientCredentialType=\"None\" proxyCredentialType=\"None\" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration=\"StoredProcBehaviors\" name=\"StoredProcService.DataRetreivalService\">
<endpoint address=\"\" binding=\"webHttpBinding\" bindingConfiguration=\"WebBinding\"
contract=\"StoredProcService.IDataRetreivalService\">
<identity>
<dns value=\"locahost\" />
</identity>
</endpoint>
<endpoint address=\"mex\" binding=\"mexHttpBinding\" bindingConfiguration=\"\"
contract=\"StoredProcService.IDataRetreivalService\" />
<host>
<baseAddresses>
<add baseAddress=\"http://WP9DBYTR1K1:8081/\" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=\"StoredProcBehaviors\">
<serviceMetadata httpGetEnabled=\"true\"/>
<serviceDebug includeExceptionDetailInFaults=\"true\" />
</behavior>
</serviceBehaviors>
</behaviors>
出于明显的原因,由于它与WebServiceHost一起使用,因此感觉像IIS设置。我已经搜索了有关如何进行设置的错误/教程,对我来说一切似乎都很好。
有什么建议么?
谢谢
解决方法
要在WCF中创建REST端点,除了使用WebHttpBinding之外,还需要具有端点行为。
<system.serviceModel>
<services>
<service behaviorConfiguration=\"StoredProcBehaviors\" name=\"StoredProcService.DataRetreivalService\">
<endpoint address=\"\" binding=\"webHttpBinding\" bindingConfiguration=\"WebBinding\" behaviorConfiguration=\"REST\"
contract=\"StoredProcService.IDataRetreivalService\">
<identity>
<dns value=\"locahost\" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name=\"REST\">
<webHttp/>
</behavior>
<endpointBehaviors>
</behaviors>
</system.serviceModel>
另一种选择是在.svc文件中使用WebServiceHostFactory,其工作方式类似于WebServiceHost。在这种情况下,您甚至不需要web.config中的system.serviceModel部分。
<% @ServiceHost Service=\"StoredProcService.DataRetreivalService\" Factory=\"System.ServiceModel.Activation.WebServiceHostFactory\" Language=\"C#\" debug=\"true\" %>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。