Run the Blue Prism process using Python (SOAP)

Introduction

Blue Prism exposes processes (robots) as WebServices and can be executed externally. In this article, I'll write a client in Python and call a Blue Prism process.

There are two prerequisites for running a process exposed as a WebService. [Separate article](https://qiita.com/muuuuuwa/items/8fdd65eb0e0b71263644#blue-prism-%E3%81%AE%E3%82%B5%E3%83%BC%E3%83%90%E3% 83% BC% E3% 82% B5% E3% 83% BC% E3% 83% 93% E3% 82% B9% E3% 82% 92% E8% B5% B7% E5% 8B% 95% E3% 81% Let's set the prerequisites by referring to 99% E3% 82% 8B).

  • A. The Blue Prism server service is running
  • B. There are runtime resources started on the public switch

Publish the process as a WebService

In the interactive client, open the "System" tab and select "Process> Publish". Click "Publish Process" displayed on the right side of the screen. publish_process_00.jpg

Select the process you want to publish as a WebService (here "logSample") and click the "Next" button. publish_process_01.jpg

Confirm the "Public name of the process" and click the "Finish" button. publish_process_02.jpg

Considering the actual operation, it seems necessary to separate the main body of the long process and the process that only accepts the process, and make it so that the response is returned synchronously to the WebService client.

Create a client in Python

Download the WSDL.

The WSDL of the published process is published by ** Runtime Resources ** (there is no API for the server to return a WSDL, isn't it?). This time we are exposing the runtime resources on port 8183, so open http://127.0.0.1:8183/ws/ in your browser. Then, a list of processes published as WebService will be displayed as shown below. webservice_list.jpg

This time, download and use the WSDL file from this page. Save it as `` `logSample.xml``` in the directory where you develop your Python script.

Install the required Python modules

Prepare the Python script development environment with Pipenv.

% pipenv --python 3.7
Creating a virtualenv for this project…
Pipfile: /Users/m-nakamura/Documents/blueprism-process-invoker_/Pipfile
Using /Users/m-nakamura/.pyenv/versions/3.7.4/bin/python3 (3.7.4) to create virtualenv…
⠹ Creating virtual environment...Using base prefix '/Users/m-nakamura/.pyenv/versions/3.7.4'
New python executable in /Users/m-nakamura/.local/share/virtualenvs/blueprism-process-invoker_-30X4pztG/bin/python3
Also creating executable in /Users/m-nakamura/.local/share/virtualenvs/blueprism-process-invoker_-30X4pztG/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /Users/m-nakamura/.pyenv/versions/3.7.4/bin/python3

✔ Successfully created virtual environment!
Virtualenv location: /Users/m-nakamura/.local/share/virtualenvs/blueprism-process-invoker_-30X4pztG
Creating a Pipfile for this project…

Install the required libraries. To use SOAP with Python, Zeep seems to be recommended, so I will use it. Zepp is convenient!

% pipenv install zeep
Installing zeep…
Adding zeep to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (663ec6)!
Installing dependencies from Pipfile.lock (663ec6)…
    ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 15/15 — 00:00:03
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

One of Zepp's features is the ability to look up the contents of a WSDL (https://python-zeep.readthedocs.io/en/master/index.html#getting-started). If you try, you will see that the input and output parameters of the process are of type xsd: string.

% pipenv run python -m zeep logSample.xml 

Prefixes:
     xsd: http://www.w3.org/2001/XMLSchema
     ns0: urn:blueprism:webservice:logsample

Global elements:


Global types:
     xsd:anyType
     xsd:ENTITIES
     xsd:ENTITY
     xsd:ID
     xsd:IDREF
     xsd:IDREFS
     xsd:NCName
     xsd:NMTOKEN
     xsd:NMTOKENS
     xsd:NOTATION
     xsd:Name
     xsd:QName
     xsd:anySimpleType
     xsd:anyURI
     xsd:base64Binary
     xsd:boolean
     xsd:byte
     xsd:date
     xsd:dateTime
     xsd:decimal
     xsd:double
     xsd:duration
     xsd:float
     xsd:gDay
     xsd:gMonth
     xsd:gMonthDay
     xsd:gYear
     xsd:gYearMonth
     xsd:hexBinary
     xsd:int
     xsd:integer
     xsd:language
     xsd:long
     xsd:negativeInteger
     xsd:nonNegativeInteger
     xsd:nonPositiveInteger
     xsd:normalizedString
     xsd:positiveInteger
     xsd:short
     xsd:string
     xsd:time
     xsd:token
     xsd:unsignedByte
     xsd:unsignedInt
     xsd:unsignedLong
     xsd:unsignedShort

Bindings:
     Soap11Binding: {urn:blueprism:webservice:logsample}logSampleSoapBinding

Service: logSampleService
     Port: logSampleSoap (Soap11Binding: {urn:blueprism:webservice:logsample}logSampleSoapBinding)
         Operations:
            logSample(message: xsd:string) -> outmessage: xsd:string

Create a Python script with the name `` `logsample.py``` in the same directory where you saved the WSDL file with the name logsample.xml.

from pathlib import Path
from zeep import Client

from requests import Session
from requests.auth import HTTPBasicAuth
from zeep.transports import Transport

# Set Blue Prism credentials
session = Session()
session.auth = HTTPBasicAuth('admin', 'admin_password_xxxxxx')

# Get the path of the WSDL file saved in the same directory
wsdl = Path.cwd() / "logSample.xml"
client = Client(str(wsdl), transport=Transport(session=session))
service = client.service

# Specify the input parameters of the logSample service with named arguments
res = service.logSample(message="hogehoge")

# A single string output parameter is returned directly as a response
print(type(res))
print(res)

Run the process

Run the script in the directory where the `` `logSample.py``` you created earlier is stored. The output parameters of the process are output, and you can confirm that the process has been executed.

% pipenv run python logSample.py
<class 'str'>
exec at 04/01/20 23:25:12hogehoge

You can also see that it was executed from the interactive client. Open the "Controls" tab and open "Session Management> Today". process_results.jpg

problem

After trying the function, I was concerned about the following points.

Recommended Posts

Run the Blue Prism process using Python (SOAP)
Try using the Python Cmd module
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Behind the flyer: Using Docker with Python
Tweet using the Twitter API in Python
Where is the python instantiation process written?
Working with OpenStack using the Python SDK
Reboot the router using Python, Selenium, PhantomJS
Run servomotor on Raspberry Pi 3 using python
Set the process name of the Python program
python setup.py test the code using multiprocess
[Python] Smasher tried to make the video loading process a function using a generator
Aggregate test results using the QualityForward Python library
vprof --I tried using the profiler for Python
[Python] Let's execute the module regularly using schedule
Creating numbering process using python in DynamoDB Local Numbering process
Python: Try using the UI on Pythonista 3 on iPad
Until you run the changefinder sample in python
Try using the Python web framework Tornado Part 1
Send Gmail at the end of the process [Python]
I tried using the Datetime module by Python
Pre-process the index in Python using Solr's ScriptUpdateProcessor
Operate the schedule app using python from iphone
Sound the buzzer using python on Raspberry Pi 3!
Try using the collections module (ChainMap) of python3
Run a Python file from html using Django
Try using the Python web framework Tornado Part 2
Run a python script from excel (using xlwings)
Try using the DropBox Core API in Python
Start using Python
I made a login / logout process using Python Bottle.
Cut a part of the string using a Python slice
[AWS IoT] Register things in AWS IoT using the AWS IoT Python SDK
Run with CentOS7 + Apache2.4 + Python3.6 for the time being
The process of installing Atom and getting Python running
Initial settings when using the foursquare API in python
Pass the authentication proxy through communication using python urllib3
Determine the threshold using the P tile method in python
Send and receive Gmail via the Gmail API using Python
Explanation of the concept of regression analysis using Python Part 1
Write data to KINTONE using the Python requests module
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
Process csv data with python (count processing using pandas)
[Python] Mask the image into a circle using Pillow
[Introduction to Python] How to stop the loop using break?
Explanation of the concept of regression analysis using Python Extra 1
Using the National Diet Library Search API in Python
Study from the beginning of Python Hour8: Using packages
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
A little bit from Python using the Jenkins API