Professional Documents
Culture Documents
Proxy anlegen
http://www.webservicex.net/globalweather.asmx?WSDL
*&---------------------------------------------------------------------*
*& Report ZSMS_PROXY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zcountry_proxy.
data:
p_content type string, t1(6) type i,
* Reference variables for proxy and exception class
lo_clientproxy
type ref to zbc_co_global_weather_soap,
lo_sys_exception
type ref to cx_ai_system_fault,
city type table of string,
* Structures to set and get message content
ls_request_gcpc
type zbc_get_cities_by_country_soa1,
ls_response_gcpc
type zbc_get_cities_by_country_soap.
parameters: country
city1
ls_request_gcpc-country_name
= country.
*ls_request-controller-field = 'C
try.
* create proxy client
get run time field t1.
create object lo_clientproxy
exporting
logical_port_name = 'ZBC_CO_GLOBAL_WEATHER_SOAP'.
* do synchronous client proxy call
Error handling
*&---------------------------------------------------------------------*
*& Report Z_COUNTRY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report
z_country.
*&---------------------------------------------------------------------*
*&
Selection Screen
*&---------------------------------------------------------------------*
parameters : p_cnt type t005t-landx .
*&---------------------------------------------------------------------*
*&
Types and Data
*&---------------------------------------------------------------------*
data: city type table of string, t1 type i.
data: http_client
type ref to if_http_client ,
http_url
type string
,
p_content
type string
,
citylast
type string
.
field-symbols: <city> type string.
*&---------------------------------------------------------------------*
*&
Start of Selection
*&---------------------------------------------------------------------*
start-of-selection .
* Build the url string based on input
concatenate 'http://www.webservicex.net/globalweather.asmx'
'/GetCitiesByCountry?CountryName='
p_cnt
into http_url .
* Creation of new IF_HTTP_Client object
get run time field t1.
call method cl_http_client=>create_by_url
exporting
url
= http_url
importing
client
= http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error
= 3
others
= 4.
* Send the request
http_client->send( ).
* Reterive the result
call method http_client->receive
exceptions
http_communication_failure =
http_invalid_state
=
http_processing_failed
=
others
=
1
2
3
4.
*
* Wetterbericht zu allen Stdten
* ===============================
concatenate 'http://www.webservicex.net/globalweather.asmx'
'/GetWeather?CityName='
<city>
'&CountryName='
p_cnt
into http_url.
* creation of new if_http_client object
call method cl_http_client=>create_by_url
exporting
url
= http_url
importing
client
= http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error
= 3
others
= 4.
* Send the request
http_client->send( ).
* Reterive the result
call method http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state
= 2
http_processing_failed
= 3
others
= 4.
clear p_content.
p_content = http_client->response->get_cdata( ).
replace all occurrences of '<' in p_content with '<' .
replace all occurrences of '>' in p_content with '>' .
write: / p_content.
endloop.