on 2020 May 20 10:28 AM
Hi, friends!
I have 2 service consumer: ZCO_LOGON and ZCO_RUN_JOB.
ZCO_LOGON generates and returns SessionID.
I need to put this SessionID in a header of ZCO_RUN_JOB.
But there's a problem: ZCO_RUN_JOB header generated automatically and I don't know how to put my SessionID there.
I've tried to do something like this, but it didn't solve my problem.
Maybe somebody can advise me something or show me my mistake.
Thanks!
DATA(lr_proxy_conn) = NEW zco_logon( ).
IF lr_proxy_conn IS BOUND.
TRY .
lr_proxy_conn->logon( EXPORTING input = conn_input
IMPORTING output = conn_output ).
CATCH cx_ai_system_fault.
ENDTRY.
DATA: client_proxy TYPE REF TO zco_run_job,
ws_header TYPE REF TO if_wsprotocol_ws_header,
system_fault TYPE REF TO cx_ai_system_fault,
name TYPE string,
namespace TYPE string.
DATA: obj_ixml TYPE REF TO if_ixml,
obj_ixml_factory TYPE REF TO if_ixml_stream_factory,
obj_ixml_ostream TYPE REF TO if_ixml_ostream,
obj_ixml_istream TYPE REF TO if_ixml_istream,
obj_parser TYPE REF TO if_ixml_parser,
w_error TYPE i.
DATA: xml_document TYPE REF TO if_ixml_document,
xml_root TYPE REF TO if_ixml_element,
xml_element TYPE REF TO if_ixml_element,
xml_node TYPE REF TO if_ixml_node.
DATA: lw_cstring TYPE string,
l_xstring TYPE xstring,
l_string TYPE string.
CREATE OBJECT client_proxy
EXPORTING
logical_port_name = 'ZLP_RUN_JOB'.
ws_header ?= client_proxy->get_protocol( if_wsprotocol=>ws_header ).
l_string = '<soapenv:Header>' &&
'<ser:session>' &&
'<SessionID>' && |{ conn_output-session_id }| && '</SessionID>' &&
'</ser:session>' &&
'</soapenv:Header>'.
IF NOT l_string IS INITIAL.
obj_ixml = cl_ixml=>create( ).
obj_ixml_factory = obj_ixml->create_stream_factory( ).
obj_ixml_istream = obj_ixml_factory->create_istream_string( l_string ).
xml_document = obj_ixml->create_document( ).
obj_parser = obj_ixml->create_parser(
stream_factory = obj_ixml_factory
istream = obj_ixml_istream
document = xml_document ).
w_error = obj_parser->parse( ).
IF sy-subrc = 0 AND NOT xml_document IS INITIAL.
xml_root = xml_document->get_root_element( ).
xml_element ?= xml_root->get_first_child( ).
WHILE NOT xml_element IS INITIAL.
name = xml_element->get_name( ).
namespace = xml_element->get_namespace_uri( ).
ws_header->set_request_header( name = name namespace = namespace dom = xml_element ).
xml_element ?= xml_element->get_next( ).
ENDWHILE.
ENDIF.
ENDIF.
CHECK: client_proxy IS BOUND.
TRY .
client_proxy->run_job( EXPORTING input = input
IMPORTING output = output ).
CATCH cx_ai_system_fault.
ENDTRY.
ENDIF.
Request clarification before answering.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.