我作为Windows服务托管WCF服务。WCF多点服务端点
下面的快照。
myHost = new ServiceHost(typeof(AnalyticsService));
Uri address = new Uri("http://localhost:8080/MathServiceLibrary");
WSHttpBinding binding = new WSHttpBinding();
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
//binding.Security.Mode = SecurityMode.None;
Type contract = typeof(IAnalyticsService);
myHost.AddServiceEndpoint(contract,binding,address);
正如你所看到的,我以前一直只在本地公开服务。我想添加另一个ServiceEndpoint,以便我的网络上的其他机器也可以调用该服务。
我想我需要这样的添加了一些上面的代码:
myHost = new ServiceHost(typeof(AnalyticsService));
Uri address = new Uri("http://localhost:8080/MathServiceLibrary");
Uri new address = new Uri("http://xxx.xxx.xxx:8080/MathServiceLibrary");
WSHttpBinding binding = new WSHttpBinding();
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
Type contract = typeof(IAnalyticsService);
myHost.AddServiceEndpoint(contract, binding, address);
myHost.AddServiceEndpoint(contract, binding, newaddress);
现在我目前的服务库应用程序配置的样子:
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceLibrary.Service1Behavior"
name="ServiceLibrary.AnalyticsService">
<endpoint address="" binding="wsHttpBinding" contract="ServiceLibrary.IAnalyticsService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/ServiceLibrary/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceLibrary.Service1Behavior">
<!-- 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>
尽管服务库在我的app.config
主机是
<system.serviceModel>
<services>
<service name="ServiceLibrary.AnalyticsService"
behaviorConfiguration ="MathServiceMEXBehavior">
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/MathService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MathServiceMEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我想我需要添加另一个基地址与外部(非本地主机)地址的服务库文件。我很困惑在服务库文件中改变什么。
如果您发布代码或XML,请**在文本编辑器中突出显示这些行然后点击编辑器工具栏上的“代码”按钮(101 010),以良好地格式化和语法突出显示它! – 2010-07-22 18:23:49