如何解决无法访问 WCF 服务元数据 (wsdl):错误 400
我在新安装(Windows Server 2016 上的 IIS 10)上遇到 WCF 元数据问题
情况
-
WCF 服务运行良好(就像以前安装时一样)
-
wsdl 的导航(通过浏览器)不再可能,或者更好
-
http://ServiceA/ServiceA.svc:是(网页可用)但指向 xml 的链接不起作用(来自 IIS 的错误 400)
-
https://ServiceA/ServiceA.svc:连页面都没有
此外,在 serviceMetadata 中声明使用 https 不使用 http,这与刚刚描述的行为形成对比。
下面是 web.config 的摘录
<services>
<service behaviorConfiguration="ServiceBehavior" name="...">
<endpoint address="https://<fqdn>/ServiceA/ServiceA.svc"
binding="wsHttpBinding"
bindingConfiguration="wsHttpEndpointBinding"
name="WsHttpBinding"
contract="ServiceContracts.IServiceA">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
...
可能与名称解析有关吗? PC 名称为 AAAAAA,FQDN 为 BBBBB.domain.ext
感谢您的任何建议 L.
解决方法
部署在 IIS 中的 WCF 服务不需要在 web.config 中设置端点地址。
这是我的演示:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true">
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<system.webServer>
<!--
To browse web app root directory during debugging,set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
<system.serviceModel>
<services>
<service name="WcfService25.Service1" behaviorConfiguration="WcfService25.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="WcfService25.IService1">
<!--
Upon deployment,the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed,WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService25.Service1Behavior">
<!-- To avoid disclosing metadata information,set the value below to false 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这是 web.config。此项目为模板项目。
WCF服务在IIS中的基地址如下:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。