WCF的问题 - .NET技术 / .NET技术前瞻
请问如果用WCF的host用的是HTTP协议,那么用这段命令就可以生成客户端类
svcutil.exe http://localhost:8888/EmployersReward?wsdl
但是如果用的是tcp协议的话如何试用svcutil来生成客户端类呢?我尝试使用这个的命令
svcutil.exe net.tcp://localhost:9999/EmployersReward
但是却报下面这样的错,请问应该怎样做?
WS-Metadata Exchange Error
URI: net.tcp://localhost:9999/EmployersReward
元数据包含无法解析的引用:“net.tcp://localhost:9999/EmployersReward”。
套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的
网络资源问题导致的。本地套接字超时是“00:04:59.9218750”。
远程主机强迫关闭了一个现有的连接。
------解决方案--------------------支持啊,偶也遇到这个问题,楼主解决了么?解决的话告诉一声哈,3Q
------解决方案--------------------svcutil "exe路径"
svcutil *.wsdl *.xsd /a /language:C# /out:MyProxy.cs /config:app.config
------解决方案--------------------只有在配置了 mex*Binding 和serviceMetadata 服务行为True时才可以获取元数据
<configuration>
<system.serviceModel>
<services>
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<!-- This endpoint is exposed at the base address provided by the host: http://localhost/servicemodelsamples/service.svc -->
<endpoint address=""
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- the mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex
To expose the IMetadataExchange contract, you
must enable the serviceMetadata behavior as demonstrated below
必须有这个节点能请求 -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<!-- The serviceMetadata behavior publishes metadata through
the IMetadataExchange contract. When this behavior is
present, you can expose this contract through an endpoint
as shown above. Setting httpGetEnabled to true publishes
the service's WSDL at the <baseaddress>?wsdl
eg. http://localhost/servicemodelsamples/service.svc?wsdl
如果这个为false话,会直接拒绝请求 -->
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
------解决方案--------------------搞定了没有,我是用netTcpBinding 我的security配置成windows 提示的是我的凭证不对,换成none后出问题,google到你的贴子,搞定了分享呀,兄弟!