Hi,
I am trying to consume web service in ABAP . I need to pass SOAP header with the authentication along with SOAP body. I have used if_wsprotocol_ws_header interface to pass header but getting the PARSE error.
This is what I did:
- Created ABAP proxy from external WSDL, which in my case is Sales Force.
- Created logical port in SOAMANAGER.
- Executed the report calling the PROXY I created.
REPORT ztest.
try.
* instantiate the object reference
if proxy_so is not bound.
* create object proxy_
* get WS_HEADER protocol
data: ws_header type ref to if_wsprotocol_ws_header.
ws_header ?= proxy_so->get_protocol('IF_WSPROTOCOL_WS_HEADER').
* Additional Header
concatenate
* '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cre="http://soap.sforce.com/schemas/class/Creat eSAPSalesOrder">'
'<soapenv:Header>'
'<cre:SessionHeader>'
'<cre:sessionId>' result-session_id '</cre:sessionId>'
'</cre:SessionHeader>'
'</soapenv:Header>' into l_string RESPECTING BLANKS.
* convert to xstring
l_xstring = cl_proxy_service=>cstring2xstring( l_string ).
if l_string is not initial.
* create iXML DOM document from XML xstring
call function 'SDIXML_XML_TO_DOM'
exporting
xml = l_xstring
importing
document = xml_document
exceptions
invalid_input = 1
others = 2.
if sy-subrc = 0 and xml_document is not initial.
xml_root = xml_document->get_root_element( ).
xml_element ?= xml_root->get_first_child( ).
* add header element by element to SOAP header
while xml_element is not initial.
name = xml_element->get_name( ).
namespace = 'http://soap.sforce.com/'. "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.
catch cx_ai_system_fault into exc.
msg = exc->get_text( ).
endtry.
* soap body using abap proxy class.
data: input_so type zwscreate_sales_order_request,
output_so type zwscreate_sales_order_response.
* Input value
input_so-quote_number = '2016-111111'.
try.
* call the method (web service call)
call method proxy_so->create_sales_order
exporting
input = input_so
importing
output = output_so.
catch cx_ai_system_fault into exc.
msg = exc->get_text( ).
endtry.
In the above catch I am getting the PARSE error. I know it is from the header section that I created. But I am not able to find where is the error. Can anyone please help me out? I was also able to see the error logs in SOAMANAGER but not able to pin point the error.
Thanks in advance,
Karuna