‎2014 Jun 26 6:51 AM
dear all
i am new to SAP.
i have a web Service developed with .net and C#.
i want to call this web Service from inside a function module.
how can i do this ?
thanks,
‎2014 Jun 26 7:49 AM
Hi Ramzy,
Please browse through chrome or sdn , there is a lot of documents and discussions, any how find the below URL, which might be helpful.
Create a Function Module and full the below Code :
Sample code :
DATA: http_client TYPE REF TO if_http_client,
host_str TYPE string VALUE 'www.myservice.in',
service_str TYPE string,
path TYPE string VALUE 'my path',
errortext TYPE string. "used for error handling
DATA : wf_string1 TYPE string,
lw_inputs TYPE string,
error_text type string,
subrc TYPE SY-SUBRC,
lw_outputs TYPE string.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = 'myurl'
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~server_protocol'
value = 'HTTP/1.1'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = 'mypath'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'application/soap+xml; charset=utf-8'."'text/xml; charset=utf-8'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'Content-Length'
value = '19000'."txlen.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'SOAPAction'
value = 'myURL'.
concatenate 'data u need sned' into wf_string
CALL METHOD http_client->request->set_cdata
EXPORTING
data = wf_string1
offset = 0
length = '19000'.
Regards,
Lokeswar.