cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP API integration - WS Security - An invalid security token was provided

oliver_sherlock
Level 2
Hi, I am attempting to use a webservice API using blueprism. The API requires a username and password to be passed in the XML header . The full template envelope that is provided in the API documentation is as below: ---------------------------------------- ##USERNAME## ##PASSWORD## ##cnu_so_?## ? ? ##cng_so_?## ##Firstname Lastname## ##INDIVIDUAL## -------------------------------- After researching webservice integration and reading the following guide: https://portal.blueprism.com/system/files/product/productpublic/4.2/Blue%20Prism%20Development/Blue%20Prism%20User%20Guide%20-%20Web%20Services.pdf It appears that BP cannot support webservices that require ws security without code blocks. Therefore i followed the relevant sections (p42-52). # to summarise: I created a proxy class inserted code into the global code of the BO amended the global code as described in the guide imported the relevant namespaces created an action in the initialise page to feed in an environment variable containing the API URL created an action on a new page to envoke the API call in this action included the script from the guide labelled as for WS-Security i amended the code to make it specific to my class. My action stage code looks like this (VB) : 'BP inputs: CF1 (text) CF2 (text) N (text) NT(text) AI (text) GI (text) BP outputs: Out (text) 'initialise stage creates an instance of the proxy class called mWebService. the function to call is called screen which takes an object of type screenRequestV1 as an argument. -------- Dim c As New screenRequestV1() 'convert inputs to readable type for call Dim inputAI As String = AI c.assigneeIdentifier = inputAI Dim inputCF1 As String = CF1 c.customId1= inputCF1 Dim inputCF2 As String = CF2 c.customId2= inputCF2 Dim inputGI As String = GI c.groupIdentifier= inputGI Dim inputN As String = N c.name=inputN Dim inputNT As String = NT c.nameType = inputNT 'WS Security Dim token As New UsernameToken("XXXXXXX", "XXXXXXX", PasswordOption.SendPlainText) mWebService.SetClientCredential(Of UsernameToken)(token) Dim webServiceClientPolicy As New Policy() webServiceClientPolicy.Assertions.Add(New UsernameOverTransportAssertion()) mWebService.SetPolicy(webServiceClientPolicy) 'Call API Action Dim Results as String Results = mWebService.screen(c) Out = Results ----------- When I attempt to execute this action in a process, an exception is thrown: Internal : Could not execute code stage because exception thrown by code stage: An invalid security token was provided (An error happened processing a Username Token) I tested the API using Soap UI. In Soap UI I copied the template envelope, inserted the parameters and it successfully generated a response. Using Telerik Fiddlder, i can see that the blueprism action is sending the following request: ----------------- urn:uuid:9ae16a03-2537-40b0-92ba-c2f5cadeceba http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous XXXXXXX 2017-06-01T12:08:19Z 2017-06-01T12:13:19Z XXXXX XXXXXbktkjXlVF1DzC0UtiSR7Iw== 2017-06-01T12:08:19Z XXXX XXXXX XXXXX XXXXX XXXXX XXXXX ------------------------ The credentials that generate a correct response in SOAP UI are identical to the ones that are being sent by the BP process. So incorrect credentials are not the issue here. It looks like the XML sent by the blue prism process is different. Is there a way to further configure the envelope sent by the process? Can someone with a lot more SOAP API experience please advise on how I can get this API call to work? Thanks in advance
1 REPLY 1

oliver_sherlock
Level 2
I have isolated the issue to the 'Nonce' attribute that is being generated in the wsse header. The web service rejects requests with a superfluous nonce header, so the solution (from my research) appears to be either to create a custom WSE policy assertion or to talk to the API developers to accommodate requests with a Nonce tag in the wsse header.