on 08-05-2009 5:02 PM
Hello,
I would like to call a specific amazon-services via http://webservices.amazon.de/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=myAC&AssociateTag=a... but this is not a web service (I think).
Could someone tell me have to call the URL and how I can handle the response? With a web service or bapi it wouldnu2019t be a problem but I donu2019t know to handle thisu2026
Can someone help me out with this?
Thx, Vanessa
This is not directly a Web Dynpro ABAP question. You should ask this in one of the general ABAP forums. I can tell you that you should look into the CL_HTTP_CLIENT class and search for resources on calling REST based services from ABAP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vanessa.
I send you an explample that it is running perfectly. I am calling a web service from a web dynpro application using http_client. Obviusly the parameters (such as de strXML) depends on your application.
DATA: http_client TYPE REF TO if_http_client.
DATA: str_webservice type string,
str_uri type string,
w_result TYPE string ,
r_url TYPE string.
DATA: result_tab TYPE TABLE OF string.
DATA: strXML TYPE string.
str_webservice = 'http://172.29.100.22/WS_Busqueda_rrhh/ServicioBusqueda.asmx'.
str_uri = 'http://172.29.100.22/WS_Busqueda_rrhh/ServicioBusqueda.asmx/Busqueda'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = str_webservice
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = '~request_method'
VALUE = 'POST'.
CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = '~request_uri'
VALUE = str_uri.
CALL METHOD http_client->REQUEST->SET_FORM_FIELD
EXPORTING
NAME = 'strXML'
VALUE = strXML.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR w_result .
w_result = http_client->response->get_cdata( ).
http_client->response->GET_COOKIES( changing cookies = cookies ).
REFRESH result_tab .
SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE
result_tab .
Greetings
Hi Manolo,
I've a similar problem with my WDA. I need to call an external service that isn't a web service. Then I need to retrieve back parameters from this service after user interaction. I'm trying to use the code below:
data: http_client type ref to if_http_client.
data: str_webservice type string,
str_uri type string,
w_result type string ,
r_url type string.
data: result_tab type table of string.
data: strxml type string.
str_webservice = 'http://....'.
call method cl_http_client=>create_by_url
exporting
url = str_webservice
importing
client = http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
call method http_client->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.
*call method http_client->request->set_form_field
*exporting
*name = 'strXML'
*value = strxml.
call method http_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
call method http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
clear w_result .
w_result = http_client->response->get_cdata( ).
I receive this error in resul_tab:
<H2><b>404 Resource not found</b></H2><br>Partner not reached<br><br><hr>
<tr><td>Error:</td><td>-20</td></tr>
<tr><td>Version:</td><td>7000</td></tr>
<tr><td>Component:</td><td>ICM</td></tr>
<tr><td>Module:</td><td>icxxconn.c</td></tr>
<tr><td>Detail:</td><td>Connection request from (14/405/0) to host....service: 80 failed (NIECONN_REFUSED) ....</td></tr>
Have you got any idea?
Thanks in adavance
Federica
Hi Thomas,
I've a similar problem. I need to call an external application from my wda and retrieve some return data after user interaction.
I'm using this code and it works fine but I need to show http body response on page in the browser. There is a way to do it?
data: http_client type ref to if_http_client.
data: str_webservice type string,
w_result type string ,
r_url type string,
wf_user type string,
wf_password type string .
data: result_tab type table of string.
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
str_webservice = 'http://....'.
call method cl_http_client=>create_by_url
exporting
url = str_webservice
proxy_host = '139.128.81.17'
proxy_service = '8080'
importing
client = http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
http_client->propertytype_logon_popup = http_client->co_disabled.
wf_user = user.
wf_password = password .
proxy server authentication
call method http_client->authenticate
exporting
proxy_authentication = 'X'
username = wf_user
password = wf_password.
call method http_client->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.
call method http_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
call method http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
clear w_result .
w_result = http_client->response->get_cdata( ).
refresh result_tab .
split w_result at cl_abap_char_utilities=>cr_lf into table
result_tab .
The only thing in Web Dynpro that could possibly display the raw HTML/JavaScript returned from an external website would be the iFrame UI element. Be cautious however because the iFrame is deprecated in 7.0 and 7.01 and does disappear at certain SP level. It returns and is supported once again in 7.02. If you aren't afraid of the deprecation, then you can take the returned content from the website and load it into the ICM cache, generate a temporary URL to the cached object and display it in the iframe. However knowing how typical HTML content is built, it probably contains relative paths that will be broken by displaying it from anywhere but its source.
Its kind of odd to use the CL_HTTP_CLIENT in such a way. If you just want to display external content, then why not just navigate to it, open the URL in a new window or iView, or use the URL from the CL_HTTP_CLIENT call in the iFrame UI element. There seems to be many other, better approaches.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.