我遇到了我正在開發的客戶端 - 服務器應用程序的問題。使用遠程WCF服務
我已經爲客戶端部分創建了一個Windows窗體應用程序,併爲服務器部分創建了一個WCF應用程序。 我正在使用Visual Studio 2010.該應用程序在本地運行良好,但我需要將它們分開。我想在連接到與客戶端應用程序相同的LAN的遠程PC中運行服務器應用程序。
每次調試我的服務器應用程序,它運行在「HTTP:/ /本地主機:端口」,但我需要它在「HTTP:/ /192.168.1.xxx:port」運行。以便我可以使用該地址將服務導入到我的客戶端應用程序:「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" />
在此先感謝。
我已經這樣做了,但我無法連接到服務器。 – omaestra
你現在自己託管這項服務嗎?我看到你還沒有致力於IIS。 –
是的,我自己託管服務。爲什麼我應該將它提交給IIS? – omaestra