(Mise à jour)CommunicationException lors de l'appel de service Web Silverlight 4
J'ai construit simple Silverlight 4 Bing Maps application en utilisant le modèle VS2010.
Dans la même solution que j'ai un projet ASP.NET avec un service Web simple: ContentService.asmx. Je cours tous les deux depuis ma machine locale pour l'instant.
je peux appeler le service Web à partir d'une page ASP.NET sans problème.
Cependant, essayez comme je pourrais, je ne peux pas obtenir Silverlight pour parler à lui.
J'essaie d'invoquer le service Web de Silverlight comme suit:
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());
}
Il doit générer le compte de l'objet de liste retournée mais il jette l'exception suivante:
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)
Je J'ai essayé divers fichiers crossdomain.xml et clientaccesspolicy.xml, rien ne fonctionne.
Toutes les suggestions très appréciées - merci.
Mise à jour
j'ai changé l'adresse de point final à 127.0.0.1 au lieu de localhost et cela a fonctionné!
EndpointAddress endPoint = new EndpointAddress ("http://127.0.0.1:49501/ContentService.asmx");
Quelqu'un sait pourquoi?