I am getting exception whenever I am trying to call FindServiceSoap.FindAddress method of Map Point web service. Exception is "Root element is missing"
I am consuming web service through proxy and I added
FindServiceSoap.Proxy = new WebProxy("192.168.2.5:8080", false, null, new System.Net.NetworkCredential("UserName", "Password", "Domain"));
Even I enabled WSE3.0 still I am facing same error.
My code sample is...................
private void MakeAddress() { Address objAddress = new Address();
FindAddressSpecification objFindAddressSpecification = new FindAddressSpecification(); FindServiceSoap objFindServiceSoap = new FindServiceSoap();
//UserId and Password are in web.config file objFindServiceSoap.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["UserID"], ConfigurationManager.AppSettings["Password"]); objFindServiceSoap.PreAuthenticate = true; //to bypass bypass firwall settings we have to assign proxy object
//Please remove this if you are not using Proxy //---------------------------//
objFindServiceSoap.Proxy = new WebProxy("192.168.2.5:8080", false, null, new System.Net.NetworkCredential("prasham.ajmera", "agt@agt123", "ecomdomain.ag")); //---------------------------//
objAddress.CountryRegion = "US"; objAddress.PrimaryCity = "New York"; objFindAddressSpecification.DataSourceName = "MapPoint.NA"; objFindAddressSpecification.InputAddress = objAddress; FindOptions objFindOptions = new FindOptions(); FindRange objFindRange = new FindRange(); objFindRange.Count = 3; objFindRange.StartIndex = 1; objFindOptions.Range = objFindRange; objFindAddressSpecification.Options = objFindOptions; //You will to connect to server at this point //Getting error at this line objFindResults = objFindServiceSoap.FindAddress(objFindAddressSpecification); Location objLocation = new Location();
views = new ViewByHeightWidth[1]; views[0] = objFindResults.Results[0].FoundLocation.BestMapView.ByHeightWidth; }
I too have faced this problem many times while using Mapoint Service and found that this is one crazy problem when you are working behind a proxy or firewall. I tested the sample on a machine outside proxy and firewall and it just works perfect! Try it out.