2011-06-06 135 views
0

我在VS2010中發生代理生成問題。WCF代理生成問題

我已經創建了一個使用WCF和Pub/Sub模式的客戶端/服務器應用程序。該服務的工作以及在本地,而我可以在服務器上通過我的瀏覽器我不能「配置服務引用」沒有得到下面的錯誤啓動服務,並可以通過培訓相關訪問的URL:

The document at the url http://cfplonbs2:8686/TradePortal was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. - Report from 'http://cfplonbs2:8686/TradePortal' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. - Report from 'DISCO Document' is 'There was an error downloading 'http://localhost:8686/TradePortal?disco'.'. - Unable to connect to the remote server - No connection could be made because the target machine actively refused it 127.0.0.1:8686 - Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. Metadata contains a reference that cannot be resolved: 'http://cfplonbs2:8686/TradePortal'. There was no endpoint listening at http://cfplonbs2:8686/TradePortal 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. If the service is defined in the current solution, try building the solution and adding the service reference again.

我發現了什麼困惑當我使用svcutil.exe工具並手動生成代理時,我可以使代碼正常工作,但這個appproach的問題在於它不像VS2010代理那樣乾淨,並且它們沒有實現iNotifyPropertyChanged接口。

這可能是阻止訪問的服務器上的防火牆設置?有沒有更改我在本地生成的代理中綁定的計算機名稱的快捷方式?

我在服務器端的app.config是:

<services> 
     <service behaviorConfiguration="Default" name="CFP_Web_Lib.TradePortal"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8686/TradePortal"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="webHttpBinding" 
      contract="CFP_Web_Lib.ITradePortal" 
        behaviorConfiguration="web"/> 
     <endpoint address="Operations/" binding="wsDualHttpBinding" 
      contract="CFP_Web_Lib.ITradeOperations"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Default"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <wsDualHttpBinding> 
     <binding name="WSDualHttpBinding_IPubSubService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" /> 
      <security mode="Message"> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsDualHttpBinding> 
     <mexHttpBinding> 
     <binding name="NewBinding0" /> 
     </mexHttpBinding> 
    </bindings> 

上我要去哪裏錯了有什麼想法?

回答

0

首先,開發後不需要「Configure Service Reference」。只更改web.configapp.config中的地址點。

其次,檢查服務器部分是否配置了mex端點,否則您將無法創建其他客戶端。

最後,當您嘗試訪問WSDL爲服務使用兩種符號之一:

http://server:port/service?wsdl 

http://server:port/service/mex 
+0

我認爲,這個問題是對的wsDualHttpBinding安全,當我更改地址時,出現安全錯誤。我已經將它切換到NetTcP,現在它工作正常 – 2011-06-07 09:16:27