2013-07-08 86 views
0

enter code here我的WCF服務沒有在測試客戶端運行,但通過瀏覽器,還運行,當我通過jQuery的獲取WCF服務不是在測試客戶端運行

可能是什麼問題

錯誤: 失敗添加一項服務。服務元數據可能無法訪問。確保您的服務正在運行並展示元數據。

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="SimpleServiceBehavior"> 
     <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<bindings> 
    <webHttpBinding> 
    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" /> 
    </webHttpBinding> 
</bindings> 
<services> 
    <service name="WcfService6.Service1"> 
    <endpoint address="" binding="webHttpBinding" 
       bindingConfiguration="webHttpBindingWithJsonP" contract="WcfService6.IService1" 
       behaviorConfiguration="webHttpBehavior"/> 
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
</services> 

+0

可能的重複[如何設置WCF測試客戶端將運行每次服務運行](https://stackoverflow.com/questions/7805818/how-to-set-that-the-wcf- test-client-will-run-every-time-the-service-is-running) – Volomike

+0

首先,看一看dupe問題,然後注意[this comment](https://stackoverflow.com/a/31223693/105539) 。完成後,請按照[本教程](https://msdn.microsoft.com/en-us/library/bb386386.aspx)進行操作。 – Volomike

回答

0

使用被配置成使用HTTP方法REST web服務你probabily。 WCF測試客戶端是一個SOAP客戶端,需要訪問Web服務元數據才能工作。

元數據配置條目添加到您的Web服務配置:http://msdn.microsoft.com/en-us/library/ms788760.aspx

在您發佈的配置你配置了兩個web服務。 你應該對當前Web服務實現元數據,沒有配置其他Web服務:

<system.serviceModel> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="webHttpBehavior" > 
     <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" /> 
     <webHttp /> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<bindings> 
    <webHttpBinding> 
    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" /> 
    </webHttpBinding> 
</bindings> 
<services> 
    <service name="WcfService6.Service1"> 
    <endpoint address="" binding="webHttpBinding" 
       bindingConfiguration="webHttpBindingWithJsonP" contract="WcfService6.IService1" 
       behaviorConfiguration="webHttpBehavior"/> 
     <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
</services> 

請仔細閱讀本:WCF REST Service not visible in WCFTestClient

+0

你可以發佈你的配置文件的servicemodel部分嗎? –

+0

DIS如你所說,但仍然無法正常工作,但通過工作和URL和jQuery的 – Mayur

+0

你可以發佈服務接口? –

0

您必須啓用服務的元數據交換,使用的配置文件,這將是ServiceBehavior下

<behaviors> 
    <serviceBehaviors> 
    <behavior name="SimpleServiceBehavior"> 
     <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

嘗試以下鏈接

http://msdn.microsoft.com/en-us/library/ms734765.aspx

+0

沒有親愛的仍然沒有工作 – Mayur

+0

同樣的錯誤我再次張貼我的服務模式 – Mayur