Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

HTTP Call to Google Geocode

$
0
0

Hi,

 

I'm trying to make an HTTP call to the Google geocode service in an 6.20 client.

 

The URL for the call is http://maps.googleapis.com/maps/api/geocode/xml?address=1,STREET,CITY,POSTCODE,&client=gme-ourclient&sensor=false&signature=fancygooglesignature=

 

(I've change the client and the signature to rubbish for the example)

 

I've put this URL (with the correct client and signature) in a web browser or a SAP html viewer it works fine and returns the required geocode.

 

However, If I run it as a HTTP client call in a program it fails as google doesn't understand the client/signature pairing. The signature is getting changed somewhere in the call.

 

My code is

* Creation of new IF_HTTP_Client object  CALL METHOD cl_http_client=>create_by_url    EXPORTING      url                = l_http_url    IMPORTING      client             = l_http_client    EXCEPTIONS      argument_not_found = 1      plugin_not_active  = 2      internal_error     = 3      OTHERS             = 4.

* Check this was successful
  CHECK : sy-subrc IS INITIAL.

* Set the request method
  l_http_client->request->set_header_field( name  = '~request_method'                                            value = 'GET' ).

* Set the header
  l_http_client->request->set_header_field( name  = 'Content-Type'                                            value = 'text/xml; charset=utf-8' ).

* Send the request
  l_http_client->send( ).

* Reterive the result
  CALL METHOD l_http_client->receive    EXCEPTIONS      http_communication_failure = 1      http_invalid_state         = 2      http_processing_failed     = 3      OTHERS                     = 4.

content = l_http_client->response->get_cdata( ).

 

I've tried turing of encoding and compression, passing the parameters individually into the object but nothing works.

 

However, if I try the public geocode URL ( http://maps.google.com/maps/api/geocode/xml?address=1,STREET,CITY,POSTCODE,&sensor=false) it works fine.

 

Any ideas how to use the URL with the signature?


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>