WCF服务 远程服务器返回错误: (415)
在浏览器可以打卡wcf服务接口,但是vs中添加服务引用失败。
下载“http://192.168.22.148:8080/$metadata”时出错。
请求失败,HTTP 状态为 404: Not Found。
元数据包含无法解析的引用:“http://192.168.22.148:8080/”。
服务 http://192.168.22.148:8080/ 不支持内容类型 application/soap+xml; charset=utf-8。
客户端和服务绑定可能不匹配。
远程服务器返回错误: (415) Cannot process the message because the content type 'application/soap+xml;
charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.。
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
解决方法是:
在
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
配置如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<!--添加到这里-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="WcfServiceLibrary2.Service1">
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary2.IService1"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<defaultDocument>
<files>
<add value="WcfServiceLibrary2.Service1.svc" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
查了好多天,原来就是少了个配置。这是部署在windows Server服务器上,一般的windows客户机系统都不需要,就可以直接访问的到。
还没有评论,来说两句吧...