Hello Experts
I have created a consumer proxy for external Web Service and then created ABAP program to trigger the service. firstly I have tested this web service
in soap UI but it worked only after I have added the header authentication. without which I get the following error as
CODE:SoapFaultCode:1
I have found a thread that deals with such issue:
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
'<soapenv:Header>'
' <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" '
' xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'
'<wsse:UsernameToken>'
'<wsse:Username>sb</wsse:Username>'
'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">epsepseps</wsse:Password>'
'</wsse:UsernameToken>'
'</wsse:Security></soapenv:Header>'
INTO lv_string.
LV_XSTRING_1 = CL_PROXY_SERVICE=>CSTRING2XSTRING( LV_STRING ).
** create ixml dom document from xml xstring
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
XML = LV_XSTRING_1
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.
for me The while loop stops because xml_element ?= xml_element->get_next( ) does not retrieve the next element. only I get the first
child values as name = security and namespae = xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
and once I set the header for this then the loop skips.
couldn't understand why the loop skips with out the rest of the code as I referred to the rest of the blogs I have tried using get_first_child again but it gets usernametoken as name and then it gets namespace as xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd.
any help please really appreciated
Guys anyone with some help. I am trying all the ways to get this work but I am failing.
Regards
s battula
Add a comment