Skip to content

A Java-based SOAP worker for Orkes Conductor that extends HTTP worker functionality. Automatically converts JSON payloads to XML, wraps them in SOAP envelopes, makes HTTP POST requests, and returns both raw XML and converted JSON responses.

License

Notifications You must be signed in to change notification settings

conductor-oss/SoapWorker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Orkes Conductor SOAP Worker

A Java-based SOAP worker for Orkes Conductor that extends HTTP worker functionality to handle SOAP calls with automatic JSON/XML conversion.

Features

  • JSON to XML Conversion: Automatically converts JSON payloads to XML format
  • SOAP Envelope Wrapping: Wraps payloads in standard SOAP envelope
  • HTTP POST Support: Makes SOAP calls via HTTP POST (as SOAP requires)
  • Dual Response Format: Returns both raw XML and converted JSON responses
  • Flexible Input: Accepts both JSON and XML payloads

Requirements

  • Java 23 or higher
  • Gradle 8.10 or higher
  • Orkes Conductor account with API credentials

Building

./gradlew build

Or on Windows:

gradlew.bat build

This will create a JAR file in the build/libs/ directory with all dependencies included.

To create a fat JAR (with all dependencies):

./gradlew jar

Testing

Run the unit tests:

./gradlew test

The tests verify all core functionality:

  • JSON to XML conversion
  • XML payload handling (no conversion)
  • SOAP envelope wrapping
  • HTTP POST requests
  • Response with both XML and JSON output

Configuration

The worker can be configured using environment variables or system properties:

  • CONDUCTOR_SERVER or conductor.server: Conductor server URL (default: https://api.orkes.io/api)
  • CONDUCTOR_KEY or conductor.key: Your Conductor API key (required)
  • CONDUCTOR_SECRET or conductor.secret: Your Conductor API secret (required)
  • WORKER_THREAD_COUNT or worker.thread.count: Number of worker threads (default: 10)

Running

export CONDUCTOR_SERVER="https://api.orkes.io/api"
export CONDUCTOR_KEY="your-api-key"
export CONDUCTOR_SECRET="your-api-secret"

java -jar build/libs/soap-worker-1.0.0.jar

Or with system properties:

java -Dconductor.server=https://api.orkes.io/api \
     -Dconductor.key=your-api-key \
     -Dconductor.secret=your-api-secret \
     -jar build/libs/soap-worker-1.0.0.jar

Task Definition

Before using the worker, you need to define the task in Orkes Conductor:

  1. Navigate to Definitions > Task in the Conductor UI
  2. Click Define task
  3. Set the Name to SOAP
  4. Set the Type to SIMPLE
  5. Configure other parameters as needed
  6. Save the task

Task Input Parameters

The SOAP worker accepts the following input parameters:

Parameter Type Required Description
url String Yes The SOAP endpoint URL
payload String Yes The request payload (JSON or XML string)
isJson Boolean No Whether the payload is JSON (default: true)
soapAction String No SOAPAction header value
headers String No Additional HTTP headers as JSON string (e.g., {"Authorization": "Bearer token"})

Task Output

The worker returns a map with the following keys:

  • xml: Raw XML response from the SOAP service
  • json: JSON representation of the XML response
  • error: Error message (only present if an error occurred)

Usage Examples

Example 1: JSON Payload (Default)

{
  "url": "https://example.com/soap-service",
  "payload": "{\"name\": \"John\", \"age\": 30}",
  "isJson": true,
  "soapAction": "http://example.com/GetUser"
}

Example 2: XML Payload

{
  "url": "https://example.com/soap-service",
  "payload": "<user><name>John</name><age>30</age></user>",
  "isJson": false,
  "soapAction": "http://example.com/GetUser"
}

Example 3: With Custom Headers

{
  "url": "https://example.com/soap-service",
  "payload": "{\"name\": \"John\", \"age\": 30}",
  "isJson": true,
  "soapAction": "http://example.com/GetUser",
  "headers": "{\"Authorization\": \"Bearer token123\", \"X-Custom-Header\": \"value\"}"
}

How It Works

  1. Input Processing: The worker receives a task with a payload (JSON or XML)
  2. Conversion: If the payload is JSON, it's converted to XML format

    Note: The JSON to XML conversion is a direct, simple conversion without any intelligence or schema mapping. The JSON structure is converted directly to XML elements (e.g., {"name": "John"} becomes <name>John</name>). For complex use cases or specific SOAP schema requirements, you may want to customize the convertJsonToXml method in SoapWorker.java to implement your own conversion logic.

  3. SOAP Envelope: The XML payload is wrapped in a standard SOAP envelope:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Body>
          <!-- Your payload here -->
       </soapenv:Body>
    </soapenv:Envelope>
  4. HTTP POST: Makes an HTTP POST request to the specified URL with:
    • Content-Type: text/xml; charset=UTF-8
    • SOAPAction header (if provided)
    • Any additional custom headers
  5. Response Processing:
    • Returns the raw XML response
    • Converts the XML response to JSON format
  6. Output: Returns both XML and JSON in the task output

Error Handling

If an error occurs during execution:

  • The error field will contain the error message
  • Both xml and json fields will be null
  • The error is also logged for debugging

Permissions

Make sure your Conductor application has:

  • Worker role enabled
  • Execute permission for the SOAP task

License

This project is provided as-is for use with Orkes Conductor.

About

A Java-based SOAP worker for Orkes Conductor that extends HTTP worker functionality. Automatically converts JSON payloads to XML, wraps them in SOAP envelopes, makes HTTP POST requests, and returns both raw XML and converted JSON responses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages