Search This Blog

2026-04-01

SAP Data Services Web Service (SOAP) Calling - Example

Product: SAP Data Services
Version: 4.2.x - 4.3.x

Overview

SAP BODS (Data Services) has DSMC browser GUI which offers web service functionality.  This allows external scheduler to easily integrate with it.

This blog post is going to show using PowerShell Invoke-WebRequest, so that you can see its  SOAP communication in low level.  For experience person, it should be easy to figure out how to configure the external job scheduler to use BODS WSDL 2.1 web service (SOAP) call.

For this example, I'm using following dummy value to illustrate

  • BODS URL: http://localhost:8080/DataServices/servlet/webservices?ver=2.1
  • Server hostname: localhost
  • Authentication Method: Build in Enterprise
  • Username: administrator
  • Password: hidden_hash_value
  • Job Server local repository name: LOCAL_REPO_DEV1
  • Job ID: 2
  • Going to simulate the OOTB web service call Get_BatchJob_Status, which will return 2 values of whether the web service call success or not (0=success), as well as job status in string of Running/Succussed/Error/Warning
    • BODS doc: https://help.sap.com/docs/SAP_DATA_SERVICES/ab33122a997f40d89e340549ff0bced8/5748962b6d6d1014b3fc9283b0e91070.html
Login is required to obtain session ID.  The session ID going to be used in subsequent web service call

For full SAP BODS web service reference doc, see https://help.sap.com/docs/SAP_DATA_SERVICES/ab33122a997f40d89e340549ff0bced8/574996556d6d1014b3fc9283b0e91070.html

Using PowerShell Invoke-WebRequest to Call BODS Web Service

1. Login

$headers1 = @{"SOAPAction" = "function=Logon"}

$soapBody1 = @"

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.businessobjects.com/DataServices/ServerX.xsd">

   <soapenv:Header/>

   <soapenv:Body>

      <ser:LogonRequest>

         <username>administrator</username>

         <password>hidden_hash_value</password>

         <cms_system>localhost</cms_system>

         <cms_authentication>secEnterprise</cms_authentication>

      </ser:LogonRequest>

   </soapenv:Body>

</soapenv:Envelope>

"@


$response1 = Invoke-WebRequest -UseBasicParsing -Method Post -ContentType "text/xml;charset=UTF-8" -Headers $headers1 -Body $soapBody1 http://localhost:8080/DataServices/servlet/webservices?ver=2.1

[xml]$xmlResponse1 = $response.Content

$dsmc_SessionID = $xmlResponse1.Envelope.Body.session.SessionID

$dsmc_SessionID


2. Call Get_BatchJob_Status

$headers2 = @{"SOAPAction" = "jobAdmin=Get_BatchJob_Status"}

$soapBody2 = @"

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.businessobjects.com/DataServices/ServerX.xsd">

   <soapenv:Header>

      <ser:session>

         <SessionID>$dsmc_SessionID</SessionID>

      </ser:session>

   </soapenv:Header>

   <soapenv:Body>

      <ser:batchJobStatusRequest>

         <runID>2</runID>

         <repoName>LOCAL_REPO_DEV1</repoName>

      </ser:batchJobStatusRequest>

   </soapenv:Body>

</soapenv:Envelope>

"@


$response2 = Invoke-WebRequest -UseBasicParsing -Method Post -ContentType "text/xml;charset=UTF-8" -Headers $headers2 -Body $soapBody2 http://localhost:8080/DataServices/servlet/webservices?ver=2.1

[xml]$xmlResponse2 = $response2.Content

$xmlResponse2.Envelope.Body.batchJobStatusResponse


localtypes                                              returnCode status
----------                                              ---------- ------
http://www.businessobjects.com/DataServices/ServerX.xsd 0          error

Using PowerShell New-WebServiceProxy to Call BODS Web Service

This is using SOAP web service call.

$url_dsmc = "http://localhost:8080/DataServices/servlet/webservices?ver=2.1&wsdlxml"
# First call to BODS web service server to get the wsdl
$response1 = New-WebServiceProxy -Uri $url_dsmc -Namespace dsmc_namespace

$dsmc_namespace = $dsmc.GetType().Namespace
$dsmc_conn_ops = New-Object -TypeName "$dsmc_namespace`.Connection_Operations"

$param = New-Object "dsmc_namespace.LogonRequest"
$param.username = "administrator"
$param.password = "hidden_hash_value"
$param.cms_system = "localhost"
$param.cms_authentication = "secEnterprise"

# 2nd call - Triggers logon, and it will return Session ID
# Stores the session_id for next call
$session_id = $dsmc_conn_ops.Logon($param)

# Next is to check Job status
# Local repo: LOCAL_REPO_DEV1
# Job's run ID 2
$job_request = New-Object "dsmc_namespace.batchJobStatusRequest"
$job_request.repoName = "LOCAL_REPO_DEV1"
$job_request.runID = 2
$dsmc_Batch_Job_Admin = New-Object -TypeName "$dsmc_namespace`.Batch_Job_Admin"
$dsmc_Batch_Job_Admin_namespace = $dsmc_conn_ops.GetType().Namespace
$dsmc_Batch_Job_Admin.sessionValue = $session_id

# 3rd time calling BODS SOAP web service
$dsmc_Batch_Job_Admin.Get_BatchJob_Status($job_request)

Output
returnCode status
---------- ------
         0 error

Analysis

The parameter and web service methods required to referring to BODS web service wsdl.  For example:
  1. New-Object "dsmc_namespace.LogonRequest" - wsdl contains "<xsd:element name="LogonRequest">" with complexType, and 4 string parameters of username , password , cms_system , cms_authentication 
  2. Logon() - wsdl indicated that the pass-in parameter is call "LogonRequest" directly under the root. It does not belongs to any class (PowerShell), or wsdl:binding (wsdl)
  3. PowerShell needs to call New-Object -TypeName $dsmc_namespace`.<wsdl:binding> to switch between 5 different binding of Batch_Job_Admin, Repo_Operations, Batch_Jobs, Connection_Operations, Realtime_Service_Admin (default)

No comments: