我正在开发一个正在开发的客户端 - 服务器应用程序。
我为客户端部件创建了一个Windows窗体应用程序,为服务器部件创建了一个WCF应用程序。 我正在使用Visual Studio 2010.该应用程序在本地工作正常,但我需要将它们分开。我想在连接到与客户端应用程序相同的LAN的远程PC中运行Server应用程序。
每次调试我的服务器应用程序时,它都运行在“http:/ / localhost:port”但我需要它在“http:/ /192.168.1.xxx上运行:端口“即可。这样我就可以使用该地址将服务导入我的客户端应用程序:“http:/ /192.168.1.xxx:port/Service1.svc”。
我有另一个问题。如何导出我的服务器应用程序以在任何我想要的地方运行它?即如何运行我的服务器应用程序而不在Visual Studio 2010上调试它?。
这些是我服务的配置文件:
客户端(app.config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IValidacionesService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocalhostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_IEncuestaCRUDService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="3200" maxStringContentLength="819200" maxArrayLength="1638400"
maxBytesPerRead="409600" maxNameTableCharCount="1638400" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http:/ /localhost:2504/ValidacionesService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IValidacionesService"
contract="ServiceValidacionesReference.IValidacionesService"
name="BasicHttpBinding_IValidacionesService" />
<endpoint address="http:/ /localhost:2504/EncuestaCRUDService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEncuestaCRUDService"
contract="ServiceEncuestaReference.IEncuestaCRUDService" name="BasicHttpBinding_IEncuestaCRUDService" />
</client>
</system.serviceModel>
服务器端(web.config):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<connectionStrings>
<add name="CADBEntities" connectionString="metadata=res://*/ModeloCaDB.csdl|res://*/ModeloCaDB.ssdl|res://*/ModeloCaDB.msl;provider=System.Data.SqlClient;provider connection string="data source=OMSUser\SQLEXPRESS;initial catalog=CADB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
提前致谢。
答案 0 :(得分:1)
答案 1 :(得分:0)
您的客户正在尝试与设置为 localhost 的EndpointAddress进行通信,这意味着当前的计算机。
必须将其配置为联系托管WCF服务的计算机的IP地址。
以下是如何在客户端配置文件中执行此操作的示例。
<system.serviceModel>
<client>
<endpoint address="http://192.168.1.xxx:port/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IValidacionesService"
contract="IValidacionesService" name="BasicHttpBinding_IValidacionesService">
</endpoint>
</client>
</system.serviceModel>