2009-10-10 5 views
1

Silverlight 프로젝트에 추가하고 Visual Studio의 ASP.NET Dev Server에서 호스팅하는 WCF 서비스가 있습니다. 그러나 tyring은 그것을 실행하는 내가받을 다음과 같은 오류 :WCF 서비스 및 Silverlight 3 디버그

 
System.ServiceModel.CommunicationException was unhandled by user code 
    Message="An error occurred while trying to make a request to URI 'http://localhost:51547/WCFService1/Service.svc'. 

This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details." 
    StackTrace: 
     at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) 
     at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) 
     at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) 
     at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result) 
     at niki_lanik_latestnews.WCFXmlOps.IxmlLoadClient.IxmlLoadClientChannel.EndLoadArticleFromXML(IAsyncResult result) 
     at niki_lanik_latestnews.WCFXmlOps.IxmlLoadClient.niki_lanik_latestnews.WCFXmlOps.IxmlLoad.EndLoadArticleFromXML(IAsyncResult result) 
     at niki_lanik_latestnews.WCFXmlOps.IxmlLoadClient.OnEndLoadArticleFromXML(IAsyncResult result) 
     at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) 
    InnerException: System.Security.SecurityException 
     Message="" 
     StackTrace: 
      at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) 
      at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 
      at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) 
     InnerException: System.Security.SecurityException 
      Message="Security error." 
      StackTrace: 
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 
       at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClass5.b__4(Object sendState) 
       at System.Net.Browser.AsyncHelper.c__DisplayClass2.b__0(Object sendState) 
      InnerException: 

그것은 호스팅 아니에요이 같은 프로젝트에, 그래서이 원인을 모르겠어요으로 크로스 도메인? 누구 아이디어?

토니

UPDATE 아래

Web.config의 내 바인딩 설정은 다음과 같습니다

 <bindings> 
     <basicHttpBinding> 
      <binding name="basicHTTP" 
      receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" 
      closeTimeout="00:10:00" 
      openTimeout="00:03:00" 
      maxBufferSize="100000" 
      maxReceivedMessageSize="100000" 
      transferMode="StreamedResponse"> 

    </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="mexBehavior" name="LoadXMLService.XMLOperations"> 
      <endpoint address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="basicHTTP" 
       contract="LoadXMLService.IxmlLoad" /> 
     </service> 
    </services> 

이 서비스는 Silerlight 3 프로젝트에 다운로드 & 업로드 파일을 가정한다 기억하십시오.

+0

clientaccesspolicy.xml을 Inetpub의 wwwroot에 추가했습니다. 그게 ASP.NET dev에 서버 위치 모르겠어요? 파일에 액세스하려고하면 Fiddler2에서이 오류가 발생합니다. [Fiddler] localhost에 연결하지 못했습니다.
예외 텍스트 : 대상 컴퓨터가 적극적으로 거부했기 때문에 연결할 수 없습니다 :: 1 : 51547 –

+0

localhost : 51547을 사용하는 경우 Visual Studio 기본 제공 웹 호스트를 사용하고 있다고 생각합니다. 귀하의 프로젝트에는 실버 프로젝트와 웹 프로젝트가 있습니까? 교차 도메인 파일을 웹 프로젝트 (예 : Web.Config와 같은 수준)에 넣을 수 있습니다. –

+0

나는 그것을 거기에 넣었으나 여전히 나에게 똑같은 오류를 준다. Domain Uri 및 Http 요청 헤더를 입력 할 필요가 없습니까? 그래도 나에게 가이드 라인을 줄 수 있을지 모르겠다. –

답변

2

적어도 "문제 해결 단계"로 다음 내용으로 웹 사이트 루트에 "clientaccesspolicy.xml"파일을 추가하는 것이 좋습니다. 이 오류는 도움이 될 것이라고 제안하는 것 같습니다.

Silverlight는 교차 포트 호출이 교차 도메인 (즉, localhost : 51547 및 localhost : 4000은 다른 도메인 임)으로 간주합니다.

<?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> 

[편집]

음, 우선이 작동하려면

은 호스팅 서비스에 직접 연결 할 수있다, 그래서 내가 우연히 문제의 몇 가지 아이디어를 던질거야 .

서비스에이 회선이 있습니까?

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
public class MyService 
{ 
} 

이 줄은 Web.Config에 있습니까?

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"> 
</system.serviceModel>