While building servicetask\soap-service getting below error.Code downloaded from github.Appricaite your help

SEVERE: ENGINE-16004 Exception while closing command context: SPIN-01004 No matching data format detected
org.camunda.spin.spi.SpinDataFormatException: SPIN-01004 No matching data format detected
at org.camunda.spin.impl.logging.SpinCoreLogger.unrecognizableDataFormatException(SpinCoreLogger.java:53)
at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromReader(SpinFactoryImpl.java:127)
at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:50)
at org.camunda.spin.impl.SpinFactoryImpl.createSpinFromString(SpinFactoryImpl.java:103)
at org.camunda.spin.impl.SpinFactoryImpl.createSpin(SpinFactoryImpl.java:47)
at org.camunda.spin.Spin.S(Spin.java:64)
at jdk.nashorn.internal.scripts.Script$1$^eval_.:program(:7)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluateScript(SourceExecutableScript.java:114)
at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:60)
at org.camunda.bpm.engine.impl.scripting.ResourceExecutableScript.evaluate(ResourceExecutableScript.java:43)
at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:56)
at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:97)
at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:83)
at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:40)
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)

Hi @kedarik

the service (http://www.webservicex.net/globalweather.asmx) which is called in this example returns no data. So the unit test fails.

There is an issue: https://app.camunda.com/jira/browse/CAM-6091

Cheers
kristin

Hi Kristin,

Thanks for responding. Can I get any soap call working example code which is running fine.

Regards,
Kedari

Hi @kedarik,

you could adjust the existing example. Instead of using http://www.webservicex.net/globalweather.asmx?op=GetWeather, you could use the other operation of this webservice http://www.webservicex.net/globalweather.asmx?op=GetCitiesByCountry

Cheers
kristin

Hi Kristin,

Thanks for prompt response.I tried the same. Getting below error

Nov 28, 2017 3:20:03 PM org.camunda.commons.logging.BaseLogger logInfo
INFO: ENGINE-03065 Creating historyLevel property in database for level: HistoryLevelAudit(name=audit, id=2)
Nov 28, 2017 3:20:03 PM org.camunda.commons.logging.BaseLogger logInfo
INFO: ENGINE-00001 Process Engine default created.
Nov 28, 2017 3:20:24 PM org.camunda.commons.logging.BaseLogger logError
SEVERE: ENGINE-16006 BPMN Stack Trace:
ServiceTask_2 (activity-execute, ScopeExecution[8])
ServiceTask_2
^
|
StartEvent_1

Nov 28, 2017 3:20:24 PM org.camunda.commons.logging.BaseLogger logError
SEVERE: ENGINE-16004 Exception while closing command context: HTCL-02007 Unable to execute HTTP request
org.camunda.connect.ConnectorRequestException: HTCL-02007 Unable to execute HTTP request
at org.camunda.connect.httpclient.impl.HttpConnectorLogger.unableToExecuteRequest(HttpConnectorLogger.java:48)
at org.camunda.connect.httpclient.impl.AbstractHttpConnector.execute(AbstractHttpConnector.java:70)
at org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl.execute(SoapHttpConnectorImpl.java:48)
at org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl.execute(SoapHttpConnectorImpl.java:23)
at org.camunda.connect.impl.AbstractConnectorRequest.execute(AbstractConnectorRequest.java:42)
at org.camunda.connect.plugin.impl.ServiceTaskConnectorActivityBehavior$1.call(ServiceTaskConnectorActivityBehavior.java:57)

Regards,
Kedari

What are you changed to call the other webservice http://www.webservicex.net/globalweather.asmx?op=GetCitiesByCountry?

You have to do adjustments in ServiceTaskSoapTest.class, properties of the process model, soapEnvelope.ftl, etc.

Hope it helps!

Cheers
kristin

Hi Kristin,

I did the same. I have pasted bpmn ,ftl and testclient java code. Some thing i missed.

Still getting the same error.

Regards,invokeSoapService.bpmn (8.4 KB)

.ftl

<soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“XML Schema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body

${country}

</soap:Body>
</soap:Envelope>

ServiceTaskSoapTest.java

/* Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an “AS IS” BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */
    package org.camunda.bpm.example.servicetask.soap;

import java.util.HashMap;
import java.util.Map;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.task.Task;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
/**

  • @author Daniel Meyer

*/
public class ServiceTaskSoapTest {

@Rule
public ProcessEngineRule processEngineRule = new ProcessEngineRule();

@Test
@Deployment(resources={“invokeSoapService.bpmn”})
public void shouldInvokeService() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(“country”, “Germany”);

RuntimeService runtimeService = processEngineRule.getRuntimeService();
TaskService taskService = processEngineRule.getTaskService();

runtimeService.startProcessInstanceByKey("weatherForecast", variables);

Task task = taskService.createTaskQuery().singleResult();
Assert.assertNotNull(task);

int temperature = Integer.parseInt( taskService.getVariable(task.getId(), "temperature").toString() );
if(temperature >= 18) {
  Assert.assertEquals("UserTask_1", task.getTaskDefinitionKey());
} else {
  Assert.assertEquals("UserTask_2", task.getTaskDefinitionKey());
}

}

}

