Skip to Content

Exposing BAPI as Web Services through SAP XI

1.0 Overview

1.1 Scenario

The example used in this step-by-step guide of building a web service through SAP XI
exposes the function module SAP_WAPI_START_WORKFLOW as a web service, which when executed
starts the WS20000391 (Schedule Manager) workflow to start a job.


1.2 Steps Overview

  • Identify the import/export parameters of the workflow and the function module
  • Design interface in SAP XI
  • Configure interface in SAP XI
  • Create web service in SAP XI
  • Test the web service using Microsoft Office InfoPath 2003
  • Verify the test results

1.3 Prerequisites

    1. Basic understanding of SAP R/3 and SAP XI
    2. Working SAP R/3 or ECC system, and Exchange Infrastructure 3.0 and up

2.0 Identifying Required Parameters

2.1 Parameters for the Workflow

Display the template for workflow WS20000391 and view the container through transaction PFTC. Identify the required import parameters for this workflow which are marked with exclamation marks. JobName, StepsReports and StepsReportVariants are the required parameters for this workflow.

2.2 Parameters for the Function Module

Display the function module SAP_WAPI_START_WORKFLOW in function builder through transaction SE37.  View its import information under the Import tab.  Identify TASK, LANGUAGE, DO_COMMIT as the necessary import parameters for this scenario.

Display the Tables tab for the function module to identify the necessary table parameter INPUT_CONTAINER for this scenario.


Display the table properties for the SWR_CONT type associated with INPUT_CONTAINER and note its components ELEMENT and VALUE.

3.0 Designing the Interface in XI

3.1 Integration Repository

Start up the homepage for the menu for XI tools using transaction SXMB_IFR.  This can also be started with a manually entered URL in the browser.  Click on Integration Repository under Integration Builder: Design to start designing the interface.  A list of objects is displayed on th left when the integration repository window starts up. Expand the object that the interface will be created under, and then expand Imported Objects.  Right click on RFC under Imported Objects to import the function module.


From the list of available objects displayed, select the desired function module, in this case SAP_WAPI_START_WORKFLOW, and click Continue to finish importing the object.


3.2 Activating Changes

Save and activate changes now and then to prevent from losing the work.  Click on the Change Lists tab next to the Objects tab in the repository, and the change list for the user will be displayed.  Navigate to the Standard Change List that contains the recent changes to be activated.  Right click on Standard Change List and click Activate.  Repeat this process throughout the design and configuration process within XI.



3.3 Deifning Request and Response Data Types

In the Objects tab, expand the namespace being worked with. Navigate to Data Types under Interface Objects. Right click on Data Types and click New to create a new data type. Name the data type correspondingly and save it.


Define a new data type each for request and response. The request data type for this interface is named StartWorkflowSchJob_REQ_DT. Name the response data type correspondingly as well.


Using the Type Definition tools, add necessary elements to the request and response data type structures.



3.4 Creating Request and Response Message Types

Navigate to Message Types under Interface Objects under the same namespace. Right click on Message Types and click New to create a new message type. Name the message types correspondingly for request and response; StartWorkflowSchJob_REQ_MT and StartWorkflowSchJob_RESP_MT.


In the Edit Message Type window after creating the message type, specify the corresponding data type that will be used for the specific message type by clicking on the Display Input Help button. The structure of the request data type is displayed in the request message type, and the structure of the response data type is displayed in the response message type.



3.5 Defining a Fault Message Type

Navigate to Fault Message Types under the same namespace and right click on it to create a new fault message type for the interface. The fault message type for this scenario is named StartWorkflowSchJob_FAULT_MT. Save and activate changes.


3.6 Defining the Message Interface

Navigate to Message Interfaces under Interface Objects under the same namespace in the integration repository. Right click on it to create a new message interface. Name the message interface correspondingly, in this case it is named StartWorkflowSchJob_MI.


Specify the interface to be outbound and synchronous in the Attributes section under the message interface Definition. Specify the request message type for the output message, the response message type for the input message and the fault message type for the fault message type by clicking on each Input Help button to the right of the input fields.


This conclude the creation of interface objects for this interface in the integration repository.  Next mapping objects will be defined in the integration repository for the messages.

3.7 Creating a Message Mapping for the Inbound Request

Navigate to Message Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Message Mappings and click on New to create a new message mapping.  Name the message mapping correspondingly. The request message mapping for this scenario is named StartWorkflowSchJob_REQ_MM. Specify the source and target messages for the message mapping and perform desired mapping using the graphical mapping tool. Click on Select Message in the Enter a source message section to display the list of options to choose from.  Do the same in the Enter a target message section when selecting a target message.


Choose StartWorkflowSchJob_REQ_MT as the source message type for the request message mapping, and choose the imported function module SAP_WAPI_START_WORKFLOW as the target message.



