添加WCF服务引用出错:content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.
下载“http://127.0.0.1:960/Service.svc”时出错。
请求因 HTTP 状态 404 失败: Not Found。
元数据包含无法解析的引用:“http://127.0.0.1:960/Service.svc”。
没有终结点在侦听可以接受消息的 http://127.0.0.1:960/Service.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参见 InnerException 以了解详细信息。远程服务器返回错误: (404) 未找到。如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。浏览器访问服务显示
解决方案:
在配置文件中添加
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<!--<behavior name="GeoDataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>-->
</serviceBehaviors>
<!--<endpointBehaviors>
<behavior name="GDEPBehavior">
<webHttp />
</behavior>
</endpointBehaviors>-->
</behaviors>
<bindings>
<webHttpBinding>
<binding name="SerViceBinding" crossDomainScriptAccessEnabled="true"/>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
</system.serviceModel>
再次在浏览器中放问服务地址,出现以下界面,即可成功添加服务引用
您的资助是我最大的动力!
金额随意,欢迎来赏!

浙公网安备 33010602011771号