我已经创建了一个RESTful WCF服务(感谢StackOverflow)。我创建了一个测试客户端,它是一个简单的.aspx页面,包含5个文本框和一个提交按钮。当我将数据输入文本框并单击提交按钮时,它会将数据 提交给WCF服务。WCF服务引用不起作用?
我的WCF服务正在Visual Studio开发服务器下运行,它工作正常,我能够成功地发送数据到WCF服务。今天,我在本地IIS上部署了这个WCF服务。当我试图引用客户端应用程序(.aspx页面)中的服务URL时,出现此错误。
“元数据包含无法解析的客户端和 服务绑定可能不匹配的基准无法处理该消息,因为 内容类型‘应用/肥皂+ xml的;字符集= UTF-8’。未 预期类型'text/xml;'
任何想法可能是什么问题?这是我的web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="RESTService1">
<endpoint address="http://localhost:420/WCFRESTService100/RESTService1.svc" binding="webHttpBinding" name="MainHttpPoint" contract="RESTService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:420/WCFRESTService100/RESTService1.svc" />
</baseAddresses>
</host>
</service>
</services>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>-->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
嗨德鲁,我不明白你的答案。我是否添加了服务引用?我没有添加任何添加到它的元数据引用。如果我没有为REST服务添加SErvice引用。是否可以为我提供一个例子。感谢您的时间 – Henry
“添加服务引用”功能仅适用于公开仅描述SOAP端点的WSDL的服务。你不能在REST端点上使用它。所以,如果你这样做了,发生什么事是你的客户端添加了一个SOAP端点。如果你粘贴你的客户端配置,它将有助于确认这是否是问题。 –
嗨德鲁,谢谢你的回复。我将在未来15分钟内提供客户端web.config。 – Henry