[英]Self hosting WCF service: unable to use wcfTestClient - unable to get metadata
该服务可以正常工作,但是由于某些原因,我无法从本地PC到服务器使用wcftestclient.exe-我想使用wcftestclient.exe调用方法。
其所有公司内部的,自托管的(在Windows服务中运行,没有iis)。 框架4. Basichttpbinding,不需要任何安全的东西。
这是我的servicemodelconfig ...
<system.serviceModel>
<services>
<service name="myService">
<endpoint
address="http://servername:8001/myService"
binding="basicHttpBinding"
contract="IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="MyDefaultBehaviour">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://servername:8001/myService/mex" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="1" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我得到...
错误:无法从中获取元数据如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用元数据发布。 有关启用元数据发布的帮助,请参阅MSDN文档, 网址为http://go.microsoft.com/fwlink/?LinkId=65455。WS-MetadataExchange错误URI:
元数据包含无法解析的引用:'。 内容类型application / soap + xml; 服务不支持charset = utf-8
客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)由于内容类型为'application / soap + xml,因此无法处理该消息; charset = utf-8'不是预期的类型'text / xml; charset = utf-8'.. HTTP GET错误URI:
下载“ http://”时出错
请求失败,HTTP状态为400:错误的请求。
我已经在上面清空了我们的服务器名称,因此有很多空白,但是希望该消息足够清晰。
我尝试添加其他端点...
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
但与此同时,Windows服务将无法启动。
谢谢
-----稍后添加---也尝试过此操作,但再次无法启动服务
<system.serviceModel>
<services>
<service name="myService" behaviorConfiguration="MyDefaultBehaviour">
<host>
<baseAddresses>
<add baseAddress="http://myServer:8001/myService" />
</baseAddresses>
</host>
<endpoint
address=""
binding="basicHttpBinding"
contract="Contracts.ImyService" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetaDataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="MyDefaultBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="1" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
如果添加mexendpoint,则需要添加baseAddress:如下所示:
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9999/WcfTcp/Service1"/>
</baseAddresses>
</host>
我的第二个配置毕竟可以工作,即使用basaddress,标准端点的空字符串和“ mex”端点。 IMetadataExchange的大写字母D拼写错误。 非常感谢@Grady
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.