2013-04-10 99 views
0

連接基本上,我有一個完整的程序,連接到它承載多業務的控制檯應用程序。我需要做的是有我的客戶一臺PC上,而我的另一個託管的所有服務主機。不過,我不確定這是如何工作的。託管WCF服務,從另一個PC

在我的微小主機的配置文件是

< 

?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 

     <system.web> 
     <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IReportService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="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_IFuelSupplyService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="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> 
     </basicHttpBinding> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_IPostoPumpService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8732/Design_Time_Addresses/PumptoPosService/Service1/" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPostoPumpService" 
     contract="PumpPosClient.IPostoPumpService" name="WSHttpBinding_IPostoPumpService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="http://localhost:8732/Design_Time_Addresses/ServerService/Service1/" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1" 
     contract="Server.IService1" name="WSHttpBinding_IService1"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="http://08346.net.dcs.hull.ac.uk/services/ReportService.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReportService" 
     contract="ReportServer.IReportService" name="BasicHttpBinding_IReportService" /> 
     <endpoint address="http://08346.net.dcs.hull.ac.uk/services/FuelSupplyService.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFuelSupplyService" 
     contract="PricingServer.IFuelSupplyService" name="BasicHttpBinding_IFuelSupplyService" /> 
    </client> 
    <services> 
     <service name="PumptoPosService.PostoPumpService"> 
     <endpoint address="" binding="wsHttpBinding" contract="PumptoPosService.IPostoPumpService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/PumptoPosService/Service1/" /> 
      </baseAddresses> 
     </host> 
     </service> 
     <service name="ServerService.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/ServerService/Service1/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="wsHttpBinding" contract="ServerService.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <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="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

</configuration> 

什麼想法?如果可能的話,有沒有辦法把它配置在運行,所以如果它是本地的,使用localhost,否則連接到主機上的端口5000

感謝

回答

1

你需要寫一個custom ServiceHostFactory。這將允許你當服務被實例化注入服務端點地址(和端口)。這good blog post詳細介紹,你需要做什麼。

+0

感謝的人,我會檢查一下,看看我能做些什麼。 – 2013-04-10 14:53:33