Skip to Content
0
Jun 13, 2017 at 02:54 PM

Conection Error NIEHOST_UNKNOWN(-2) using cl_http_client=>create_by_url .

19504 Views Last edit Jun 13, 2017 at 06:11 PM 2 rev

Hi community.

I am creating a program to receiva data from rest link.

I have been following sdn Tutorials but i get error:

Connect to (name my host).com.br:80 failed: NIEHOST_UNKNOWN(-2).

I found some people in sdn with same error and i follow yours instructions but the problem continues.

This is my code and the error ocorred after lo_http_client->receive..

DATA: lv_http_url      TYPE string,

          lv_result        TYPE string,

          lo_ixml          TYPE REF TO if_ixml,

          lo_istream       TYPE REF TO if_ixml_istream,

          lo_streamfactory TYPE REF TO if_ixml_stream_factory,

          lo_document      TYPE REF TO if_ixml_document,

          lo_parser        TYPE REF TO if_ixml_parser,

          lo_http_client   TYPE REF TO if_http_client.

    wa_dest-lat_f  =  48451245 * ( -1 ).

    wa_dest-lng_f  =  22882449 * ( -1 ).

    wa_dest-lat_t  =  46225189 * ( -1 ).

    wa_dest-lng_t  =  23538130 * ( -1 ).

    CONDENSE:wa_dest-lat_f,

             wa_dest-lng_f,

             wa_dest-lat_t,

             wa_dest-lng_t .

* Prepare the url for the DistanceMatrix API From Address Coordinates and To Address Coordinates

    CONCATENATE

      'http://kkkkkxxxx.com.br/Roteirizador/RouteService.svc/rest/Solve?origem='
       wa_dest-lat_f ';'  wa_dest-lng_f ','

      '&destino=' wa_dest-lat_t ';' wa_dest-lng_t

      INTO lv_http_url .

* Get client from url

    CALL METHOD cl_http_client=>create_by_url

      EXPORTING

        url                = lv_http_url

      IMPORTING

        client             = lo_http_client

      EXCEPTIONS

        argument_not_found = 1

        plugin_not_active  = 2

        internal_error     = 3

        OTHERS             = 4.

    lo_http_client->send(

      EXCEPTIONS

       http_communication_failure = 1

       http_invalid_state         = 2 ).

    lo_http_client->receive(

      EXCEPTIONS

       http_communication_failure = 1

       http_invalid_state         = 2

       http_processing_failed     = 3 ).

    CLEAR lv_result .

    lv_result = lo_http_client->response->get_cdata( ).

    lo_ixml = cl_ixml=>create( ).

    lo_streamfactory = lo_ixml->create_stream_factory( ).

    lo_istream = lo_streamfactory->create_istream_string(

                                     lv_result ).

    lo_document = lo_ixml->create_document( ).

    lo_parser = lo_ixml->create_parser(

                           stream_factory = lo_streamfactory

                           istream        = lo_istream

                           document       = lo_document ).

I created sm59 conection with type G conection and the same error ocurred.

In chrome jason view it works.

What is wrong?

Thanks.