2010-03-28 208 views
0

我目前正在開發一個Silverlight 3項目,我正在使用2臺機器來測試它。WCF服務異常

「harbinger」是運行Win7 + IIS的Web服務器。我已經將該網頁和WCF webservice部署到該機器。

我已經進入以下網址在我的瀏覽器:

http://harbinger:43011/UserService.svc 
http://harbinger:43011/UserService.svc?wsdl 

,並獲得網頁加載內容的預期兩個

接下來我決定進去看看,我可以從我的機器調用web服務,我已經添加了ServiceReference,執行了調用其中一種方法和.... BOOM:

System.ServiceModel.CommunicationException was unhandled by user code 
    Message="An error occurred while trying to make a request to URI 'http://harbinger:43011/UserService.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 Energy.USR.UserServiceClient.UserServiceClientChannel.EndGetAllUsers(IAsyncResult result) 
     at Energy.USR.UserServiceClient.Energy.USR.UserService.EndGetAllUsers(IAsyncResult result) 
     at Energy.USR.UserServiceClient.OnEndGetAllUsers(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.<EndGetResponse>b__4(Object sendState) 
       at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState) 
      InnerException: 

有人可以解釋發生了什麼嗎?我需要做什麼來避免這種情況?

回答