BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only

Mastering IBM BAW REST API: Sending Messages to BPEL Process Instances

By R Abhiramya posted Tue April 07, 2026 12:58 PM

  

In IBM Business Automation Workflow (BAW), the ability to programmatically interact with BPEL processes is crucial for building integrated enterprise solutions. The REST API's sendMessage method provides a powerful way to initiate or communicate with BPEL process instances using standard HTTP protocols. This blog post will guide you through understanding and implementing this capability with practical examples. The examples in this topic use `curl` as the HTTP client to send the `POST` request.

Understanding BPEL and Message-Based Communication

What is BPEL?

Business Process Execution Language (BPEL) is an OASIS standard for defining and executing business processes that orchestrate web services:

  • Define long-running business workflows that can span days, weeks, or months
  • Support asynchronous communication between services
  • Implement compensation and error handling for complex transactions
  • Use correlation sets to route messages to specific process instances
  • Integrate with web services using WSDL definitions

Message-Based Communication Model

BPEL processes communicate through messages, following these principles:

  1. Receive Activity: Waits for incoming messages to start or continue a process
  2. Reply Activity: Sends response messages back to callers
  3. Invoke Activity: Calls external services
  4. Correlation Sets: Route messages to the correct process instance

Why Use REST API Instead of SOAP?


Aspect REST API SOAP
Simplicity JSON/XML over HTTP Complex SOAP envelopes
Performance Lightweight, faster More overhead
Tooling Any HTTP client SOAP-specific tools
Modern Integration Native to web/mobile apps Legacy systems
Learning Curve Easier Steeper

Understanding the sendMessage API

The sendMessage REST API endpoint allows you to:

  • Start a new BPEL process instance by sending a message to a start-enabled Receive activity.
  • Communicate with running instances using WS-BPEL correlation sets
  • Integrate external systems with your workflow processes seamlessly
  • Trigger process operations defined in WSDL interfaces

API Endpoint Structure

POST /rest/bpm/bfm/v1/process?action=sendMessage&processTemplateName={string}&portType={string}&operation={string}

Key Parameters Explained


Parameter Type Description Example
action string  Must be set to sendMessage sendMessage
processTemplateName string  Name of the BPEL process template CustomerOrderProcess
portType string  QName of WSDL port type: {namespace}localname {http://SendMessageExample/CustomerOrderInterface}CustomerOrderInterface
operation string  WSDL operation name (NCName) processOrder

Practical Implementation Guide


Step 1: Creating the Process Assets in Integration Designer

1.1 Create a New Module

Module Name: SendMessageExample

1.2 Define Business Object

Create a business object named CustomerData:


<xsd:complexType name="CustomerData">
  <xsd:sequence>
    <xsd:element name="customerId" type="xsd:string"/>
    <xsd:element name="customerName" type="xsd:string"/>
    <xsd:element name="orderAmount" type="xsd:double"/>
  </xsd:sequence>
</xsd:complexType>

1.3 Create Interface

Define CustomerOrderInterface:


  • OperationprocessOrder

  • InputcustomerInfo (type: CustomerData)

  • Outputresult (type: string)


1.4 Build BPEL Process

Create CustomerOrderProcess with the following activities:


  1. Receive Activity: Receives the processOrder operation
  2. Assign Activity: Processes the customer data


    concat('Customer ID: ', $customerInfo/customerId, 
           ', Customer Name: ', $customerInfo/customerName, 
           ', Order Amount: ', $customerInfo/orderAmount)
  3. Reply Activity: Returns the result

1.5 Deploy

Deploy the module to your IBM BAW runtime environment.


Step 2: Invoking the Process via REST API


2.1 Construct the API Call

Full URL Example:

POST https://your-baw-server:9443/rest/bpm/bfm/v1/process?action=sendMessage&processTemplateName=CustomerOrderProcess&portType={http://SendMessageExample/CustomerOrderInterface}CustomerOrderInterface&operation=processOrder

2.2 Set Request Headers

Content-Type: application/json
Authorization: Basic [Base64EncodedCredentials]
Accept: application/json


Generating Base64 Credentials:


echo -n "username:password" | base64

2.3 Prepare Request Body

Standard Format:


{
  "customerInfo": {
    "customerId": "CUST001",
    "customerName": "John Doe",
    "orderAmount": 1299.99
  }
}

Alternative Format (with EVENTMSG wrapper):


{
  "EVENTMSG": {
    "customerInfo": {
      "customerId": "CUST001",
      "customerName": "John Doe",
      "orderAmount": 1299.99
    }
  }
}

Some BAW configurations require the EVENTMSG wrapper. Test both formats to determine which your environment requires

Step 3: Complete cURL Example


curl -X POST \
  'https://your-baw-server:9443/rest/bpm/bfm/v1/process?action=sendMessage&processTemplateName=CustomerOrderProcess&portType={http://SendMessageExample/CustomerOrderInterface}CustomerOrderInterface&operation=processOrder' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'Accept: application/json' \
  -d '{
    "customerInfo": {
      "customerId": "CUST001",
      "customerName": "John Doe",
      "orderAmount": 1299.99
    }
  }'

