我创建了一个 WCF 服务。最初我能够使用我的本地 URL https://localhost:44390/MyService.svc. 添加或更新服务引用,但是一旦我在 serviceMetaData 中将 HttpsGetEnabled 的值更改为 false
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
我无法再添加此服务参考,也无法更新服务参考。我收到下面以粗体显示的错误。如何将这两个值(httpGetEnabled、httpsGetEnabled)设置为 false
来更新或添加服务下载出错
**'https://localhost:44390/MyService.svc/$metadata'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'https://localhost:44390/MyService.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service https://localhost:44390/MyService.svc. The client and service bindings may be mismatched.
The remote server returned an error: (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'..
If the service is defined in the current solution, try building the solution and adding the service reference again.**
在客户端,我正在尝试按照以下方式在 web.config 中混合服务
<client>
<endpoint address="https://localhost:44390/MyService.svc" binding="basicHttpsBinding" bindingConfiguration="BasicHttpsBinding_IMyService" contract="MyWCFService.ITWCIntegrationECHO" name="BasicHttpsBinding_IMyService"/>
</client>
在我的服务中我添加了以下行为
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<!-- 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>
[1]: https://i.stack.imgur.com/t9qfU.png
为了生成代理,我们需要元数据信息。 serviceMetadata中
httpGetEnabled
和httpsGetEnabled
的默认值为false。值为 false 表示您没有提供 WSDL 格式的元数据。
我们还可以提供 MEX 格式的数据来生成这样的代理:
<endpoint address="mex" binding="mexBasicHttpBinding" contract="IMetadataExchange"/>