Google Webservice aus Abap heraus

WAS, Netweaver, Fiori

Google Webservice aus Abap heraus

Postby Vito4530 » Tue Aug 16, 2005 4:10 pm

Hallo,
hat schon mal jemand probiert, den Google-Webservice aus Abap heraus aufzurufen und die Response auszuwerten?
Hab schon etwas mit der Klasse CL_HTTP_CLIENT experimentiert, komme aber nicht so richtig weiter.
mfg
Stefan
Vito4530
..
..
 
Posts: 11
Joined: Tue Aug 16, 2005 4:10 pm

Postby Alva1590 » Tue Aug 16, 2005 6:11 pm

Wenn Du das per HTTP auswerten willst, hast Du Dir aber ziemlich was vorgenommen.
Ich würde mal im Paket SOAP (SE80) nachschauen, ob Du dort was brauchbares findest. Damit sollte sich ja im Grunde ein Webservice-Response entsprechend auswerten lassen. Request sollte damit auch möglich sein.
Alva1590
.....
.....
 
Posts: 4387
Joined: Mon Dec 02, 2002 3:01 pm

Postby Vito4530 » Wed Aug 17, 2005 11:59 am

Hallo,
ich arbeite mit cl_http_client und bekomme auch schon eine Response. Allerdings habe ich Probleme mit der Parametrisierung des Requests. Ich bin mir nicht ganz sicher wie ich die Url aufzubauen hab.
mfg
Stefan
Vito4530
..
..
 
Posts: 11
Joined: Tue Aug 16, 2005 4:10 pm

Postby Vito4530 » Wed Aug 17, 2005 4:27 pm

Hallo,
villeicht hilt es jemand, wenn ich mein Coding veröffentliche. Es ist nicht ganz sauber. Ist halt nur Testcoding. Den Key in der Url habe ich weggelassen.
Die Response wird im Html-Viewer ausgegeben


report zll_testws line-size 1023 .


data: l(256),
i type i.
data: o_cont type ref to cl_gui_custom_container,
o_hv type ref to cl_gui_html_viewer,
ok_code type syucomm.

data: client type ref to if_http_client,
url type string.

****Build the Sending URL
concatenate
'http://api.google.com/search/beta2'
`&key=`
` ?!?!?`
`&q=`
`Star Wars`
into url.

****Create the HTTP client
call method cl_http_client=>create_by_url
exporting
url = url
* ssl_id = 'page_srv-ssl_id'
proxy_host = 'proxy'
proxy_service = '8080'
importing
client = client
exceptions
others = 1.

***!!!!!!!!!!!!!!!
****Set the Request type to GET
client->request->set_header_field( name = '~request_method'
value = 'GET' ).

****Make the call
client->send( ).
***!!!!!!!!!!!!!!!!!!!!
****Receive the Response Object
call method client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.

****Get the response content in Character format
data: p_content type string.
p_content = client->response->get_cdata( ).



set screen 0100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
data: ll(256),
lt like table of ll,
li type i,
m type i,
x_do type i,
x_rest type i.
m = 0.
i = 0.
m = strlen( p_content ).
x_rest = m mod 256.
x_do = m div 256.
*if x_rest > 0.
add 1 to x_do.
*endif.
if not p_content is initial.
do x_do times.
subtract 1 from x_do.
if x_do <= 1.
if x_rest = 0.
exit.
endif.
li = x_rest.
else.
li = 256.
endif.
ll = p_content+i(li).
add 256 to i.
append ll to lt.
if x_do = 1. exit. endif.

enddo.
endif.

set pf-status '0100'.
* SET TITLEBAR 'xxx'.
append p_content to lt.
create object o_cont
exporting
container_name = 'CC'.

create object o_hv
exporting
parent = o_cont.

call method o_hv->load_data
importing
assigned_url = hurl
changing
data_table = lt.

call method o_hv->show_url
exporting
url = hurl.

endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.

if sy-ucomm = 'BACK'.
leave to screen 0.
endif.
endmodule. " USER_COMMAND_0100 INPUT
Vito4530
..
..
 
Posts: 11
Joined: Tue Aug 16, 2005 4:10 pm

Postby Jonathan5279 » Wed Nov 30, 2005 2:11 pm

Hi @ all,

steht irgendwo beschrieben, wie die Klasse cl_http_client tickt? (also die Methoden).

Da ich auch gerne einen SOAP Request verschicken möchte und dann davon den Request auslesen / speichern möchte!

Leider bin ich noch neu in dem Gebiet und verstehe fast nix :-(


Kann mir da jemand paar Tipps geben, oder vielleicht en Beispiel Quellcode?

Gruß Xell
Jonathan5279
.
.
 
Posts: 1
Joined: Wed Nov 30, 2005 2:11 pm


Return to Web Application Server

Who is online

Users browsing this forum: No registered users and 8 guests