這很難解釋,所以請讓我澄清任何不清楚的事情。如何配置在另一個WCF服務庫中引用的WCF服務的URL
我有3個WCF Web服務庫和3個主機應用程序,我將其稱爲Service1
,Service2
和Service3
。 Service2採用相同的解決方案,但目前與此問題無關。
Service1
參考Service3
主機應用程序。一旦編譯完成後,我看不到任何方法可以在Service1
中配置Service3
的URL。
我希望它在Service1
主機應用程序的配置中。這可能嗎?我不能相信這是硬編碼在DLL中?
服務1庫App.Config中:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service3Data" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyHost/gws/GService3.svc/gwd"
binding="basicHttpBinding" bindingConfiguration="Service3Data"
contract="GServices3.IGws" name="Service3Data" />
</client>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="" binding="basicHttpBinding" contract="MyNameSpace.Business.WebServices.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/MyNameSpace.Business.WebServices/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
服務1主機應用程序Web.Config(和我需要來配置服務3網址):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Binding" openTimeout="00:10:00" maxBufferPoolSize="2147483646"
maxBufferSize="2147483646" maxReceivedMessageSize="2147483646">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="bwd" binding="basicHttpBinding" bindingConfiguration="Service1Binding"
name="BWData" contract="MyNameSpace.Business.WebServices.IService1" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
當您說「Service1引用Service3主機應用程序」時,是否指您在Service1中爲Service3創建代理? – Szymon
@Szymon對不起,是的,這就是我的意思。 – Fred
好吧,因此添加代理意味着您在Service1的配置文件中也應該有條目,並且您應該可以在其中設置URL。 – Szymon