2011-05-10 3 views
1

로컬 컴퓨터에 WCF 자체 호스팅 서비스를 만들고 Silverlight App이이 서비스에서 데이터 을 가져 와서 원격 서버로 보냅니다. 그것은 한 달 넘게 일했지만 갑자기 알려진 오류 clientaccesspolicy.xml을 해결하지 못했습니다. 디버그에 꽤 많은 시간을 보내고 난 후에, 나는 그것이 예를 http://2xx.1xx.223 이소 http://www.myserver.com를 들어, 주소 대신 도메인 addresss의 IP 주소로 변경되었습니다 원격 서버 때문에 실패 실현하지만, 도메인 주소 그래서 나는 할 수 없습니다 더 이상 을 사용 가능한 있지 않습니다 그것을 재현하고 정말로 실제적인 변화가 범죄인지를 확신하지 못한다.Silverlight WCF Self Hosting이 ClientAccessPolicy.xml을 찾지 못했습니다.

웹 서버 모두 자기 호스팅 서비스 내 dev에 컴퓨터에서 실행하고 나는 나의 브라우저에서 파일을 볼 수있는 경우는 여전히 잘 작동에 "http : // localhost를 : 8000/clientaccesspolicy.xml" 하지만 404 오류 입력 한 경우 "http : // my-machine-name : 8000/clientaccesspolicy.xml". 일부 블로그를 읽으면서 clientaccesspolicy.xml은 로컬 컴퓨터 의 80 포트에 위치해야하지만 어떻게해야하는지 알지 못하고 문제를 일으키는 지 알지 못합니다.

내 서비스 호스트는 다음과 같이 구성됩니다.

  string baseAddress = "http://localhost:8000"; 
     //Create a ServiceHost for the OPCService type and 
     //provide the base address. 
     _serviceHost = new ServiceHost(typeof(OpcService), new Uri(baseAddress)); 
     _serviceHost.AddServiceEndpoint(typeof(IOpcService), new BasicHttpBinding(), new Uri(baseAddress + "/OpcService")); 
     _serviceHost.AddServiceEndpoint(typeof(IPolicyRetriever), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior()); 

그리고 clientacceccpolicy.xml

인터페이스

 private Stream StringToStream(string result) 
    { 
     WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml"; 
     return new MemoryStream(Encoding.UTF8.GetBytes(result)); 
    } 

    public Stream GetSilverlightPolicy() 
    { 
     string result = @"<?xml version=""1.0"" encoding=""utf-8""?> 
     <access-policy> 
     <cross-domain-access> 
     <policy> 
      <allow-from http-request-headers=""*""> 
      <domain uri=""*""/> 
     </allow-from> 
     <grant-to> 
      <resource path=""/"" include-subpaths=""true""/> 
     </grant-to> 
    </policy> 
    </cross-domain-access> 
    </access-policy>"; 
     return StringToStream(result); 
    } 

을 통해 사용되는 실버 라이트 클라이언트가 쉽게 웹 방법을 얻을 수 ServiceReferences.ClientConfig 하지 않고 있지만, 서비스에 refrence와 프록시 서비스를 사용합니다.

 public class ServiceProxy 
{ 
    private const string ServiceEndPoint = "http://localhost:8000/OpcService"; 
    private static Uri _serviceMap = new Uri(ServiceEndPoint, UriKind.Absolute); 

    public static T GetProxyFor<T>() 
    { 
     return new ChannelFactory<T>(new BasicHttpBinding(), new EndpointAddress(_serviceMap)).CreateChannel(); 
    } 

    [Export] 
    public IOpcService SyrOpcService 
    { 
     get { return GetProxyFor<IOpcService>(); } 
    } 

    public static SYR.HMI.OpcProxy.ServiceReference.OpcServiceClient GetProxy() 
    { 
     return new SYR.HMI.OpcProxy.ServiceReference.OpcServiceClient(); 
    } 
} 

나는 여기에 많은 스레드를 읽고 구글하지만 확실히 내 추천하고 나에게 여전히 모호 어느 문제, IP 주소 변경 또는 clientaccesspolicy 파일 위치입니다.

친절한 조언을 부탁드립니다. 미리 감사드립니다.

HK.Lee

+0

** StackOverflow에 오신 것을 환영합니다! ** –

답변

1

I 2 개 작은 방법 작은 SL 테스트 애플리케이션을 만들어 http://ipv4.fiddler:8000 대신에 http://locahost:8000 ClientConfig 의 엔드 포인트 주소를 변경.

Fiddler는 127.0.0.1 iso localhost, 에서 clientaccesspolicy.xml을 찾았으므로 SL 클라이언트 프록시 주소를 localhost 대신 127.0.0.1로 변경했습니다. 모든 것이 정상적으로 작동합니다.

IP 주소 vc 도메인 이름에서 xap을 다운로드하면 localhost가 작동하지 않는 것이 재미 있습니다. 세부 사항을 모르지만 누구나 조언을 해줍니다.

HK.lee