2012-06-29 255 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

相关问题