Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

web service

Former Member
0 Likes
504

Hi All,

I am trying to consume a web service,where I need to pass the soap header for sending the request to the sever.

I am using if_ws_protocol_ws_header->SET_REQUEST_HEADER to set the cilent id to the soap header. After a lot of trouble shooting I came to conclusion that the client id not being updated in soap header.

I want to know how to set the soap header? I have tested the web service in the SOAP UI testing tool and it works fine.

Here is what I am trying to pass:

'<soap:Header>'

     '<AuthenticateHeader xmlns="http://mycomany.com/PDM/PartRegistration/">'

       '<ClientID>''MSM''</ClientID>'

     '</AuthenticateHeader>'

   '</soap:Header>'

ABAP Code is :

REPORT  ytest_webservice NO STANDARD PAGE HEADING.

DATA : proxy TYPE REF TO zwpart_brokerco_part_broker_so.

DATA: input TYPE zwpart_brokercreate44part_num1,

       output TYPE zwpart_brokercreate44part_numb.

DATA : ws_header TYPE REF TO if_wsprotocol_ws_header,

        name TYPE string,

        namespace TYPE string,

        system_fault TYPE REF TO cx_ai_system_fault.

* set somehow header as iXML-DOM tree

DATA:     ixml TYPE REF TO if_ixml,

           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 l_xstring        TYPE xstring.

DATA l_string         TYPE string.

FIELD-SYMBOLS <fs_xstring> TYPE xstring.

TRY.

     CREATE OBJECT proxy

       EXPORTING

         logical_port_name = 'ZPART_BROKER'.

*  get WS_HEADER protocol

     ws_header ?= proxy->get_protocol('IF_WSPROTOCOL_WS_HEADER').

*  Additional Header:

     CONCATENATE

  '<soap:Header>'

     '<AuthenticateHeader xmlns="url">'

       '<ClientID>''MSM''</ClientID>'

     '</AuthenticateHeader>'

   '</soap: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( .

           IF NOT xml_element IS INITIAL.

           ENDIF.

           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.

ENDTRY.

input-prefix = '0050'.

input-material_type = 'HALB'.

input-uom = 'EA'.

input-material_group = '0210'.

input-division = '2P'.

input-description = 'TEST1'.

input-extended_description = 'TEST1'.

input-project = '12345'.

input-requestor = 'anil@gamil.com'.

input-lab_office = '11A'.

input-xplant_status = 'C1'.

TRY.

     CALL METHOD proxy->create44part_number

       EXPORTING

         input  = input

       IMPORTING

         output = output.

   CATCH cx_ai_system_fault INTO system_fault.

     WRITE:/ 'System Fault'(sye).

     WRITE:/ system_fault->errortext.

   CATCH cx_ai_application_fault .

     WRITE:/ 'Application fault'(apf).

     EXIT.

ENDTRY.

WRITE : output-create44part_number_result.


The below screen shot is the error which I am getting.please check this and let me know.

thanks in advance.

1 REPLY 1
Read only

Former Member
0 Likes
381

please give solution..