Skip to Content
0
Dec 02, 2022 at 07:34 PM

Not able to pass fields in SOAP Header in consumer proxy.

198 Views Last edit Dec 03, 2022 at 03:28 PM 2 rev

Hi Experts,

I am facing the issue in passing SOAP header field in the consumer proxy for some days.

I have tried using if_wsprotocol_ws_header and the value of field and namespace is getting set to the to lref_ws_header. But only the first tag AuthenticationHeader is filled, and rest of the XML tags are ignored as xml_element->get_next returns blank value.

When I open SOAP UI and check the method, I can see the fields (AuthenticationHeader ApplicationType, SessionID) available in the soap header but in the proxy class we don’t have the fields to pass the value. So I have decided to add them in header as per different blogs.

CONCATENATE

'<soap-env:Header>'
'<eb:AuthenticationHeader xmlns:eb="http://schemas.xmlsoap.org/soap/envelope/" '
' xmlns:eb="http://ws.providernamespace.com/"> '
' <eb:ApplicationType>Api</eb:ApplicationType> '
' <eb:PropertyNumber>2</eb:PropertyNumber> '
' <eb:SessionID>' l_string '</eb:SessionID> '
' </eb:AuthenticationHeader> '
' </soap-env:Header> ' INTO ls_string.

 CONVERT to xstring
l_xstring = cl_proxy_service=>cstring2xstring( ls_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 = xml_element->get_namespace_uri( ).
lref_ws_header->set_request_header( name = name namespace = namespace dom = xml_element ).
xml_element ?= xml_element->get_next( ).
ENDWHILE.
ENDIF.


Let me now the mistake, do we need to have all the XML fields in the header request? Is something wrong with the XML I built?

Any help , hints is highly appreciated.

Thanks ,

Shubham