You are on page 1of 6

Integrata WebServices fr die NRW-Bank

Komplettbung Webservice Wetterbericht


Erkennen der WSDL
Einstieg ins Internet : http://www.webservicex.com/ws/default.aspx

Integrata WebServices fr die NRW-Bank

Proxy anlegen

Integrata WebServices fr die NRW-Bank

http://www.webservicex.net/globalweather.asmx?WSDL

Integrata WebServices fr die NRW-Bank

*&---------------------------------------------------------------------*
*& 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

type char20 default 'germany',


type char20 default 'leipzig'.

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

Integrata WebServices fr die NRW-Bank


lo_clientproxy->get_cities_by_country( exporting input
= ls_request_gcpc
importing output = ls_response_gcpc ).
get run time field t1.
write: / 'Time:', t1.
p_content = ls_response_gcpc-get_cities_by_country_result .
*&---------------------------------------------------------------------*
*&
Processing the string
*&---------------------------------------------------------------------*
data : moff type syst-tabix ,
moff1 type syst-tabix ,
len
type syst-tabix .
do .
find '<City>' in section offset moff of p_content ignoring case match offset moff .
if sy-subrc = 0 .
moff = moff + 6 .
find '</City>' in section offset moff of p_content ignoring case match offset moff1 .
len = moff1 - moff .
write : / p_content+moff(len) .
append p_content+moff(len) to city.
else.
exit.
endif.
enddo .
catch cx_ai_system_fault into lo_sys_exception.
*

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.

Integrata WebServices fr die NRW-Bank


get run time field t1.
write: / 'Time:', t1.
exit.
p_content = http_client->response->get_cdata( ).
get run time field t1.
replace all occurrences of '&lt;' in p_content with '<' .
replace all occurrences of '&gt;' in p_content with '>' .
*&---------------------------------------------------------------------*
*&
Processing the string
*&---------------------------------------------------------------------*
data : moff type syst-tabix ,
moff1 type syst-tabix ,
len
type syst-tabix .
do .
find '<City>' in section offset moff of p_content ignoring case match offset moff .
if sy-subrc = 0 .
moff = moff + 6 .
find '</City>' in section offset moff of p_content ignoring case match offset moff1 .
len = moff1 - moff .
write : / p_content+moff(len) .
append p_content+moff(len) to city.
else.
exit.
endif.
enddo .
loop at city assigning <city>.
clear http_url.

*
* 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 '&lt;' in p_content with '<' .
replace all occurrences of '&gt;' in p_content with '>' .
write: / p_content.
endloop.