SAP sistemi ile yeni bir web service entegresine
başladınız.Kullanıcı bilgileri ile servisi SOAPUI’dan test ettiniz.Herşey çok
güzel.Sıra SAP sistemine geldi.SAOPUI test ekranınızdaki Raw Tabındaki request
header bilgilerini alarak abap http request header alanlarını doldurarak
servise erişim yapabilirsiniz.
Soapui request header:
POST https://test.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://tempuri.org/test/testGonder"
Authorization: Basic ASD3KDKEIEI
Content-Length: 1717
Host: test.com.tr
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Örnek kullanım:
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Accept-Encoding'
value = 'gzip,deflate'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Content-Length'
value = gv_txlen.
Örnek abap kodu:
Concatenate kısmını SOAPUI request xml’ini kopyalarak
düzenleyebilirsiniz.
DATA: gv_ws_string TYPE string.
DATA: gv_rlength TYPE i,
gv_txlen TYPE string.
DATA: lv_url TYPE string.
DATA: gv_http_client TYPE REF TO if_http_client,
gv_xml_document TYPE REF TO cl_xml_document.
DATA: gv_ws_string1 TYPE string.
DATA: xml_input TYPE xstring.
DATA: xml_table LIKE TABLE OF smum_xmltb WITH HEADER LINE,
return LIKE TABLE OF bapiret2.
CONCATENATE
INTO gv_ws_string .
gv_rlength = STRLEN( gv_ws_string ) .
MOVE: gv_rlength TO gv_txlen.
lv_url = 'https://test.com /Service.svc'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = gv_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 gv_http_client->request->set_header_field
EXPORTING
name = 'POST'
value = https://test.com
/Service.svc' HTTP/1.1'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Accept-Encoding'
value = 'gzip,deflate'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Content-Length'
value = gv_txlen.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Authorization'
value = 'Basic saopui
authoriztion token'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'SOAPAction'
value = 'http://tempuri.org/METHOD
AD'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Host'
value = 'https://test.com'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'Connection'
value = 'Keep-Alive'.
CALL METHOD gv_http_client->request->set_header_field
EXPORTING
name = 'User-Agent'
value = 'Apache-HttpClient/4.1.1 (java 1.5)'.
CALL METHOD gv_http_client->request->set_cdata
EXPORTING
data = gv_ws_string
offset = 0
length = gv_rlength.
CALL METHOD gv_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD gv_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
gv_ws_string1 = gv_http_client->response->get_cdata( ).
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = gv_ws_string1
encoding = '4103'
IMPORTING
buffer = xml_input
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml_input
TABLES
xml_table = xml_table[]
return = return.
Hiç yorum yok:
Yorum Gönder