Kedari

Hi @kedarik,

It looks good so far.
You don’t need to change the inputParameter “url”. You have set the operation which should be executed in the header.
It is also necessary to adjust the script parseTemperature.js and the value of the output parameter forecast because you get another response format.

Cheers
kristin

Hi Kristin,

Thanks for reply.

In bpmn and .js files ,pasted below. Still I need to change any thing else.

invokeSoapService.bpmn (8.4 KB)

parseTemperature.js

// this script parses the temperature from the response

// remove prologue which cannot be parsed: ‘<?xml version="1.0" encoding="utf-16"?>’
var rawForecast = execution.getVariable(‘Country’);
var forecast = rawForecast.substring(rawForecast.indexOf("\n"));

var parsedTemperature = S(forecast).childElement(“City”).textContent();

// temperature looks like this: 68 F (20 C)
var regex = /((-?\d+) C)/;

// return only the temperature in C:
regex.exec(parsedTemperature)[1];

But getting error as

SEVERE: ENGINE-16004 Exception while closing command context: Error while evaluating expression: ${S(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function ‘S’
org.camunda.bpm.engine.ProcessEngineException: Error while evaluating expression: ${S(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function ‘S’
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:64)
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:48)
at org.camunda.bpm.engine.impl.el.ElValueProvider.getValue(ElValueProvider.java:36)
at org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter.execute(OutputParameter.java:43)

Regards,
Kedari

Hi Kristin,

I have changed as suggested. But still getting below error. Something missing.

SEVERE: ENGINE-16004 Exception while closing command context: Error while evaluating expression: ${S(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function 'S’
org.camunda.bpm.engine.ProcessEngineException: Error while evaluating expression: ${S(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function ’

changed code uploaded in git.

Regards,
kedari

Hi @kedarik,

your output parameter Table must have the value

        ${XML(response)
            .childElement("Body")
            .childElement("http://www.webserviceX.NET", "GetCitiesByCountryResponse")
            .childElement("GetCitiesByCountryResult")
            .textContent()}

In the parseTemperature script, you can get the variable with the following line.

var table = execution.getVariable('Table');

The variable table has the following example content.

<NewDataSet>
  <Table>
    <Country>Germany</Country>
    <City>Guetersloh</City>
  </Table>
  <Table>
    <Country>Germany</Country>
    <City>Brueggen</City>
  </Table>
  ...
</NewDataSet>

You have to rewrite the script parseTemperature because the response format it another one as from the weather request.

Cheers
kristin

Hi Kristin,

I tried with XML also. Getting below error .

SEVERE: ENGINE-16004 Exception while closing command context: Error while evaluating expression: ${XML(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function ‘XML’
org.camunda.bpm.engine.ProcessEngineException: Error while evaluating expression: ${XML(response)
.childElement(“Body”)
.childElement(“http://www.webserviceX.NET”, “GetCitiesByCountryResponse”)
.childElement(“GetCitiesByCountryResult”)
.textContent()}. Cause: Error invoking function ‘XML’
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:64)
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:48)
at org.camunda.bpm.engine.impl.el.ElValueProvider.getValue(ElValueProvider.java:36)

BPMN

invokeSoapService.bpmn (8.3 KB)

And my parseTemparature.js

var table = execution.getVariable(‘Table’);
var city = table.substring(table.indexOf("\n"));

var parsedCity = S(city).childElement(“City”).textContent();
var regex = /((-?\d+) C)/;

regex.exec(parsedCity)[1];

And my soapEnvolope.ftl

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:web=“http://www.webserviceX.NET”>
soapenv:Header/
soapenv:Body
web:GetCitiesByCountry

web:CountryName${country}</web:CountryName>
</web:GetCitiesByCountry>
</soapenv:Body>
</soapenv:Envelope>

and ServiceTaskSoapTest.java

public class ServiceTaskSoapTest {

@Rule
public ProcessEngineRule processEngineRule = new ProcessEngineRule();

@Test
@Deployment(resources={“invokeSoapService.bpmn”})
public void shouldInvokeService() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(“country”, “Germany”);

RuntimeService runtimeService = processEngineRule.getRuntimeService();
TaskService taskService = processEngineRule.getTaskService();

runtimeService.startProcessInstanceByKey("weatherForecast", variables);

Task task = taskService.createTaskQuery().singleResult();
Assert.assertNotNull(task);

int temperature = Integer.parseInt( taskService.getVariable(task.getId(), "temperature").toString() );
if(temperature >= 18) {
  Assert.assertEquals("UserTask_1", task.getTaskDefinitionKey());
} else {
  Assert.assertEquals("UserTask_2", task.getTaskDefinitionKey());
}

}

}

Regards,
kedari

mmhh, I can’t see the problem.

Please try the following:

  • Change something in the parseTemperature.js, save it
  • Execute the unit test

It looks like a caching problem regarding the process definition deployment.

Cheers
kristin

Dont know…why it is giving error. Can i get any working example from git or somewhre.

Hi @kedarik,

I look again deeper into your example and found two problems.

Please change the Content-Type in the Input Parameter header to

application/soap+xml;charset=UTF-8;action="http://www.webserviceX.NET/GetCitiesByCountry

and change the namespace in the soapEnvelope.ftl to

xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"

After that you can get the first City from the response with the following code in the parseTemperature.js

var table = execution.getVariable('Table');
print('TABLE:' + table);
var parsedCity = S(table).xPath('string(/NewDataSet/Table[1]/City[1])').string();
print('parsedCity: ' + parsedCity);

When you get the same, you have only to adjust the unit test class and the expressions on the sequence flows in the BPMN process. Then, it should work fine.

Maybe you could have a look in the other SOAP example

Cheers
kristin

Hi Kristin,

Thanks for reply. Soap call is working. Am seeing logs.

But unit test is failing . I have done below adjustments in expression and as well java test class. Still any changes required?

public class ServiceTaskSoapTest {

@Rule
public ProcessEngineRule processEngineRule = new ProcessEngineRule();

@Test
@Deployment(resources={“invokeSoapService.bpmn”})
public void shouldInvokeService() {

Map<String, Object> variables = new HashMap<String, Object>();
 variables.put("country", "Germany");

RuntimeService runtimeService = processEngineRule.getRuntimeService();
System.out.println("runtimeService:::"+runtimeService);
TaskService taskService = processEngineRule.getTaskService();
runtimeService.startProcessInstanceByKey("weatherForecast", variables);

Task task = taskService.createTaskQuery().singleResult();
Assert.assertNotNull(task);

String city = taskService.getVariable(task.getId(), “City”).toString();

if(city.equals("Berlin-Schoenefeld")) {
  Assert.assertEquals("UserTask_1", task.getTaskDefinitionKey());
} else {
  Assert.assertEquals("UserTask_2", task.getTaskDefinitionKey());
}

}

}

And BPMN expression for gateway expressions …
${City==‘Berlin-Schoenefeld’}

invokeSoapService.bpmn (8.4 KB)

Regards,
Kedari

Hi @kedarik,

did you return the correct value for the output parameter ‘City’ in your parseTemperature.js.
For that, please check the code below.

var table = execution.getVariable('Table');
// remove the process variable because after finishing the service task
// "Get Weather Forecast" the engine tries to write the "table" variable in the history
// but the history field is to small for the big XML result
execution.removeVariable('Table')
print('TABLE: ' + table);
S(table).xPath('string(/NewDataSet/Table[1]/City[1])').string();

The java test class looks fine.

Cheers
kristin

Hi Kristin,

Thanks for your support. It is working finally.

Is I need to change any changes for this process use.
When I am using in actual process…getting error as

"SEVERE [http-nio-8080-exec-3] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: ENGINE-03004 Exception while executing Database Operation ‘INSERT HistoricVariableInstanceEntity[9eb8bcae-d8fa-11e7-80c3-0a0027000003]’ with message ’

Error updating database. Cause: org.h2.jdbc.JdbcSQLException: Value too long for column “TEXT_ VARCHAR(4000)”: “STRINGDECODE(’\n

\n Germany\n Berlin-Schoenefeld\n
\n <Table… (8154)”; SQL statement:"

Regards,
Kedari

Hi @kedarik

I added the following hint in the parseTemperature.js.

That’s the reason, why you get the exception. Did you also delete the process variable ‘Table’ or how looks your parseTemperature.js?

Cheers
kristin