The structures of the source and target messages specified are displayed in the left and right sections in the Design tab of the message mapping. Save the message mapping that has been defined so far to prevent from losing the progress. The RFC message structure for SAP_WAPI_START_WORKFLOW is displayed on the right hand side of the Design tab in the request message mapping as the target message.


Map the source elements to the target elements based on desired conditions and values. Recall the required import parameters that were identified for the function module in section 2.2. Those are the parameters that correspond to the elements in the target message that should be mapped for the request message mapping.

Map the constant “WS20000391” that specifies the workflow to the element TASK in the target message.


Map the constant “X” to the DO_COMMIT element in the target


Map the contant “EN” for English to the LANGUAGE element in the target message.


The INPUT_CONTAINER table parameter for the SAP_WAPI_START_WORKFLOW function module has three container elements. Therefore, the subtree of the INPUT_CONTAINER node in the target message must be duplicated twice to represent the three rows of the table. Right click on the item subtree under INPUT_CONTAINER in the target message and click on Duplicate Subtree. Repeat this step one other time so that INPUT_CONTAINER has three of the same Item subtrees.


Map the names of the required import parameters of the workflow Schedule Job identified in step 2.1 to each ELEMENT under each item subtree. The third ELEMENT would be mapped with the constant “StepsReportVariants”.


Map the node StartWorkflowSchJob_REQ_MT from the source message to the INPUT_CONTAINER node and each of the item subnodes. Each VALUE under each item subtree is mapped with each element in the source message. The second VALUE is mapped with ProgramName.


3.8 Creating a Message mapping for the Outbound Response

Navigate to Message Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Message Mappings and click on New to create a new message mapping.  Name the message mapping correspondingly.  Specify the source and target messages for the message mapping and perform desired mapping using the graphical mapping tool. The source message is the function module and the target message is the response message StartWorkflowSchJob_RESP_MT.
Map the source elements with the same names as the target elements to the target elements.


3.9 Defining the Interface Mapping

Navigate to Interface Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Interface Mappings and click New to create a new interface mapping for the interface.  Name the mapping accordingly.  Specify the source and target interfaces, and select the correct request and response message mappings. The interface mapping for the SOAP interface that is being defined in XI is named StartWorkflowSchJob_IM.


Select StartWorkflowSchJob_MI for the source interface of the interface mapping.


Select the imported function module SAP_WAPI_START_WORKFLOW as the target interface for the interface mapping.


Specify the request message mapping StartWorkflowSchJob_REQ_MM as the request mapping program.


Specify the response message mapping StartWorkflowSchJob_RESP_MM for the response mapping program. Save and activate all changes.  The design of the interface in XI Integration Repository is done.

4.0 Configuring the Interface in XI

4.1 Configuration Wizard

Start up the homepage for the menu for XI tools.  This can also be started with a manually entered URL in the browser.  Click on Integration Directory under Integration Builder: Configuration to start designing the interface.  A list of scenarios is displayed on the left when the integration directory window starts up. Click on the Configuration Wizard icon to start the configuration wizard.


Choose Internal Communication for message exchange within the same system landscape.


Specify the appropriate service and interface for the sender.


Specify the appropriate service and interface for the receiver.


Name the communication channel accordingly to define how the SOAP adapter will process the inbound message.


Use the default receiver determination configuration.


Use the default interface determination configuration.


Name the communication channel for the receiver accordingly.


The scenario in this case is named StartWorkflowSchJob. Click Finish to generate the defined objects for the interface configuration.


4.2 Defining Communication Channel Details

After generating the scenario in the integration directory, define details for the sender and receiver communication channels specified by navigating to the objects from the Scenarios list and under the scenario that has been created. In the sender communication channel, specify the default interface namespace and name.  The Quality of Service parameter can be specified for specific message delivery options.


In the receiver communication channel for the outbound message, make certain the RFC parameters are set and that valid logon information is provided.


5.0 Web Service Creation

5.1 Generating the WSDL File

In Integration Directory, from Tools in the main menu, select Define Web Service.  Specify the parameters for the web service and save the generated wsdl file to desired path.


Specify the URL for the web service. The format should be
http://[server]:[port]/XISOAPAdapter/MessageServlet?channel=:[sender communication channel service]:[sender communication channel name]


Use the default interface information.


Specify the sender as done in interface configuration.


Review the information specified and click Finish to generate the wsdl file of the web service.


Click on Save to save the generated web service document to an accessible path.


6.0 Testing the Web Service

6.1 Designing and Testing the Form

Using Microsoft Office 2003 InfoPath, the web service that has been generated can be easily tested.  To begin testing the web service, first design the form in InfoPath.  Various other tools are also available for web service testing, including licensed and free tools.

Click on Design a Form after starting up InfoPath 2003.


Click on New from Data Connection in Design a Form window.


The Data Connection wizard starts up, choose Web service.


Choose Receive and submit data since the web service involves request and response.


Enter the path to the web service document that had been saved from XI.


Highlight the message interface.


Enter the name for the data connection for receiving data accordingly.


