也许有人可以帮助我。
我在 IIS 上托管 WCF 服务。.svc 文件可从浏览器访问。它在本地工作,但是当我在服务器上发布并且我想从我的客户端调用一个方法时,我总是从服务器得到一个 HTTP 状态 500。
这是我的 web.config 文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!-- Allow receiving of large files, maxRequestLength is in kB -->
<httpRuntime maxRequestLength="2097151" executionTimeout="300" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="WebServices.MVSWebServicesBehavior"
name="WebServices.MVSWebServices">
<endpoint address="" binding="basicHttpBinding" contract="WebServices.MVSWebServices_I" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://<ipaddr>/WebServices/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WebServices.MVSWebServicesBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
日志文件只显示我
2013-06-17 13:55:44 <ipaddr> POST /WebServices/MVSWebServices.svc - 80 - <ipaddr> ksoap2-android/2.6.0+ 500 0 0 2121
所以我在服务器上尝试了失败的请求跟踪,我得到了(如果需要,我可以提供完整的跟踪):
MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName IsapiModule
Notification 128
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0
ErrorCode 0
ConfigExceptionInfo
Notification EXECUTE_REQUEST_HANDLER
ErrorCode The operation completed successfully. (0x0)
四天我把头撞在墙上,任何帮助将不胜感激:)
PS:我正在使用带有 IIS 7.5 的 Windows Server 2008 R2
编辑1:
启用 WCF 跟踪后,会出现错误消息:
The message with Action 'http://tempuri.org/MVSWebService_I/getTimestamp' 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).
合同不匹配让我想验证 WSDL 文件中的 SOAP 操作:
http://tempuri.org/MVSWebServices_I/getTimestamp
然后在我的客户端(Android 应用程序)中:
http://tempuri.org/MVSWebService_I/getTimestamp
只是为了在我的行动中发现一个缺失的 s !我将丢失的字母添加到 SOAP 操作中,并且一切正常。就是这样,这封丢失的信花了我 4 天的时间,但我仍然喜欢编程 :D
谢谢您的帮助。