Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

External Web Service Requires - WS-Security Header (calling from ABAP)

Hello,

I have created the proxy for external Web Servcie and ABAP program to trigger it This service requires header authentication, without which I get the following error:

CODE:SoapFaultCode:1

ERRORTEXT: Security Data : No WS-Security Header

I have found a thread that deals with such issue: Web Services Security using ABAP Proxies

In that thread Thomas Jung gives example of the program on how to create service header. However, the following code does not work for me:

concatenate

'<Header>'

'<Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'

'<UsernameToken Id="uuid-e55489fa6444-1">'

'<Username>User123</Username>'

'<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordText">Pass123</Password>'

'</UsernameToken>'

'</Security>'

'</Header>' into l_string.

** convert to xstring*

l_xstring = cl_proxy_service=>cstring2xstring( l_string ).

if not l_string is 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 not xml_document is initial.

xml_root = xml_document->get_root_element( ).

xml_element ?= xml_root->get_first_child( ).

** add header element by element to SOAP header*

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.

The while loop stops because xml_element ?= xml_element->get_next( ) does not retrieve the next element. And even the first element is retrieved only partially, just its name.

Does anyone know why this code does not work? Is there any other way to pass WS-Security Header.

Thanks,

Alex

Former Member
Not what you were looking for? View more on this topic or Ask a question