Bonita BPM 6.x: Consume soap call and use element content for gateway

1
0
-1

Hello everyone,

I'm new to BonitaBPM. I designed an easy process with only a service task (with a web service SOAP connector) and a gateway. The application successfully receives the web service call from Bonita. The application tells me that a response has been sent back to Bonita. The problem is that I have no idea how to consume the soap message. I only want to use the content of one element in order to make the decision at the gateway. I found the response configuration (where I check the 'Returns envelope' or 'Returns body' checkbox) and the output operation. I don't know what kind of Groovy script I have to use.

Can someone please help me?

Thanks in advance!

2 answers

1
0
-1

With that code you can get the whole soap envelope, then you can parse and get the value you want to retrieve in a string and cast to the desired type.

import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.sax.SAXSource; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; try{ StringWriter sw = new StringWriter(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.transform((SAXSource) sourceResponse, new StreamResult(sw)); String result = sw.toString(); if(result!=null && !result.isEmpty()) { return sw.toString(); } } catch(Exception e) { return e.toString() }

Comments

Submitted by romario.lodder on Wed, 05/07/2014 - 22:40

Hi,

Thanks for all your help! Now I get at least something back (it isn't what I've expected though). I get a :

javax.xml.transform.TransformException: java.lang.NullPointerException

When I test my wsdl with SOAPUI (and mule up and running), then I'm receiving a correct soap response.

Do you think this is an issue in my Bonita flow conf or in my Mule project (where I expose my webservice from).

Once again, thanks for your help. You can also mail me directly I've that is easier for you :) (it's romariolodder@gmail.com).

1
0
-1

Maybe you want to retrieve the webservice return value.

That code worked for me (bonita v 6.2.2)

Put that code in a groovy expression and save it into a variable.

import javax.xml.transform.dom.DOMResult; import javax.xml.transform.Source; import javax.xml.transform.TransformerFactory; import org.w3c.dom.Document; Source source = sourceResponse; DOMResult result = new DOMResult(); TransformerFactory.newInstance().newTransformer().transform(source, result); return result.getNode().getChildNodes().item(0).getTextContent();

Comments

Submitted by romario.lodder on Wed, 05/07/2014 - 10:52

Thanks for your response. What kind of variable should I use? Just a java.util.string? And how can I get the content from a specific element (for example: rep:status)?

Notifications