[英]WCF Hosted as Service
I have a VB.NET WCF service hosted as a Window Service. 我有一个VB.NET WCF服务托管为窗口服务。 I was able to create an install package, install the service to my machine, and start the service manually from Services in Administrative Tools.
我能够创建一个安装包,将该服务安装到我的计算机上,然后从管理工具中的“服务”中手动启动该服务。
Now when I try to reference the service in my test console application (Address: http://localhost:8080/ ), I get the following error: 现在,当我尝试在测试控制台应用程序(地址: http:// localhost:8080 / )中引用该服务时,出现以下错误:
There was an error downloading 'http://localhost:8080'.`
下载“ http:// localhost:8080”时出错。
Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8080`
无法连接到远程服务器无法建立连接,因为目标计算机主动拒绝它127.0.0.1:8080`
Metadata contains a reference that cannot be resolved: 'http://localhost:8080/'.
元数据包含无法解析的引用:“ http:// localhost:8080 /”。 Could not connect to http://localhost:8080/ .
无法连接到http:// localhost:8080 / 。 TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080.
TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:8080。 Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8080 If the service is defined in the current solution, try building the solution and adding the service reference again.
无法连接到远程服务器无法建立连接,因为目标计算机主动拒绝它127.0.0.1:8080如果服务在当前解决方案中定义,请尝试构建解决方案并再次添加服务引用。
Not sure what I can do about this. 不知道该怎么办。 Any ideas???
有任何想法吗???
Thanks, Jason. 谢谢,杰森。
Here's the code from app.config inside my service: 这是我的服务中来自app.config的代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<services>
<service name="ExStreamWCF.Service1"
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<!-- Service Endpoints -->
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="ExStreamWCF.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ExStreamWCF.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
If anyone needs more from me please let me know! 如果有人需要我提供更多信息,请告诉我!
Not sure if it's really an issue - but on a production server, I would never use localhost
as my base address. 不知道这是否真的是一个问题-但是在生产服务器上,我永远不会使用
localhost
作为我的基地址。
So can you try to change: 所以您可以尝试更改:
<service name="ExStreamWCF.Service1"
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>
to 至
<service name="ExStreamWCF.Service1"
behaviorConfiguration="ExStreamWCF.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://YourServerName:8080/Design_Time_Addresses/JasonsService/Service/" />
</baseAddresses>
</host>
Does that make any difference when calling into the service?? 调用服务时有什么区别吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.