Step 4: Understanding the Response


Success Response (200 OK)

{
  "piid": "12345",
  "processTemplateName": "CustomerOrderProcess",
  "processTemplateID": "67890",
  "name": "CustomerOrderProcess_Instance_1",
  "state": "STATE_RUNNING",
  "startTime": "2025-12-01T09:30:00Z",
  "isMigrated": false,
  "customText1": "",
  "customText2": "",
  ...
  "customText8": ""
}


Key Response Fields:



piid: Process Instance ID - unique identifier for tracking

state: Current state (STATE_RUNNING, STATE_FINISHED, etc.)

startTime: When the instance was created

isMigrated: Indicates if the instance was migrated (available since v7.0)

customText1-8: Custom fields for additional metadata (available since v7.5.1)


Advanced Scenarios


Scenario 1: Correlation sets

For long-running processes, the first message might start the process, but later messages must reach the correct running instance. In Integration Designer, define a correlation field such as orderId, create a correlation set, and configure the Receive activities to use it. In the REST request, send the same value so BAW can match the message to the correct process instance.

Example:

{
  "customerInfo": {
    "customerId": "CUST001",
    "orderId": "ORD-12345",
    "customerName": "John Doe",
    "orderAmount": 1299.99
  }
}

If the correlation field is missing, incorrect, or does not match a waiting instance, the request can fail with a conflict or routing error.


Scenario 2: Error Handling


When testing with curl, Postman, JavaScript, or Java, check both the HTTP status code and the response body. Also verify that the process is deployed, the processTemplateName is correct, the portType and operation match the WSDL, and the user is authorized.

Typical status codes:

  • 400 - request format or parameters are wrong
  • 401 - credentials are missing or invalid
  • 404 - process template, interface, or operation was not found
  • 409 - process state or correlation problem
  • 415 - wrong Content-Type
  • 500 - server-side error; check BAW logs

A good approach is to first test a simple request that starts a new instance, and only then test follow-up messages and error cases.


Scenario 3: XML Content Type

If you use XML instead of JSON, set Content-Type: application/xml and make sure the XML matches the expected input structure exactly, including element names and namespaces if required.

Example:

<customerInfo>
  <customerId>CUST001</customerId>
  <customerName>John Doe</customerName>
  <orderAmount>1299.99</orderAmount>
</customerInfo>

Before testing, verify the expected structure from the WSDL or XSD because XML requests are sensitive to naming and namespace mismatches.

What to verify before using sendMessage?

Before calling the API, confirm the following:

  • the process application is deployed
  • the processTemplateName is correct
  • the portType QName and operation name are correct
  • the request body matches the input message definition
  • required correlation fields are included
  • the process is in a state where it can receive the message
