2012-06-29 256 views
1

我知道這是一個常見問題解答,我已經閱讀了所有類似的Q和A,但我仍然不能正確。無法添加服務。無法連接到遠程服務器

我在一般的Web服務和ASP.NET是一個新手。我有一個由同事編寫的小WCF服務應用程序,該應用程序在他的電腦上工作並進行了演示。在我的電腦上,沒有任何更改,我無法在WCF Test Client程序將它作爲服務添加時接受它(下面的錯誤消息)。我的同事現在休假了!

項目屬性設置爲使用帶有自動分配端口號的VS開發服務器啓動WcfTestClient.exe。該項目已添加webform.aspxGlobal.asax文件,這是服務所需的。

我已經運行

netsh http add urlacl url=http://localhost:51568/Service1.svc user=<loginname> 

我的問題是我如何才能通過WcfTestClient啓動該服務,並在瀏覽器上的網頁表單?

我已經看過各種SO回答類似的問題,但我仍然遭到拒絕。

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata. Error: Cannot obtain Metadata from http://localhost:51568/Service1.svc 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 ... Error URI: http://localhost:51568/Service1.svc
Metadata contains a reference that cannot be resolved: ' http://localhost:51568/Service1.svc '. There was no endpoint listening at http://localhost:51568/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:51568HTTP GET Error URI: http://localhost:51568/Service1.svc There was an error downloading ' http://localhost:51568/Service1.svc '. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:51568

這是我的web.config:

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
</system.web> 
<system.serviceModel> 
    <services> 
     <service name="Service1" behaviorConfiguration="DefaultBehavior"> 
      <endpoint address="http://localhost:*/Service1" binding="basicHttpBinding" contract="IService1" /> 
      <endpoint address="http://localhost:*/Service1/mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="DefaultBehavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
       <serviceDebug includeExceptionDetailInFaults="false"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

東西很奇怪,我對於端口號是,如果我不設置項目開始與外部程序,然後在瀏覽器中列出的目錄在本地主機端口50345列表這是一個不同的端口號51568.

回答

0

Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:51568

而且

if I don't set the project to start with the external program then the browser lists the directory listing at localhost port 50345

這只是表示您的WCF服務託管在後一個端口。您可以在項目屬性的「Web」選項卡上更改此項。

+0

非常感謝,我刪除了以前的答案讓我困惑的部分,並將測試客戶端指向'http:// localhost:50345/Service1.svc',一切都很好。 – acraig5075

相關問題