2013-10-21 104 views
0

我有我的服务托管在IIS7与net.tcp作为启用protocol.When我浏览从IIS的服务,我可以看到服务页面和它的tcp地址,但如果我使用该地址与WCF测试客户端或任何应用程序作为服务引用我得到这个错误在WCF客户端WCF:无法获取元数据错误

Error: Cannot obtain Metadata from http://localhost:808/MyService/MyService.svc?wsdl 
If this is a Windows (R) Communication Foundation service to which you have access, 
please check that you have enabled metadata publishing at the specified address. 
For help enabling metadata publishing, 
please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455 
WS-Metadata Exchange Error 
URI: http://localhost:808//MyService/MyService.svc?wsdl 
Metadata contains a reference that cannot be resolved: 
'http:/localhost:808/MyService/MyService.svc?wsdl . 
There was no endpoint listening at 
'http:/localhost:808/MyService/MyService.svc?wsdl that could accept the message. 
This is often caused by an incorrect address or SOAP action. See InnerException, 
if present, for more details.  
The remote server returned an error: (404) Not Found.HTTP GET Error 
URI: http:/localhost:808/MyService/MyService.svc?wsdl  
The HTML document does not contain Web service discovery information. 

我很惊讶,当我把地址的net.tcp在WCF客户端为什么误差约为HTTP只

我的服务配置是

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 


<system.web> 
<compilation debug="true" targetFramework="4.0"/> 
<httpRuntime maxRequestLength="102400" /> 
</system.web> 

<system.serviceModel> 
    <bindings> 
    <netTcpBinding> 
    <binding name="TcpBinding" maxBufferPoolSize="2147483647" 
    maxBufferSize="2147483647" 
      closeTimeout="10:00:00" sendTimeout="10:00:00" openTimeout="10:00:00" 
     receiveTimeout="10:00:00" 
     maxReceivedMessageSize="2147483647" portSharingEnabled="true" > 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"/> 
     <reliableSession enabled="true" inactivityTimeout="10:00:00" /> 
    </binding> 
    </netTcpBinding> 
    </bindings> 
    <services> 
    <service behaviorConfiguration="MyService.MyServiceBehaviour" 
     name="MyService.MyService"> 
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="TcpBinding" 
     name="EndPointTCP" contract="MyService.IMyService" isSystemEndpoint="false" /> 
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
    <behavior name="MyService.MyServiceBehaviour"> 
     <serviceMetadata httpGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
    </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
     <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate"  
     /> 
    </system.webServer> 

    </configuration> 
+0

如果你试图添加服务引用,那么httpGetEnabled应该在你的服务行为中为真 –

+0

@SanjayRabadiya嗯,我不认为它需要TCP绑定。因为我不希望我的服务在http协议上访问。 – TRS

+0

我认为服务使用http绑定。 –

回答

0

我想出了根本原因,因为从Windows功能激活WCF非http激活时出现了一些问题,它总是给出错误,如操作无法完成。我能够在其他机器上运行我的服务,但仍然希望知道什么可能是WCF非http激活错误的可能原因。

0

由于它是一个netTcp绑定,因此您无法将其添加到wcf测试客户端并进行测试。要在WCF测试客户端中使用,您还需要使用Http公开该服务(即使用Http和NetTcp绑定)。那么你可以浏览元数据并在wcf测试客户端使用Http来使用它。使用NetTcp绑定将服务公开给客户端。希望我已经回答了你的问题。

注意:在您托管的网站下的IIS中,前往设置并将允许的绑定提及为“Http,NetTcp”。

+0

:“因为它是一个netTcp绑定,你不能将它添加到wcf测试客户端并测试它吗?”它可能,Iam成功地做到了,并且我还为http和net.tcp在IIS中设置了启用的协议。我想从根本原因,因为有一些问题,从Windows功能激活WCF非HTTP激活,它总是给错误,如操作无法完成。我能够在其他机器上运行我的服务,但仍想知道什么可能是可能的WCF非http激活错误的原因 – TRS

+0

什么是您正在使用的.Net框架版本和操作系统?因为有一个来自Microsoft的已知错误,请检查此处的链接[link](http://connect.microsoft.com/VisualStudio/feedback/details/455497/installation-of-net-framework-3-5-1-features- WCF激活-HTTP-激活失败与 - 误差0x80070643-当净4-β-1-被安装) – Abhinay