Hitachi ID SOAP Web Services API – Create and Submit Workflow Request (WFPDRSubmit) Using Python

In this article I will be showing how to use Python programming language to create a Workflow Request and Submit it for processing by calling the WFPDRSubmit Function. This function is among the many functions exposed by the Hitachi ID SOAP Web Services API.

This blog entry piggybacks on the introduction to Hitachi ID SOAP API previously published at Hitachi ID Soap Web Services API – Calling the Login Function Using Python.

Purpose

The WFPDRSubmit function will accept all the attributes required for successful creation and submission of a Request. The Request will in turn be submitted to and processed by a Predefined Request(PDR) which is specified as part of the Request attribute . Below is the general form of the input and output for this function

Request:

<WFPDRSubmitRequest>
<recipid>...</recipid>
<recippass>...</recippass>
<recipemail>...</recipemail>
<requesteremail>...</requesteremail>
<requestreason>...</requestreason>
<preqid>...</preqid>
<reserveid>...</reserveid>
<maqid>...</maqid>
<parentbatchsig>...</parentbatchsig>
<sessdat>...</sessdat>
<input>...</input>
</WFPDRSubmitRequest>

<WFPDRSubmit_vectorInput>
<attrkey>...</attrkey>
<value>...</value>
</WFPDRSubmit_vectorInput>

Response:

<WFPDRSubmitResponse>
<errmsg>...</errmsg>
<rc>...</rc>
<sessdat>...</sessdat>
<output>...</output>
</WFPDRSubmitResponse>
<WFPDRSubmit_vectorOutput>
<batchsig>...</batchsig>
</WFPDRSubmit_vectorOutput>

Prerequisites

 

  •  Hitachi ID Suite 10.x and above
  •  Corporate Reference Build
  •  Python

Process

Assuming that the SOAP API Service is already setup per the information provided in my previous post, a fully functional Predefined Request(PDR) is required before the WFPDRSubmit function can be executed successfully. We will be using the NEW-EMPLOYEE PDR which comes pre-configured by installing the Corporate Reference Build (Read the Hitachi ID documentation titled “Component-Reference”) to know more.

Execute the following python script

from zeep import Client
from idmlib.components import component_log

log = component_log.getChild(__name__)

class IDAPI_SOAP_WEBSERVICE:

    def __init__(self):
        self.instancename = '<INSTANCENAME>'
        self.servername = '<SERVERNAME>'
        self.sessdat = None
        log.info('starting SOAP Client...')
        wsdl = 'http://{}/{}/idapi/wsdl'.format(self.servername, self.instancename)
        log.info('wsdl : ' + wsdl)
        self.iw =  Client(wsdl=wsdl)

    def login(self):
        log.info('start Login...')
        request_data = {
            'userid': 'IDAPI_SOAP_USER',
            'password': '******',
            'isadmin': 1,
            'options': '',
            'sessdat': self.sessdat
        }
        return self.iw.service.Login(request_data)

    def wfpdrsubmitfunction(self, sessdat):
        log.info('Submitting PDR  requesting info...')
        wf_input = {'WFPDRSubmit_vectorInput':[{'attrkey': 'FIRST_NAME','value': 'John',},{'attrkey': 'LAST_NAME','value': 'Doe',}]}
        request_data= {
            'recipid': '<recipientAccountname>',
            'recipemail': '<recipientEmail>',
            'requesteremail': '<requesterEmail>',
            'requestreason': '<requesterReason>',
            'preqid': 'NEW-EMPLOYEE',
            'reserveid' : '',
            'maqid': '',
            'parentbatchsig': '1',
            'sessdat': sessdat,
            'input': wf_input
        }
        return self.iw.service.WFPDRSubmit(request_data)
		
	def logout(self, sessdat):
        log.info('start Logout...')
        request_data = {'sessdat': sessdat}
        return self.iw.service.Logout(request_data)

#login, get sessdat
print('logging in.......>')
loginresponse = IDAPI_SOAP_WEBSERVICE().login()
print(loginresponse)

#logged in,
print('Getting session data')
sessdat = loginresponse['sessdat']
print(sessdat)

#Submitting the request
print('submitting the request..##..>')
wfrequestresponse = IDAPI_SOAP_WEBSERVICE().wfpdrsubmitfunction(sessdat)
print(wfrequestresponse)

#logout, send sessdat
print('loging out <.......')
logoutresponse = IDAPI_SOAP_WEBSERVICE().logout(sessdat)
print(logoutresponse)

Once the WFPDRSubmit function is successfully executed, the Request entry can be viewed using the Reporting feature of the HiIDM Suite.

Conclusion
A typical scenario where this function is useful is Bulk provisioning where large amount of data needs to be processed via a specific PDR in Hitachi ID Suite from other enterprise applications.