locked
trying to get Location(Longitude and Lattitude) using Bing URL(http://dev.virtualearth.net/REST/v1/Locations/) RRS feed

  • Question

  • Hi,

     

    I had been trying to get Location(Longitude and Lattitude) using Bing URL(http://dev.virtualearth.net/REST/v1/Locations/)

    from oracle SQL script . I am attaching the sample script which i was trying to get the details.

    DECLARE
    v_url1      varchar2(200) := 'http://dev.virtualearth.net/REST/v1/Locations/'; --address is to be appended in the middle of URL.So I have split URL in 2 parts
    v_url2      varchar2(200) := '?o=xml&&key=API_KEY';  ---api key
      v_address  varchar2(200) := 'LOCATION_ADDRESS';----any location address details
      v_req      utl_http.req;
      v_rsp      utl_http.resp;
      v_xml      varchar2(32767);
      v_lng      number;
      v_lat      number;
    BEGIN
      utl_http.set_proxy('CLIENT_PROXY', 'PROXY_URL');---Database client proxy details to be provided here
      v_req := utl_http.begin_request(v_url1 || utl_url.escape(v_address) || v_url2, 'GET', utl_http.HTTP_VERSION_1_1);
      v_rsp := utl_http.get_response(v_req);
      utl_http.read_text(v_rsp, v_xml);
      utl_http.end_response(v_rsp);
      select longitude, latitude
      into v_lng, v_lat
      from xmltable(
           '/Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1/ResourceSets/ResourceSet/Resources/Location/Point'
           passing xmlparse(document v_xml)
           columns longitude number path 'Longitude'
                 , latitude  number path 'Latitude'
           );
      dbms_output.put_line('Longitude = ' || v_lng);
      dbms_output.put_line('Latitude = ' || v_lat);
    END;

    ERROR:-xml parsing error.

     

    So please help me out in getting the locations for the address.

    Thanks,

    Bhanu.

     

    Wednesday, May 8, 2013 7:05 AM

Answers