日期:2014-05-20  浏览次数:20959 次

wcf发布的web service无法访问?
我用wcf发布成的 webservice在本机通过增加web引用用此地址http://192.168.31.82:8080/WebService,能访问,
在别人机器上通过wcf的方式也能访问,就是通过web 引用的方式不行
但在别人机器上访问时出现下面的错误: 

- 来自“http://192.168.31.82:8080/WebService”的报告是“无法识别此文档格式(内容类型为“text/html; charset= 
“DISCO 文档”的报告是“下载“http://localhost:8080/WebService.asmx?disco”时出错。”。 

这是我的配制信息:
  <system.serviceModel>
  <services>
  <service name="Infrastructure.WCF.ServerProxy" behaviorConfiguration="MyServiceTypeBehaviors">
  <host>
  <baseAddresses>
  <add baseAddress="http://localhost:8080/WebService"/>
  </baseAddresses>
  </host>

  <endpoint
  name ="basicHttpEndPoint"
  address=""
  contract="Infrastructure.WCF.IServerProxy"
  binding="basicHttpBinding"
  />

  <endpoint
  name="TcpEndPoint"
  address="net.tcp://localhost:8085/Remoting/"
  binding="netTcpBinding"
  bindingConfiguration=""
  contract="Infrastructure.WCF.IServerProxy" />

  </service>
  </services>

  <behaviors>
  <serviceBehaviors>
  <behavior name="MyServiceTypeBehaviors" >
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="False"/>
  </behavior>
  </serviceBehaviors>
  </behaviors>

  </system.serviceModel>


------解决方案--------------------
“wcf发布成的 webservice”----什么意思?wcf与webservice是不同的两种事物。你是不是说用了wcf的httpbinding模式?这要在client端通过“添加服务引用”才能用,添加web服务虽然添加是成功地,但是是无法使用的。
------解决方案--------------------
wsHttpEndPoint

如果你需要早先版本的vs支持的ws客户端访问,使用wsHttpBinding。


------解决方案--------------------
basicHttpBinding

如果你需要早先版本的vs支持的ws客户端访问,使用wsHttpBinding。
------解决方案--------------------
添加 

 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit" />


然后在添加这个
<serviceBehaviors>
<behavior name="Service.ECCSReadServiceBehavior">
<serviceMetadata httpGetEnabled="true" /> 
</behavior>
</serviceBehaviors>
才可以看到元数据


对于WebService ,只有BasicHttpBinding 才有效,其他都会不支持的