Common HTTP Status Codes

Code Description Action
200 Success Message delivered successfully
400 Bad Request Check parameter validity
401 Unauthorized Verify credentials
404 Not Found Confirm process template exists
406 Not Acceptable Check Accept header
409 Conflict Process stopped or correlation issue
415 Unsupported Media Type Verify Content-Type header
500 Internal Server Error Check server logs

Best Practices


1. Security

  • Always use HTTPS in production
  • Store credentials securely (use environment variables or secret managers)
  • Implement proper authentication and authorization
  • Rotate credentials regularly

2. Error Handling

  • Implement retry logic with exponential backoff
  • Log all API interactions for troubleshooting
  • Handle all possible status codes gracefully
  • Provide meaningful error messages to users

3. Performance

  • Use connection pooling for multiple requests
  • Implement request timeouts
  • Monitor API response times
  • Cache process template information when possible

4. Testing

  • Test with both JSON and XML formats
  • Verify correlation set behavior
  • Test error scenarios (invalid data, missing parameters)
  • Load test for production readiness

5. Documentation

  • Document your process interfaces clearly
  • Maintain API endpoint inventory
  • Version your process templates
  • Keep integration documentation updated

Monitoring and Troubleshooting

If the sendMessage call does not behave as expected, first check the request URL, headers, payload, HTTP status code, and response body.

For deeper analysis, enable tracing on the BAW server. Trace can help identify issues such as an incorrect portType, wrong operation name, payload mapping problems, or correlation mismatches.

Example trace specification:

com.ibm.bpm.rest.*=all
com.ibm.ws.webcontainer.*=all

After enabling trace, reproduce the problem, review the server logs, and then reduce or disable tracing because detailed trace can generate large log files.

If the issue appears to be inside the BPEL engine, add a more detailed com.ibm.bpe.* trace temporarily, because it can generate a large amount of diagnostic output.

Common issues and solutions

  • Issue 1: 409 Conflict

A 409 Conflict usually means that BAW received the message, but could not deliver it to the process in the expected way. This can happen if the target process template is stopped, if the process is not currently waiting at the expected Receive activity, or if correlation values do not match an existing running instance.

What to check

      • the process template is started and deployed correctly
      • the process instance is waiting for the expected message
      • the correlation field is present in the payload
      • the correlation value matches the correct running instance
  • Issue 2: Wrapper element such as EVENTMSG

In some environments, the request body may need to include a wrapper element because the deployed message structure expects it. This is not simply a client preference. It depends on how the input message was defined in the interface and how BAW maps the incoming payload to that message.

What to check

      • the expected input message structure in the WSDL or XSD
      • whether the root JSON or XML element must be wrapped
      • whether the payload matches the message part name used by the interface
      • If a wrapper element is required, structure the payload exactly as defined by the deployed message model.
  • Issue 3: Port type not found

This error usually means the portType value in the REST request does not exactly match the WSDL definition used by the BPEL process. Even a small difference in the namespace or local name can prevent BAW from resolving the target operation.

What to check

      • the exact QName from the WSDL
      • the namespace URI
      • the local port type name
      • the operation name associated with that port type

When troubleshooting, always compare the REST request values directly with the deployed WSDL rather than entering them manually from memory.

Real-World Use Cases


The sendMessage API can be used in many integration scenarios where an external system needs to start or continue a BPEL process. A few common examples are:

  • Order processing
    Start an order fulfillment process when an order is submitted from a web or mobile application.
  • Customer onboarding
    Trigger an onboarding process when a new customer is created in a portal or CRM system.

Conclusion

The sendMessage REST API provides a practical way to connect external applications with BPEL processes in IBM BAW. Once the process interface, message structure, and correlation settings are defined correctly, customers can use standard HTTP tools such as curl to start new process instances or send messages to running ones. As with any integration scenario, success depends on matching the deployed process definition exactly and validating the request step by step during testing.

0 comments
24 views

Permalink