Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Web services -sample code

Former Member
0 Likes
1,021

Hi Friends,

I have a scenario where abap code has to access a wsdl file .I am tryng to create a PROXY from SE80, but its not taking the url which am providing.and throwing me an error.

CAn anyone please list me the steps to create the proxy and provide me a valid WSDL link along with a sample program to access it from ABAP??

I would be hightly thankful if u can provide me the steps for accesing a wsdl file aong with the sample file.

Please very urgent

Thanks a lot in advance

4 REPLIES 4
Read only

Former Member
0 Likes
693

Hi,

Can any body give the guidelines for how to proceed with this kind of requirment.

Thanks,

Raghav

Read only

mnicolai_77
Active Participant
0 Likes
693

hi,

i try to explain how to create a web services and how to call it from abap.

to create a web services is very simple,

you have to create a RFC function module after that go to

UTILITY->MOREUTILITY->Create web services-> from the function module

now it start a wizard to create the web services.

>1 - step: Create Services

Service Definition - here you insert External name of a virtual end point (its key sensitive)

Short Text - little description

>_2 - step Choose endpoint_

Name Mapping - If the flag 'Mapping of Names' is set, the existing labels for the endpoint are copied. Only the beginning letters are uppercase letters and underscores are >removed.

>3 - step: Configure Services

>Profile : here you can choose if you have a basic autorizzation or Secure autorizzation

>Release Service for Runtime : If you select this checkbox, the Web Service is immediately released when completed. If the field is not selected, the Service can be released later in transaction >WSCONFIG ( Release Web Services for SOAP Runtime ).

>4 - step: Complete. assing a package (e.g. $TMP)

Now in the transaction SE80 under package $TMS ypou find an new folder called Enterprice service

here u find your web services doble click . here u can change the name of every singel field the activate.

now go to transaction sicf and under /default_host/sap/bc/srt/rfc/sap/ you find your web services.

to call a web services in no so simple

there is an include released from 4.7 used to call a web services using SOAP message. In this class you can fine all the classes to create message here i attach an example that i create for calling a web services of a travel agency for creating a trip.

>data: response type zptf.

data: osoap type ref to csoapdocument.

data: isoap type ref to isoapserialize.

data: otransp type ref to csoaptransporthttp.

data: ofault type ref to csoapfault.

data: trnex type ref to csoapexceptiontransport.

data: fltex type ref to csoapexceptionfault.

data: fmtex type ref to csoapexceptiondocumentformat.

data: usgex type ref to csoapexceptionusage.

data: resex type ref to csoapexceptionresource.

data: intex type ref to csoapexceptioninternal.

data: extxt type string.

data: dref type ref to data.

data: tags_param type t_param_tags.

data: ls_zptf type zptf.

if lcl_ofault is bound.

clear lcl_ofault.

endif.

create object osoap.

try.

call method osoap->set_method

exporting

nsvalue = lc_method_nsvalue

name = lc_method_req_name.

>* CALLING METHOD

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

nsvalue = lc_travelrequest_nsvalue

name = 'TravelRequest'

value = dref.

get reference of zuvt_s_key into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_S_KEY'

value = dref.

free dref.

get reference of zuvt_so_pass into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_SO_PASS'

value = dref.

free dref.

get reference of zuvt_so_time into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_SO_TIME'

value = dref.

free dref.

get reference of zuvt_to_hotel into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_TO_HOTEL'

value = dref.

free dref.

get reference of zuvt_to_plane into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_TO_PLANE'

value = dref.

free dref.

get reference of zuvt_to_car into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_TO_CAR'

value = dref.

free dref.

get reference of zuvt_to_train into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = '_ZUVT_TO_TRAIN'

value = dref.

free dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_in

name = 'TravelRequest'

value = dref.

>*begin response

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_out

nsvalue = lc_method_nsvalue

name = 'RequestToAgencyResponse'

value = dref.

data: begin of str,

pernr type ptrv_perio-pernr,

reinr type ptrv_perio-reinr,

stato(10),

note(255),

end of str.

get reference of str into dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_out

nsvalue = lc_travelrequeststatus_nsvalue

name = 'TravelRequestStatus'

value = dref.

call method osoap->add_parameter

exporting

direction = csoapconstants=>ic_param_out

name = 'RequestToAgencyResponse'

value = dref.

call method osoap->set_tag_name_format

exporting

