2011-04-14 98 views
0

我的WCF服務工作正常,然後突然停止工作。我認爲我沒有改變任何配置。WCF - 不會創建服務引用

WCF服務由Windows服務託管。

奇怪的是,當我添加服務引用時,它將識別合同和所有暴露的方法。但是,如果我去瀏覽器,我得到一個404錯誤,編譯器不創建服務。我已刪除並嘗試重新添加引用沒有運氣

此外,我部署的應用程序仍然能夠訪問wcf服務。

問題1: 在WCF windows服務中,我應該能夠在瀏覽器(http:// localhost:8080/MaestroService/mex)中看到wsdl。在IE中,我收到了400個錯誤的請求。我假設這是問題的根源。

問題2: 還有別的嗎?

的App.config

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="NewBinding0" /> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
<serviceBehaviors> 
    <behavior name="metadataAndDebug"> 
    <serviceMetadata httpGetEnabled="true" /> 
    <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" /> 
    </behavior> 
</serviceBehaviors> 
</behaviors> 
<services> 
    <service behaviorConfiguration="metadataAndDebug" name="MaestroServiceLibrary.MaestroService"> 
    <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="NewBinding0" 
     name="basicHttp" contract="MaestroServiceLibrary.IMaestroService" /> 
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
     contract="IMetadataExchange" /> 
    <endpoint address="net.tcp://localhost:8888/MaestroService" binding="netTcpBinding" 
     bindingConfiguration="" name="netTcpBinding" contract="MaestroServiceLibrary.IMaestroService" /> 
    <endpoint address="net.pipe://localhost/MaestroService" binding="netNamedPipeBinding" 
     bindingConfiguration="" name="netNamedPipeBinding" contract="MaestroServiceLibrary.IMaestroService" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8080/MaestroService" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 

錯誤編譯:

Custom tool error: Failed to generate code for the service reference 'MaestroService'. Please check other error and warning messages for details. 

Custom tool warning: Cannot import wsdl:binding 


Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on. 

XPath來的wsdl:portType的:// WSDL:定義[@的targetNamespace =「HTTP ://tempuri.org/']/wsdl:portType [@ name ='IMaestroService'] XPath來誤差來源://wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='basicHttp']

更新

我打開跟蹤,我看到: 由於EndpointDispatcher中的AddressFilter不匹配,無法在接收方處理To'http:// localhost:8080/MaestroService/mex/mex'的消息。檢查發件人和收件人的EndpointAddresses是否同意。如果我弄清楚,我會更新這個問題。

更新V2

我去同一個解決方案中的另一個項目。我能夠在那裏添加服務,沒有任何問題。我注意到我在wpf瀏覽器應用程序中的控制檯應用程序中使用3.5版本。當我回來報告這個時,我注意到在我的最新更新中,即使我將http://localhost:8080/MaestroService/mex放入了url中,它仍然有/ mex/mex。我試過http://localhost:8080/MaestroService,它工作!

最後,我最終使用了Migual Castro技術here,在那裏創建了conracts和代理。很高興看到它是如何工作的以及VS在做什麼。但是,一天半之後回來是件好事。

感謝大家的建議。

+0

「我不認爲我改變了任何配置。」 - 這通常是事情停止工作的原因.... – 2011-04-14 14:20:28

+0

@Mitch。嚴。 :(我儘量不要觸摸它,但我不能100%肯定,但我知道我沒有碰到生產副本的配置,我得到的結果相同 – H20rider 2011-04-14 15:27:08

回答

0

您正在作爲Windows服務運行。

Windows服務在用戶帳戶的安全上下文中運行。

如果用戶帳戶的密碼更改或過期,則該服務不會運行。

您應該檢查的第一件事是:服務是否正在運行。

+0

該服務正在運行。如果不是,我會得到在添加引用之後:無法連接到遠程服務器並且在IE中沒有響應 – H20rider 2011-04-14 18:15:46

+0

它是否是空綁定配置? – 2011-04-14 21:31:08

+0

我放棄了試圖弄清楚爲什麼突然之間我無法添加服務引用。我結束了以下使用的技術http://www.dnrtv.com/default.aspx?showNum=122。它看起來像一個更清潔的實現,然後添加服務參考 – H20rider 2011-04-18 21:09:49