Click Next and follow the same steps for the data connection for sending data as done for the data connection for receiving data. Enter a name for the sending data connection correspondingly.

After configuring the data connections for both send and receive, specify the parameters that will be submitted through the web service to start the workflow. Choose one parameter at a time.



Finish the data connection creation.

Design the actual form of the web service.


Drag and drop field elements from the Data Source window into the submit and return sections of the form accordingly. When done with designing the form, click on Preview Form from the top menu to test.


Input valid test parameters into the boxes for the submit parameters and click the Submit Request button.


Enter valid logon information to connect to the web service.


If everything was configured correctly, valid results should
be visible in the return parameters fields.


7.0 Verifying the Test Results

7.1 Verification in XI

Go to the XI Integration Engine to make sure that the request and response messages have been successfully processed. In transaction SXMB_MONI, check the corresponding message ID for the processed request and response messages.  Notice in the SOAP header of the request message, the

7.2 Verification in R/3

Verify in the target system that the workflow and the job have been started successfully. In transaction SWI1, verify that the Schedule Manager: Schedule Job job instance has been started correctly by the workflow instance.


In transaction SM37, verify the status of the job that had been started by the workflow instance.


You must be Logged on to comment or reply to a post.
  • Hi,

    it’s a pretty nice weblog but
    what’s new or specific it in?
    we already have a few RFC, and SOAP weblogs
    that describe those kind of scenarios
    and much more that describe
    how to do standard config in ID and IR

    maybe try to post even smaller weblogs
    but with new or not described anywhere information in the future

    you can always check previos weblogs on:

    thank you,


    • You are right. I didn’t really do research on other similar blogs. I hope to add new ideas by introducing areas concerning security, reliability and how BPX may relate to the topic. Thanks for the input.
      • Hi Jui-Chia Che,
        Perhaps writing for a BPX audience might be a very good approach as process integration and implementing that technically is something that might be of interest to a BPX, although very detailed technical details may not.  Sometimes, it isn’t the uniqueness of the content that will matter to the audience but rather the structuring of content for a specific type of reader and their specific tasks.
        I welcome you to add the BPX metatag to topics when you feel they are appropriate to the BPX audience.  You might try getting feedback in the Business Process Expert General Discussion (Read Only Archive) (link to your blog in a new thread and request discussion as to whether the content is appropriate to that audience.)  If you ask honestly, the community will certainly let you know.
        Thanks Jui-Chia for your blog and thanks Michal for the XI mentoring.
    • Doing a search for web services in the XI blogs section, I found no similar blogs compared to mine.  Also I didn’t find anything as detailed on the subject, and have tried some step-by-step guides from other blogs before on similar topics that didn’t seem to work. So hopefully my blog will prove to be helpful in some form or another.
      • hi,

        >>>>So hopefully my blog will prove to be helpful in some form or another.

        no doubt it will but as I said there
        are many RFC and SOAP weblogs already
        and that was my point

        let’s not try to mix all adapters
        with each other as a new weblog
        as we will have many redundant weblogs

        it’s better to show something
        from your experience (even simple, non standard)
        or something very new (not described anywhere
        and might be a little difficult if you
        only use

        just my few cents

        there realy are milions of things
        there were not described in the XI area
        so keep on blogging but just keep in mind what I said 🙂


  • imho this is an excellent weblog. a clear and useful use case, very well illustrated and most importantly – complete (which a lot of other blogs aren’t).
    maybe the XI part is too detailed for the guru, but don’t worry, the rest of the world will appreciate it. at least I do and if I’d ever had to suggest an XI tutorial example I’d take this instead of the 151st material query example.
    thx jui-chia.

    regards, anton

  • Thanks for the blog, great article.  I am learning XI and this served as a good tutorial.  As others have mentioned, it is complete.  There are many other blogs out there that don’t go into detail (plus screenshots) and consequently can be tricky to learn from.  Keep them coming 🙂
  • hi,
    thats a very lucid description of the entire process .i am working on workflow and i have a bit of understanding about XI and as well as regarding web services.After going through this article, i can now correlate the things very well.

    thanks a lot!!!

  • Wanted to say THANKS for this great blog.  We’ve got lots of workflow people out there who want to get going with XI – use SAP_WAPI* is a great idea and the step by step approach is very useful!
    Thanks for taking the time and effort to publish such a great blog!
  • Hi Jui-Chia!
    Thanks for your presentations at TechEd ’06 in Las Vegas and subsequently posting this greatly detailed blog!  It’s great to see content like this and know it’s grounded in an actual customer implementation.

    Best Regards,

  • Hi..
       By seeing your blog i was able to do execute the wsdl using the infopath. It helped a lot. I am having one doubt, that the infopath will accepts only wsdl file which is not using BPM. Why i asked this was, i have tried the wsdl which was generated without the bPm, then it is working fine. If i give the wsdl where i have used the BPm, then it is not working. Could please help in this regard. waiting for ur response