format = csoapconstants=>ic_tagfmt_default.

call method osoap->set_item_name_format

exporting

format = csoapconstants=>ic_itemfmt_useitem.

catch csoapexceptionusage into usgex.

exit.

endtry.

isoap = osoap.

>* 2 create transport and set payload

try.

call method csoaptransport=>new_http_transport

importing

transport = otransp.

catch csoapexceptionresource into resex.

exit.

endtry.

try.

call method otransp->set_destination_by_dest

exporting

dest = dest. "created in SM59 as HTTP external

call method otransp->set_payload

exporting

payload = isoap.

catch csoapexceptionusage into usgex.

exit.

endtry.

data: soapaction type string.

concatenate lc_soapaction_first

lc_soapaction_central

lc_soapaction_last into soapaction.

call method otransp->set_soapaction

exporting

soapaction = soapaction.

try.

call method otransp->request_response.

catch csoapexceptionfault into fltex.

return = fltex->get_text( ).

call method fltex->get_fault

importing

fault = ofault.

raise http_error_call.

catch csoapexceptiontransport into trnex.

data: httpfault type ref to csoaphttpfault.

data: httpcode type i.

data: httpinfo type string.

data: httpbody type string.

data: httprc type sysubrc.

data: httpmsg type string.

call method trnex->get_fault

importing

fault = httpfault.

call method httpfault->get_all

importing

code = httpcode

text = httpinfo

body = httpbody

icf_rc = httprc

icf_msg = httpmsg.

message e032(ztrv) with 'http error N° ' httprc

'Try again later'.

catch csoapexceptiondocumentformat into fmtex.

return = fmtex->get_text( ).

raise http_error_call.

catch csoapexceptionusage into usgex.

return = usgex->get_text( ).

raise http_error_call.

catch csoapexceptionresource into resex.

return = resex->get_text( ).

raise http_error_call.

catch csoapexceptioninternal into intex.

return = intex->get_text( ).

raise http_error_call.

endtry.

call method otransp->close.

>* MOVE response TO return.

move str to return.

>* 5 PREPARE THE RESULT

if not ofault is initial.

try.

lcl_ofault ?= ofault.

data: factor type string.

data: fcode type string.

data: fstring type string.

data: fdetstr type string.

data: fdetail type t_node_table.

data: fdetrow type t_node_struct.

data: detcnt type i.

call method ofault->get_all

importing

fault_actor = factor

fault_code = fcode

fault_string = fstring

fault_detail_str = fdetstr

fault_detail_tab = fdetail.

>*WRITE: / '>> SOAP fault information:'.

>*WRITE: / ' > actor : ', fActor.

>*WRITE: / ' > code : ', fCode.

>*WRITE: / ' > string: ', fString.

if fdetstr is initial.

>*WRITE: / ' > detstr: '.

else.

>*WRITE: / ' > detstr: '.

call method csoaptools=>print_string

exporting

xmldoc = fdetstr.

endif.

describe table fdetail lines detcnt.

if detcnt gt 0.

>*WRITE: / ' > detail: '.

loop at fdetail into fdetrow.

>*WRITE: / ' >>'.

>*WRITE: / ' >> id > ', fDetRow-id.

>*WRITE: / ' >> pid > ', fDetRow-pid.

>*WRITE: / ' >> prfx> ', fDetRow-data-nsprefix.

>*WRITE: / ' >> nsvl> ', fDetRow-data-nsvalue.

>*WRITE: / ' >> name> ', fDetRow-data-name.

>*WRITE: / ' >> text> ', fDetRow-data-text.

endloop.

else.

>*WRITE: / ' > no detail'.

endif.

endtry.

endif.

Bye

Marco

Read only

0 Likes
693

oops,

the name of the include is SOAPINCL

Sorry.

taka a look to this other link

[https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/abap%2bproxy%2binbound%2bprogram%2b-%2bsales%2border%2bcreation]

[;

bye

marco

Edited by: nicolai marco on Jan 7, 2008 4:02 PM

Read only

0 Likes
693

Hi ,

I need some help from u

I m using the same soapdocument class - methods to acess a webservice from abap

the problem im facing is that ma webservice is in java .. (EJB)

the tags are in small caps ( first letter is always in small case )

abap provides us with method of tag_format in which only uppercase n mixcase are possible

is there ne possible way through which i can change the format of the tags to lowercase in abap .... atleast the first letter to lower case .....

thanks