none
How to call a web service from within a Map App RRS feed

  • Question

  • I have a Map App I’m trying to write and it’s all going fine using the examples from the SDK, but when I try to make a WCF service call to an external web service I’m getting a CommunicationException.

    Here’s the exception info:

    System.ServiceModel.CommunicationException was unhandled by user code

      Message=""

      StackTrace:

           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 MapAppTutorial.Elevation_Service.Elevation_ServiceSoapClient.Elevation_ServiceSoapClientChannel.EndgetElevation(IAsyncResult result)

           at MapAppTutorial.Elevation_Service.Elevation_ServiceSoapClient.MapAppTutorial.Elevation_Service.Elevation_ServiceSoap.EndgetElevation(IAsyncResult result)

           at MapAppTutorial.Elevation_Service.Elevation_ServiceSoapClient.OnEndgetElevation(IAsyncResult result)

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

      InnerException: System.Net.WebException

           Message=""

           StackTrace:

                at pilationRelaxationsAttribute.EndGetResponse(IAsyncResult mscorlib)

                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(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 pilationRelaxationsAttribute.EndGetResponse(IAsyncResult mscorlib)

                InnerException: System.Security.SecurityException

                     Message=Security error.

                     StackTrace:

                          at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

                          at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)

                          at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)

                     InnerException:

    Is it allowed for a Map App to call out to an external web service?

    I’m trying to use http://gisdata.usgs.net/XMLWebServices/TNM_Elevation_Service.asmx?op=getElevation to supply elevation data in Entities I’m adding to my layer on a map.

    I’ve gotten the web service to work in standalone applications, but not in my Map App.  Here’s the Soap Client configuration I’m using (runtime, not in a config file):

                BasicHttpBinding binding = new BasicHttpBinding(

                    Application.Current.Host.Source.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase)

                    ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None);

                binding.MaxReceivedMessageSize = int.MaxValue;

                binding.MaxBufferSize = int.MaxValue;

                return new Elevation_Service.Elevation_ServiceSoapClient(binding, new EndpointAddress(

                    new Uri("http://cumulus.cr.usgs.gov/xmlwebservices2/elevation_service.asmx", UriKind.Absolute)));

    Is there any guidance I can use to help me configure things so that I can access this web service from my Map App?

    Thanks,

    Allen


    Allen Denver - Visual Studio Development

    Friday, July 27, 2012 5:56 PM

Answers

  • You can access an external Web Service from map apps. The communication issue may be related to the service you are accessing or with your SOAP reference.

    http://rbrundritt.wordpress.com

    Friday, July 27, 2012 6:36 PM