Skip to Content
avatar image
Former Member

Extract fields from the SOAP body during mapping

Hi all,

I have an Abap Proxy to SOAP scenario with a main payload and an attachment. During mapping I need the reference of the attachment to store the reference in the main payload. I don't need the attachment itself.

SOAP-Body:

  <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <!--  Eingangs-Message 
  --> 
- <SAP:Manifest xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wsu="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="wsuid-manifest-5CABE13F5C59AB7FE10000000A1551F7">
- <SAP:Payload xlink:href="cid:payload-E742FF47D930DE5CE1000000C107826A @sap.com">
  <SAP:Name>MainDocument</SAP:Name> 
  <SAP:Description /> 
  <SAP:Type>Application</SAP:Type> 
  </SAP:Payload>
- <SAP:Payload xlink:href="cid:payload-EE42FF47D930DE5CE1000000C107826A @sap.com">
  <SAP:Name>hugo.txt</SAP:Name> 
  <SAP:Description /> 
  <SAP:Type>ApplicationAttachment</SAP:Type> 
  </SAP:Payload>
  </SAP:Manifest>

I need the attachment reference as string inside my main payload: cid:payload-EE42FF47D930DE5CE1000000C107826A @sap.com

I wrote an user defined function to select the MessageId, but the MessageId is only part of the reference to the main payload.

String constant;
java.util.Map map;
map = container.getTransformationParameters();

constant = (String) map.get(StreamTransformationConstants.MESSAGE_ID); 
return constant;

Has anybody an idea to get the reference of the attachment from the SOAP body with an user defined function or an adapter module?

Thanks and kind regards

Frank

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 18, 2008 at 07:03 AM

    Hi,

    You can use Dynamic Cofiguration in UDF to accessthese parameters.

    Thanks & Regards,

    Akshay

    • Reward points if find useful.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 21, 2008 at 07:06 AM

    hi,

    You will try with the "PayloadSwapBean " and "MessageTransformBean"...

    It will work with your requirement.....

    [http://help.sap.com/saphelp_nw04/helpdata/en/44/748d595dab6fb5e10000000a155369/content.htm]

    [http://help.sap.com/saphelp_nw04/helpdata/en/57/0b2c4142aef623e10000000a155106/content.htm]

    Regards,

    Prakasu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello,

      thank you all for the information. I found a solution for my problem on the sender side. I wrote an own helper class with the method create_attach_from_txt_withref. This method build an attachment with an own reference and write the reference back to the payload.

      This reference will not be changed within the execute_asynchronous method of the proxy.

      Method parameters:

      P_DATA        Importing   Type     STRING
      P_TYPE        Importing   Type     STRING
      P_NAME        Importing   Type     STRING
      P_ATTACHMENT  Exporting   Type Ref IF_AI_ATTACHMENT
      P_AREF        Exporting   Type     STRING
      

      Method coding:

      METHOD create_attach_from_txt_withref.
      
        DATA: lo_attachment TYPE REF TO cl_ai_attachment,
              l_payload     TYPE REF TO if_xms_payload,
              l_pref        TYPE        sxms_mf_s,
              l_guid        TYPE        guid_32,
              l_aref        TYPE        string.
      
        CLASS cl_ai_factory DEFINITION LOAD.
      
      " create the attachment
        p_attachment = cl_ai_factory=>create_attachment_from_text(
                      p_data = p_data             " attachment data
                      p_type = p_type             " attachment type
                      p_name = p_name ).          " attachment name
      
      " we need an implementing class of the interface if_ai_attachment
        lo_attachment ?= p_attachment.
      " get the new payload
        l_payload = lo_attachment->get_payload( ).
      " get the reference of the payload
        l_pref = l_payload->getreference( ).
      
      " build an own reference
        CALL FUNCTION 'GUID_CREATE'
          IMPORTING
            ev_guid_32 = l_guid.
      
        CONCATENATE 'payload-' l_guid '@sap.com' INTO l_aref.
        CONCATENATE 'cid:'     l_aref            INTO l_pref-href.
      " set our own reference
        l_payload->setreference( reference = l_pref ).
      " write back the modified payload
        lo_attachment->set_payload( p_payload = l_payload ).
      " return of the reference
        p_aref = l_aref.
      
      ENDMETHOD.
      

      If anybody has an idea how to read the soap body within an adapter module please let me know.

      Regards

      Frank