WCF 서비스를 Windows 서비스로 호스팅하고 있습니다.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를 추가하고 싶습니다.
은 내가 위의 코드에 다음과 같이 뭔가를 추가해야합니다 가정 : APP의 설정 보이는 지금
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)을 클릭하면 멋지게 포맷하고 구문을 강조 할 수 있습니다! –