How to SOAP on http/https?
A. Testing HTTP with SOAP request:
- Download SoapUI version 5.5.0 from here and install it with default settings:
- Create from File > New SOAP project. Give it a Name and use the following web service as Initial WSDL. Check “Create sample requests for all operations?”:
- Right click the first binding and select Generate SOAP Mock Service:
- Give a name to the service (in this case SoapNumberService) and enable it from the Start button
- Start Service
- Double-click the first binding, navigate to the second tab “Service Endpoints”, and check that there are 2 endpoints added (online and local):
- On the endpoint (our named binding which in this case is SoapNumberService) modify the Request and the Response Body .
Double-Click the Response1 and the edit the ? for the request, and the ? for the response values. Check example:
- Copy the local endpoint, in our case: http://end_point:8088/mockNumberConversionSoapBinding . To test this press the run button and check Request and Response message.
- Click send and notice the response > response is working.
- From UiPath Studio > New Project which uses the UiPath.Web.Activities, version 1.4.4 as dependency. Add a SOAP request Activity and configure it as following:
- Service Description > Add your binding address + “.asmx?wsdl” (http://end_point:8088/mockNumberConversionSoapBinding.asmx?wsdl )
- Press Get to retrieve the Data
- Pick the method with modified body, in our case “NumberToDollars”
- Press Invoke and check the response
B. Testing HTTPS with SOAP request:
- Studio is configured to validate the trust chain of server certificate that it connects to. If the certificate is issued by a public certificate authority, it will work without any further configurations. Here is an example that works directly, where the certificate is issued by Digicert authority
- If the certificate is self signed/private it must be added as a trusted certificate into the local machine/user certificate store (on the machine running Studio).
- To secure the mock service previously created via SSL, first generate a keystore with private and public keys. To do this, use the keytool command-line utility that is included in the JDK installation (see below steps).
Note: If JDK is not installed, it can be downloaded from the Oracle web site
- Open the command prompt and navigate to the bin folder in the JDK folder (for example, C:\java\jdk1.8.0_112)
- Generate a keystore containing our private/public key pair:
Note: The Certificate for target MUST correspond with the site name.
- If the certificate does not have exactly the same name as the site, in the Issued to and Issued By field, Studio will fail to verify it and will not be able to communicate with the SOAP endpoint
- In this case, issue a certificate for our “hostname” machine. For this open a CMD window and type “Hostname”
- Proceed creating the JKS keystore. From an elevated CMD, run:
- keytool -genkey -alias soapui -keyalg RSA -keystore mock.keystore
- Enter a password for the new keystore and provide the utility with the required information. The first 3 fields it MUST be completed with the “Hostname” or site name:
- At the end when asking if the information provided is correct, type “YES” to create the JKS keystore
- A certificate with the HostName will be created, and could be used for testing.
- Note: If the certificate already exists and an import into the JSK store is want, it can be done by running the command:
- keytool -import -alias soapui -file soapui.cer -keystore mock.truststore
- In there check “Enable Mock SSL”, put the port 8443.
- Specify the path to the created keystore and the password, as well as the password for the key:
- Test the HTTPS endpoint on port 8443. From the first binding copy the address and change HTTP to HTTPS and port 8088 to 8443. Press play to test the response:
- Import the certificate into the local machine/user certificate store, for Studio to trust it. It can also be done manually with the following instruction from here
It could be also done via Internet Explorer:
- Open Internet Explorer and navigate to the mentioned endpoint adding the ?WSDL condition, eg: https://orch2018:8443/mockNumberConversionSoapBinding?WSDL
IE it will give a certificate error. This is because the browser is looking if the certificate has been installed as a trusted certificate into the local machine/user certificate store.
- Install it directly from IE, by clicking on the lock Sign > View Certificates:
- Once the certificate is displayed click on “Install Certificate” > Select “Local Machine” > “Place all certificates in the following store” > Browse > “Trusted Root Certification Authorities”:
- *Note: If the Install Certificate option is not displayed go to IE > Internet Options > Security > Uncheck the “Enable Protected Mode” Option:
- Close and open IE again > navigate to the site and now, no error message should be received
- Now, the automation on Studio using SOAP over HTTPS is ready and can be started.