약 30 개의 wcf 서비스가 있으며 우리는 클라이언트의 요청을 배포하기 위해 wcf 라우터를 사용합니다. wcf 서비스는 Windows 서비스에 의해 호스팅됩니다. 클라이언트와 서비스를 같은 컴퓨터에 넣으면 클라이언트와 서비스가 서로 연락 할 수 있습니다. 그러나 다른 시스템에있을 때 클라이언트는 서비스에 접속할 수 없습니다. wcftestclient를 사용하여 서비스를 테스트했으며 서비스를 추가 할 수 없거나 추가 된 클라이언트 프로젝트를 사용하여 테스트하는 경우 서비스를 추가 할 수 없습니다. 서비스가 클라이언트와 다른 시스템에있는 경우 모든 개별 서비스는 net.pipe를 사용하고 라우터는 net.tcp를 사용합니다. 나는 2 주 동안이 일을 해왔으며 문제는 여전히 존재합니다. 아무도 그것으로 잘못 될 수있는 것을 지적 할 수 있습니까? 고마워요!wcf 라우터가 메타 데이터를 노출하지 않습니다.
최종 사용자가 서비스 서버 주소의 이름을 입력 할 수 있도록 설정 구성 파일이 있습니다. 포트 번호는 설정 파일에도 있습니다.
if (!this._issinglecomputer)
{
// now add protocol conversion router
Uri routerbaseaddress = new Uri(publicbaseaddress, "router");
_routingsvchost = new ServiceHost(typeof(RoutingService), routerbaseaddress);
_routingsvchostmex = new ServiceHost(typeof (RoutingService), new Uri(routerbaseaddress, "mex"));
// add the endpoint the router will use to receive service requests
// we use IDuplexSessionRouter to support a variety of one-way and two-way calls
_routingsvchost.AddServiceEndpoint(typeof(IDuplexSessionRouter), new NetTcpBinding(SecurityMode.None), "");
_routingsvchostmex.AddServiceEndpoint(typeof(IDuplexSessionRouter), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
// add routing config
RoutingConfiguration rc = new RoutingConfiguration();
// loop over all the hosted interfaces and add the entries to the routing table
foreach (IWcfServiceLibrary sl in wcfServiceLibraries)
{
foreach (IWcfServiceConfig config in sl.WcfServiceConfigs)
{
string routedservice = config.WcfService.ServiceClassName.Split('.').Last();
var contract = ContractDescription.GetContract(typeof(ISimplexDatagramRouter));
var client = new ServiceEndpoint(contract, new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress("net.pipe://localhost/" + routedservice));
var ea = new EndpointAddress(routerbaseaddress.AbsoluteUri.ToString() + "/" + routedservice);
rc.FilterTable.Add(new EndpointAddressMessageFilter(ea, false), new List<ServiceEndpoint>() { client });
}
}
_routingsvchost.Description.Behaviors.Add(new RoutingBehavior(rc));
_routingsvchostmex.Description.Behaviors.Add(new RoutingBehavior(rc));
_routingsvchost.Open();
_routingsvchostmex.Open();
LoggingService.Logger.Info(string.Format("It is now routing services at {0}", routerbaseaddress.AbsoluteUri));
}
나는 그것을 시도했지만 여전히 문제가있다. 구성 부분이 아닌 다른 곳에서 올 수 있는지 궁금합니다. –
metaDataUri가 코드에서 하나와 일치합니까? –