Instant Estimate +44(0)1908738254
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
22 October 2015

How to integrate K2 to a Webservice that requires security headers

In this article we will see how to connect to soap webservices with security headers from K2.

At present K2 (4.6.7) doesn’t support registering the webservices with security headers as a service instance.

There is a workaround to achieve this

K2 Automated Testing Software

BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.

 

Free K2 Five Upgrade Review

Create a classlibrary with the methods as below.  Create a static parametrised method ,So that we can use from workflow using code reference event.

public static string SendValues(string Parameter1,string Parameter2,string WebserviceURL,string Action)
 {
 try
 {
 httpwebrequest webrequest=httpwebrequest(string WebserviceURL,string Action);
XmlDocument soapEnvelopeXml=Createsoapxml(Parameter1,Parameter2);
PassSoapenvelopeintoWebRequest( soapEnvelopeXml,webRequest);
 return “Success”
 }
 catch(Exception ex)
 {
 return ex.message;
 }
 }

Build SOAP webservice as xml with your parameter values

public XMLDocument Createsoapxml(string Parameter1,string Parameter2)
 {
 xmldocument soapEnvelop=new xmldocument();
stringbuilder sbxml=new stringbuilder;

Build your SOAP with Envelope,Headers and body by passing the parameters as values

return soapEnvelop;
 }
public HttpWebRequest httpwebrequest(string URL,string Action)
 {
 HttpWebRequest request=(HttpWebRequest)WebRequest.Create(URL);
 request.headers.add(“soapaction”,”urn”+action);
 request.ContentType = "text/xml;charset="utf-8"";
 request.Accept = "text/xml";
 request.Method = "POST";
 return request;
 }
 PassSoapenvelopeintoWebRequest(xmldocument ,httpwebrequest)
 {
 using(stream stream=httpwebrequest .getrequeststream())
 {
 xmldocument.Save(stream)
 }
 }

You can use the above build class library dll in two ways from K2 –

  1. Using as a code reference event from workflow

a) Build the dll and add as reference to the process and check copy local , so that this dll will be copied to server while deploying to server.

b) Add code reference event and we can see the SendValues Static method and we can pass datafields as values as a parameters to this method
2. Using as a Smartobject in Smartforms or Workflow

a) build the dll and register it as a endpoint assemblies Service instance or as a custom service broker with required changes

b)generate smartobjects from service instance and use that in a smartforms or workflow

So,now you can pass the values from workflow or smartforms to Webservice with security headers.

Need further technical advice or support?