문제

net.tcp를 통해서만 지원되는 일부 설정이 있는 서비스가 있습니다.다른 엔드포인트를 추가하는 가장 좋은 방법은 무엇입니까?완전히 새로운 호스트를 생성해야 합니까?

도움이 되었습니까?

해결책

서비스는 단일 호스트 내에 여러 엔드포인트를 가질 수 있지만 모든 엔드포인트에는 주소, 바인딩 및 계약의 고유한 조합이 있어야 합니다.IIS에서 호스팅되는 서비스(즉, .SVC 파일)의 경우 끝점의 주소를 상대적인 URI를 확인하고 Visual Studio 또는 wsdl.exe 생성 클라이언트가 생성자에서 엔드포인트 이름을 지정하는지 확인하세요.

MSDN 기사도 참조하세요. 다중 엔드포인트.

다른 팁

서버나 클라이언트에 여러 끝점을 정의할 수 있습니다.

클라이언트에서 이를 수행하려면 다른 이름의 새 엔드포인트로 app.config 파일을 편집한 다음 새 클라이언트를 생성할 시기를 정의하면 됩니다.

예를 들어 클라이언트 앱에 다음과 같은 엔드포인트가 있는 경우:

<endpoint address="https://yourdomain.com/WCF/YourService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IYourService"
      contract="MessagingService.IYourService"  
      name="BasicHttpBinding_IYourService" />

전화 방법:

YourServiceClient client = new YourServiceClient();

새 이름으로 새 엔드포인트를 추가할 수 있습니다.

<endpoint address="https://yourotherdomain.com/WCF/YourService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IYourService"
      contract="MessagingService.IYourService"  
      name="BasicHttpBinding_IYourService_ENDPOINT2" />

다음 방법으로 전화할 수 있습니다.

YourServiceClient client = new YourServiceClient("BasicHttpBinding_IYourService_ENDPOINT2");

위에서는 도메인만 변경했는데 바인딩 구성 섹션을 새로 만들면 "bindConfiguration" 값만 변경하면 됩니다.

현재 IIS를 호스트로 사용하고 있다면 완전히 새로운 호스트를 생성해야 합니다. IIS는 TCP 바인딩이 아닌 HTTP만 지원합니다.그러나 WAS 또는 Windows 서비스를 사용하는 경우에는 새 net.tcp 엔드포인트만 생성하면 됩니다.

동일한 서비스에 대해 여러 엔드포인트를 사용할 수 있습니다.다음과 같은 방법으로 웹 구성을 구성할 수도 있습니다.

 <service name="MessagePatternDemo.Service1">  
 <endpoint name="ep1" address="/ep1" binding="basicHttpBinding" 
   contract="MessagePatternDemo.IService1"/>  
 <endpoint name="ep2" address="/ep2" binding="wsHttpBinding"  
   contract="MessagePatternDemo.IService1" />  
 <endpoint name="mex" contract="IMetadataExchange" address="mex"  
   binding="mexHttpBinding" />  
 </service>   
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top