2010-12-13 8 views
1

からWebサービスを呼び出すときに(更新)て、CommunicationExceptionのSilverlight 4

私はVS2010のテンプレートを使用して、簡単なSilverlightの4 Bing Mapsのアプリを構築しました。

私は単純なWebサービスであるASP.NETプロジェクトを持っています:ContentService.asmx。

私は現在ローカルマシンから両方を実行しています。

ASP.NETページ内から問題なくWebサービスを呼び出すことができます。

しかし、私が思うように、私はSilverlightにそれを話すことができません。

私は次のようにシルバーからWebサービスを呼び出すためにしてみてください。

public BingMapAppPanel() 
{ 
    InitializeComponent(); 

    BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); 

    EndpointAddress endPoint = new EndpointAddress("http://localhost:49501/ContentService.asmx"); 

    ContentServiceSoapClient contentService = new ContentServiceSoapClient(binding, endPoint); 

    contentService.GetAllCategoriesCompleted += new EventHandler<GetAllCategoriesCompletedEventArgs>(contentService_GetAllCategoriesCompleted); 
    contentService.GetAllCategoriesAsync(); 
} 

void contentService_GetAllCategoriesCompleted(object sender, GetAllCategoriesCompletedEventArgs e) 
{  
    MessageBox.Show(e.Result.Count.ToString()); 
} 

それはすべき返されたListオブジェクトの出力カウントではなく、それは、次の例外がスローされます。

Bing Maps has encountered an exception. Please press CTRL+C to copy the error message text. 

ErrorSource: Unhandled Exception. 

ErrorType: System.Reflection.TargetInvocationException 

ErrorMessage: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. 

ErrorCallStack: 
    at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 

    at BingMapApp.Content.GetAllCategoriesCompletedEventArgs.get_Result() 

    at BingMapApp.BingMapAppPanel.contentService_GetAllCategoriesCompleted(Object sender, GetAllCategoriesCompletedEventArgs e) 

    at BingMapApp.Content.ContentServiceSoapClient.OnGetAllCategoriesCompleted(Object state) 

InnerType: System.ServiceModel.CommunicationException 

InnerMessage: 

InnerCallStack: 
    at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult 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 BingMapApp.Content.ContentServiceSoapClient.ContentServiceSoapClientChannel.EndGetAllCategories(IAsyncResult result) 

    at BingMapApp.Content.ContentServiceSoapClient.BingMapApp.Content.ContentServiceSoap.EndGetAllCategories(IAsyncResult result) 

    at BingMapApp.Content.ContentServiceSoapClient.EndGetAllCategories(IAsyncResult result) 

    at BingMapApp.Content.ContentServiceSoapClient.OnEndGetAllCategories(IAsyncResult result) 

    at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) 

私は」さまざまなcrossdomain.xmlとclientaccesspolicy.xmlファイルを試しましたが、何も動作しません。

ご意見ありがとうございます。ありがとうございます。

更新

私は、localhostの代わりに127.0.0.1にエンドポイントアドレスを変更し、それが働きました!

EndpointAddress endPoint = new EndpointAddress( "http://127.0.0.1:49501/ContentService.asmx");

誰でも知っていますか?

答えて

1

このWCFサービスをホストするソリューションに別のWebプロジェクトを追加したと思いますか?可能であれば、Silverlightアプリケーションが元のドメインとは別のドメインのサービスと通信しようとしているクロスドメインの問題が考えられます(可能な場合は、WCFをホストしますあなたがまだ問題を解決している場合(またはそうでない場合)は、Fiddlerを使って舞台裏で何が起こっているのかを調べてみてください。 、フィドラーは、(それがローカルホストのトラフィックを無視します)しかし、トラフィックをピックアップしてもらうipv4.fiddlerとあなたのURIのlocalhostへの参照を交換してください。このことができます

希望...

クリス・アンダーソン

ために、

注:投稿する前にあなたの編集が表示されませんでした。それは奇妙なものです!

関連する問題