Skip to Content
0

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

Jun 13, 2017 at 02:54 PM

1.2k

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Kiran Prasad Garudas Jun 20, 2017 at 03:43 PM
0

Hi,

SAP basis needs to install the SSL certificate in the system

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Kiran now it works fine .

0
Syam Babu Jun 14, 2017 at 10:26 AM
0

Hi Ronaldo,

Could you please check Proxy settings in SICF level for your system sometime it might be the reason would say the unknown host

Thanks,

Syam

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Syam i don´t have any proxy configuration.

proxy-sicf.png (12.2 kB)
0
Isaias Freitas
Jun 14, 2017 at 06:14 PM
0

Hello Ronaldo,

The error NIEHOST_UNKNOWN means that the hostname your are accessing ("name my host.com.br") is not known to the server where SAP is running.

This is a DNS issue.

You can involve your server / DNS / network team(s), so they fix this.

Regards,

Isaías

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for reply Isaias

I talked with basis team and they solved it , now after pass by lo_http_client->receive

the sy-subrc = 0.

and i used this code to get data:

lv_bin            TYPE xstring,
lv_bin = lo_http_client->response->get_data( ).

But using this code to transform data:
 DATA: lt_data2  TYPE TABLE OF x255,

          l_len     TYPE i,

          ls_string TYPE string.

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

      EXPORTING

        buffer        = lv_bin

      IMPORTING

        output_length = l_len

      TABLES

        binary_tab    = lt_data2.





    CALL FUNCTION 'SCMS_BINARY_TO_STRING'

      EXPORTING

        input_length = l_len

      IMPORTING

        text_buffer  = ls_string

      TABLES

        binary_tab   = lt_data2.
Is returned it:
3C68746D6C3E3C686561643E3C7469746C653E4170706C69636174696F6E20536572766572204572726F723C2F7469746C653E0D0A3C7374796C6520747970653D22746578742F637373223E0D0A626F6479207B20666F6E742D66616D696C793A20617269616C2C2073616E732D73657269663B7D0D0A3C2F7374796C653E0
67696E6865696768743D223022206D617267696E77696474683D2230223E0D0A3C7461626C65206865696768743D223631222077
How can i get it and transform in my jason data to input n a internal table?


0
Ronaldo Aparecido Jun 20, 2017 at 01:14 PM
0

I converted this receive data and the data converted is :

SSL handshake with marcozerogis.com.br:443 failed: SSSLERR_PEER_CERT_UNTRUSTED (-102)#The peer's X.509 Certificate (chain) is untrusted##SapSSLSessionStartNB()==SSSLERR_PEER_CERT_UNTRUSTED# SSL:SSL_read() failed (536872221/0x2000051d)# => "Failed to ve

somebody knows what hepened?

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Ronaldo,

This would be a different issue.

It is best to post new questions when you have new issues, so both issues do not get mixed up in the thread.

Anyway, check out this WIKI page.

Regards,

Isaías

1

Thanks Isaias.

0

You're welcome!

0