You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by sa...@apache.org on 2018/01/30 10:20:54 UTC
[08/14] ode git commit: Add initial BPEL REST extension activities
bundle and related tests
Add initial BPEL REST extension activities bundle and related tests
Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/f6ab51fe
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/f6ab51fe
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/f6ab51fe
Branch: refs/heads/master
Commit: f6ab51fe357258aa8ab4bfc65c35252e2d10bf5f
Parents: b31d36a
Author: hahnml <ha...@users.noreply.github.com>
Authored: Fri Jan 12 16:27:31 2018 +0100
Committer: hahnml <ha...@users.noreply.github.com>
Committed: Mon Jan 15 13:15:32 2018 +0100
----------------------------------------------------------------------
Rakefile | 14 +-
.../Bpel4RestLightExtensionBundle.java | 50 ++++
.../bpel4restlight/Bpel4RestLightOperation.java | 101 +++++++
.../bpel4restlight/Bpel4RestLightUtil.java | 295 +++++++++++++++++++
.../bpel4restlight/MethodAttribute.java | 31 ++
.../bpel4restlight/http/HighLevelRestApi.java | 196 ++++++++++++
.../bpel4restlight/http/HttpMethod.java | 28 ++
.../http/HttpResponseMessage.java | 62 ++++
.../bpel4restlight/http/LowLevelRestApi.java | 91 ++++++
.../ode/test/RestExtensionActivitiesTest.java | 269 +++++++++++++++++
.../TestPostExtActWithWrongURL.bpel | 100 +++++++
.../TestPostExtActWithWrongURL.wsdl | 73 +++++
.../2.0/TestPostExtActWithWrongURL/deploy.xml | 30 ++
.../2.0/TestPostExtActWithWrongURL/restApi.xsd | 19 ++
.../TestRestDeleteExtAct.bpel | 89 ++++++
.../TestRestDeleteExtAct.wsdl | 73 +++++
.../bpel/2.0/TestRestDeleteExtAct/deploy.xml | 30 ++
.../bpel/2.0/TestRestDeleteExtAct/restApi.xsd | 12 +
.../2.0/TestRestDeleteExtAct/test.properties | 23 ++
.../TestRestExtActComplexTypeVar.bpel | 90 ++++++
.../TestRestExtActComplexTypeVar.wsdl | 73 +++++
.../2.0/TestRestExtActComplexTypeVar/deploy.xml | 30 ++
.../test.properties | 23 ++
.../TestRestExtActStatusCode.bpel | 90 ++++++
.../TestRestExtActStatusCode.wsdl | 73 +++++
.../2.0/TestRestExtActStatusCode/deploy.xml | 30 ++
.../2.0/TestRestExtActStatusCode/restApi.xsd | 12 +
.../TestRestExtActStatusCode/test.properties | 23 ++
.../TestRestGetExtAct/TestRestGetExtAct.bpel | 84 ++++++
.../TestRestGetExtAct/TestRestGetExtAct.wsdl | 73 +++++
.../bpel/2.0/TestRestGetExtAct/deploy.xml | 30 ++
.../bpel/2.0/TestRestGetExtAct/test.properties | 23 ++
.../TestRestPostExtAct/TestRestPostExtAct.bpel | 100 +++++++
.../TestRestPostExtAct/TestRestPostExtAct.wsdl | 73 +++++
.../bpel/2.0/TestRestPostExtAct/deploy.xml | 30 ++
.../bpel/2.0/TestRestPostExtAct/restApi.xsd | 19 ++
.../bpel/2.0/TestRestPostExtAct/test.properties | 23 ++
.../TestRestPostExtAct2/TestRestPostExtAct.bpel | 94 ++++++
.../TestRestPostExtAct2/TestRestPostExtAct.wsdl | 73 +++++
.../bpel/2.0/TestRestPostExtAct2/deploy.xml | 30 ++
.../bpel/2.0/TestRestPostExtAct2/restApi.xsd | 19 ++
.../2.0/TestRestPostExtAct2/test.properties | 23 ++
.../TestRestPutExtAct/TestRestPutExtAct.bpel | 100 +++++++
.../TestRestPutExtAct/TestRestPutExtAct.wsdl | 73 +++++
.../bpel/2.0/TestRestPutExtAct/deploy.xml | 30 ++
.../bpel/2.0/TestRestPutExtAct/restApi.xsd | 19 ++
.../bpel/2.0/TestRestPutExtAct/test.properties | 23 ++
47 files changed, 2965 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index 3ae6838..fab841a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -102,7 +102,7 @@ define "ode" do
libs = projects("axis2", "bpel-api", "bpel-compiler", "bpel-connector", "bpel-dao",
"bpel-epr", "bpel-nobj", "bpel-obj", "bpel-ql", "bpel-runtime", "scheduler-simple",
"bpel-schemas", "bpel-store", "dao-hibernate", "jca-ra", "jca-server",
- "utils", "dao-jpa", "agents", "clustering"),
+ "utils", "dao-jpa", "agents", "clustering", "bpel-rest-extensions"),
AXIS2_ALL, ANNONGEN, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.fileupload, COMMONS.io, COMMONS.httpclient, COMMONS.beanutils,
COMMONS.lang, COMMONS.pool, DERBY, DERBY_TOOLS, JACOB, JAXEN, JAVAX.activation, JAVAX.ejb, JAVAX.javamail,
JAVAX.connector, JAVAX.jms, JAVAX.persistence, JAVAX.transaction, JAVAX.stream, JIBX,
@@ -323,7 +323,7 @@ define "ode" do
SPRING_TEST, COMMONS.codec, SLF4J, LOG4J2
test.using :properties=>{ "org.apache.ode.autoRetireProcess"=>"true" }
- test.with projects("bpel-nobj", "bpel-obj", "bpel-schemas", "bpel-scripts"),
+ test.with projects("bpel-nobj", "bpel-obj", "bpel-schemas", "bpel-scripts", "bpel-rest-extensions"),
COMMONS.collections, COMMONS.lang, DERBY, JACOB, JAVAX.connector,
JAVAX.stream, JAVAX.transaction, JAVAX.connector, JAXEN, HSQLDB, SAXON, XERCES, XMLBEANS, XALAN, GERONIMO.transaction, SPRING, HIBERNATE, DOM4J, H2::REQUIRES, JACKSON
@@ -514,7 +514,7 @@ define "ode" do
# libs = artifacts(package(:jar),
# projects("bpel-api", "bpel-api-jca", "bpel-compiler", "bpel-connector", "bpel-dao",
# "bpel-epr", "jca-ra", "jca-server", "bpel-nobj", "bpel-ql", "bpel-runtime",
-# "scheduler-simple", "bpel-schemas", "bpel-store", "dao-hibernate", "dao-jpa", "utils", "agents"),
+# "scheduler-simple", "bpel-schemas", "bpel-store", "dao-hibernate", "dao-jpa", "utils", "agents", "bpel-rest-extensions"),
# ANT, AXIOM, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.dbcp, COMMONS.lang, COMMONS.pool,
# COMMONS.primitives, DERBY, GERONIMO.connector, GERONIMO.transaction, JACOB, JAVAX.connector,
# JAVAX.ejb, JAVAX.jms, JAVAX.persistence, JAVAX.stream, JAVAX.transaction, JAXEN, OPENJPA,
@@ -647,7 +647,7 @@ define "ode" do
# define "jbi-bundle" do
# ode_libs = artifacts(projects("bpel-api", "bpel-api-jca", "bpel-compiler", "bpel-connector", "bpel-dao", "bpel-epr",
# "jca-ra", "jca-server", "bpel-nobj", "bpel-obj", "bpel-ql", "bpel-runtime", "scheduler-simple",
-# "bpel-schemas", "bpel-store", "dao-hibernate", "dao-jpa", "utils", "agents"))
+# "bpel-schemas", "bpel-store", "dao-hibernate", "dao-jpa", "utils", "agents", "bpel-rest-extensions"))
# libs = artifacts(ANT, AXIOM, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.dbcp, COMMONS.lang, COMMONS.pool,
# COMMONS.primitives, COMMONS.io, DERBY, GERONIMO.connector, GERONIMO.transaction, JACOB, JAVAX.connector,
# JAVAX.ejb, JAVAX.jms, JAVAX.persistence, JAVAX.stream, JAVAX.transaction, JAXEN, LOG4J2, OPENJPA,
@@ -718,6 +718,12 @@ define "ode" do
package(:jar).with :manifest=>_("src/main/resources/META-INF/MANIFEST.MF")
end
+ desc "BPEL REST Extensions"
+ define "bpel-rest-extensions" do
+ compile.with projects("bpel-api", "bpel-nobj", "bpel-runtime", "utils"), COMMONS.codec, COMMONS.httpclient, SLF4J, LOG4J2
+ package :jar
+ end
+
# sources and javadocs of jbi-karaf-examples are packaged separately.
# package_with_sources :except => ["jbi-karaf-examples:helloworld2-osgi", "jbi-karaf-examples:ping-pong-osgi"]
# package_with_javadoc :except => ["jbi-karaf-examples:helloworld2-osgi", "jbi-karaf-examples:ping-pong-osgi"] unless ENV["JAVADOC"] =~ /^(no|off|false|skip)$/i
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java
new file mode 100644
index 0000000..32b5e61
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightExtensionBundle.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.eapi.AbstractExtensionBundle;
+import org.apache.ode.utils.Namespaces;
+
+/**
+ * Extension bundle for basic REST operation support in BPEL.
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ *
+ */
+public class Bpel4RestLightExtensionBundle extends AbstractExtensionBundle {
+
+ public static final String NAMESPACE = "http://www.apache.org/ode/bpel/extensions/bpel4restlight";
+
+ public static final QName FAULT_QNAME = new QName(Namespaces.ODE_EXTENSION_NS, "bpel4RestExtensions");
+
+ @Override
+ public String getNamespaceURI() {
+ return NAMESPACE;
+ }
+
+ @Override
+ public void registerExtensionActivities() {
+ super.registerExtensionOperation("PUT", Bpel4RestLightOperation.class);
+ super.registerExtensionOperation("GET", Bpel4RestLightOperation.class);
+ super.registerExtensionOperation("POST", Bpel4RestLightOperation.class);
+ super.registerExtensionOperation("DELETE", Bpel4RestLightOperation.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java
new file mode 100644
index 0000000..3506435
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightOperation.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight;
+
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.eapi.ExtensionContext;
+import org.apache.ode.bpel.eapi.ExtensionOperation;
+import org.apache.ode.bpel.extension.bpel4restlight.http.HighLevelRestApi;
+import org.apache.ode.bpel.extension.bpel4restlight.http.HttpMethod;
+import org.apache.ode.bpel.extension.bpel4restlight.http.HttpResponseMessage;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * This class provides the implementation of the four typical REST operations
+ * GET, PUT, POST and DELETE through corresponding BPEL extension activities
+ * ({@link Bpel4RestLightExtensionBundle}).
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ *
+ */
+public class Bpel4RestLightOperation implements ExtensionOperation {
+
+ public void run(ExtensionContext context, Element element) throws FaultException {
+ String httpMethod = element.getLocalName();
+
+ // Extract requestUri
+ String requestUri = Bpel4RestLightUtil.getMethodAttributeValue(context, element, MethodAttribute.REQUEST_URI);
+
+ HttpResponseMessage responseMessage = null;
+
+ // Execute corresponding HttpMethod via the HighLevelRestApi
+ switch (HttpMethod.valueOf(httpMethod)) {
+
+ case PUT: {
+ String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element);
+ String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element);
+ responseMessage = HighLevelRestApi.Put(requestUri, requestPayload, acceptHeader);
+ break;
+ }
+
+ case POST: {
+ String requestPayload = Bpel4RestLightUtil.extractRequestPayload(context, element);
+ String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element);
+ responseMessage = HighLevelRestApi.Post(requestUri, requestPayload, acceptHeader);
+ break;
+ }
+
+ case GET: {
+ String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element);
+ responseMessage = HighLevelRestApi.Get(requestUri, acceptHeader);
+ break;
+ }
+
+ case DELETE: {
+ String acceptHeader = Bpel4RestLightUtil.extractAcceptHeader(context, element);
+ responseMessage = HighLevelRestApi.Delete(requestUri, acceptHeader);
+ break;
+ }
+ default:
+ break;
+ }
+
+ processResponseMessage(responseMessage, context, element);
+ }
+
+ private void processResponseMessage(HttpResponseMessage responseMessage, ExtensionContext context, Element element)
+ throws FaultException {
+ // Write responsePayload to designated variable
+ String responsePayloadVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, element,
+ MethodAttribute.RESPONSE_PAYLOAD_VARIABLE);
+ String statusCodeVariableName = Bpel4RestLightUtil.getMethodAttributeValue(context, element,
+ MethodAttribute.STATUS_CODE_VARIABLE);
+
+
+ if (responsePayloadVariableName != null && !responsePayloadVariableName.isEmpty()) {
+ Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getResponseBody(),
+ responsePayloadVariableName);
+ }
+
+ if (statusCodeVariableName != null && !statusCodeVariableName.isEmpty()) {
+ Bpel4RestLightUtil.writeResponsePayload(context, responseMessage.getStatusCode(), statusCodeVariableName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightUtil.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightUtil.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightUtil.java
new file mode 100644
index 0000000..37c3386
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/Bpel4RestLightUtil.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight;
+
+import java.io.IOException;
+
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.eapi.ExtensionContext;
+import org.apache.ode.bpel.obj.OScope;
+import org.apache.ode.bpel.obj.OScope.Variable;
+import org.apache.ode.bpel.obj.OVarType;
+import org.apache.ode.bpel.obj.OXsdTypeVarType;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * This class provides some utility methods for the BPEL REST extension
+ * activities.
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ *
+ */
+public class Bpel4RestLightUtil {
+
+ private static final String VARIABLE_VALUE_REFERENCE = "$bpelvar[";
+
+ /**
+ * This method extracts the request message payload from the provided extension
+ * activity. This request payload is either provided through a specified BPEL
+ * variable ('request' attribute) or statically defined within the process model
+ * as the child node of the extension activity.
+ *
+ * @param context
+ * The extension context required to resolve variable values
+ * @param element
+ * The extension activity DOM element containing the request payload
+ * @return The request message payload
+ *
+ * @throws FaultException
+ */
+ public static String extractRequestPayload(ExtensionContext context, Element element) throws FaultException {
+ String requestPayload = null;
+
+ String requestPayloadVariableName = getMethodAttributeValue(context, element,
+ MethodAttribute.REQUEST_PAYLOAD_VARIABLE);
+
+ // Check if a reference to a variable is specified
+ if (requestPayloadVariableName != null && !requestPayloadVariableName.isEmpty()) {
+ // Get the request variable value
+ Node requestVariableNode = context.readVariable(requestPayloadVariableName);
+
+ // Check if the specified variable provides data
+ if (requestVariableNode != null) {
+ requestPayload = variableData2String(requestVariableNode);
+ }
+ }
+
+ // If no variable was specified or the variable doesn't provide data, we check
+ // if a static request payload is specified as the child element of the
+ // extension activity
+ if (requestPayload == null) {
+ Node request = DOMUtils.findChildByType(element, Node.ELEMENT_NODE);
+
+ if (request != null) {
+ requestPayload = DOMUtils.domToString(request);
+ }
+ }
+
+ if (requestPayload == null) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "REST extension activity does not specify any request payload.");
+ }
+
+ return requestPayload;
+ }
+
+ /**
+ * This method writes the response payload to a specified BPEL variable.
+ *
+ * @param context
+ * The extension context required to resolve a variable and write a
+ * new value to it
+ * @param responsePayload
+ * The payload of the response which will be written to the specified
+ * variable
+ * @param processVariableName
+ * The name of the variable to write to
+ * @throws FaultException
+ */
+ public static void writeResponsePayload(ExtensionContext context, Object responsePayload,
+ String processVariableName) throws FaultException {
+ if (responsePayload != null && !responsePayload.toString().isEmpty()) {
+ OScope.Variable bpelVariable = context.getVisibleVariables().get(processVariableName);
+
+ // Create a new instance of the variables' type, to see if we need a wrapper
+ Document doc = DOMUtils.newDocument();
+ Node val = bpelVariable.getType().newInstance(doc);
+
+ // Check if we need a temporary simple type wrapper
+ if (val.getNodeType() == Node.TEXT_NODE) {
+ // Create a wrapper element and add the response payload as text node
+ Element tempwrapper = doc.createElementNS(null, "temporary-simple-type-wrapper");
+ doc.appendChild(tempwrapper);
+ tempwrapper.appendChild(val);
+
+ // Set the response payload
+ val.setTextContent(responsePayload.toString());
+
+ // Return the wrapper element
+ val = tempwrapper;
+ } else {
+ // Convert the structured XML response payload to DOM
+ try {
+ val = DOMUtils.stringToDOM(responsePayload.toString());
+ } catch (SAXException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Writing the response payload to BPEL variable '" + processVariableName
+ + "' caused an exception: " + e.getMessage(),
+ e);
+ } catch (IOException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Writing the response payload to BPEL variable '" + processVariableName
+ + "' caused an exception: " + e.getMessage(),
+ e);
+ }
+ }
+
+ // Write the variable value
+ context.writeVariable(bpelVariable, val);
+ }
+ }
+
+ public static String extractAcceptHeader(ExtensionContext context, Element element) throws FaultException {
+ return getMethodAttributeValue(context, element, MethodAttribute.ACCEPT_HEADER);
+ }
+
+ /**
+ * This method extracts special predefined attributes (see
+ * {@link MethodAttribute}) from an extension activity. Therefore, references to
+ * a variable value via '$bpelVar[varName]' are also automatically resolved.
+ *
+ * @param context
+ * The extension context required to resolve variable values
+ * @param element
+ * The extension activity DOM element containing the attribute value
+ * @param methodAttribute
+ * Attribute whose content has to be returned
+ * @return The value of the attribute
+ * @throws FaultException
+ */
+ public static String getMethodAttributeValue(ExtensionContext context, Element element,
+ MethodAttribute methodAttribute) throws FaultException {
+
+ String result = "";
+
+ switch (methodAttribute) {
+
+ case REQUEST_URI:
+ result = element.getAttribute("uri");
+
+ if (result == null || result.isEmpty()) {
+ result = element.getAttribute("requestUri");
+ } else {
+ // Resolve a possible variable value reference
+ result = resolveVariableValueReference(context, result);
+ }
+
+ break;
+ case REQUEST_PAYLOAD_VARIABLE:
+ result = element.getAttribute("request");
+
+ if (result == null || result.isEmpty()) {
+ result = element.getAttribute("requestPayload");
+ }
+ break;
+ case RESPONSE_PAYLOAD_VARIABLE:
+ result = element.getAttribute("response");
+
+ if (result == null || result.isEmpty()) {
+ result = element.getAttribute("responsePayload");
+ }
+ break;
+ case STATUS_CODE_VARIABLE:
+ result = element.getAttribute("statusCode");
+ break;
+ case ACCEPT_HEADER:
+ result = element.getAttribute("accept");
+
+ // Resolve a possible variable value reference
+ if (result != null && !result.isEmpty()) {
+ result = resolveVariableValueReference(context, result);
+ }
+
+ break;
+ }
+
+ return result;
+ }
+
+ /**
+ * Resolves references to variable values specified in an extension activity via
+ * '$bpelVar[varName]'.
+ *
+ * @param context
+ * The extension context to lookup and resolve variables and their
+ * values.
+ * @param variableValueReference
+ * A potential variable value reference.
+ *
+ * @return If the 'variableValueReference' parameter contains a variable value
+ * reference ($bpelVar[varName]), the actual value of the variable is
+ * returned, else the provided parameter value is returned.
+ * @throws FaultException
+ */
+ public static String resolveVariableValueReference(ExtensionContext context, String variableValueReference)
+ throws FaultException {
+ String variableValue = variableValueReference;
+
+ // Check if a concrete variable name ("varName") or a reference to the value of
+ // a variable
+ // is specified ("$bpelVar[varName]")
+ if (variableValueReference.startsWith(VARIABLE_VALUE_REFERENCE)) {
+ String variableName = variableValueReference.substring(variableValueReference.indexOf("[") + 1,
+ variableValueReference.indexOf("]"));
+
+ Variable variable = context.getVisibleVariables().get(variableName);
+
+ // We only support simple type variables, therefore the value of the variable is
+ // directly provided within a <temporary-simple-type-wrapper/> element.
+ if (variable != null && isSimpleType(variable.getType())) {
+ Node variableContent = context.readVariable(variableName);
+
+ if (variableContent.getTextContent() != null) {
+ variableValue = variableContent.getTextContent();
+ }
+ } else {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "References to the value of a BPEL variable using '$bpelVar[varName]' only support simple type variables.");
+ }
+ }
+
+ return variableValue;
+ }
+
+ public static String variableData2String(Node variableData) {
+ String result = null;
+
+ if (variableData != null) {
+ if ("temporary-simple-type-wrapper".equals(variableData.getLocalName())) {
+ result = variableData.getTextContent();
+ } else {
+ result = DOMUtils.domToString(variableData);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Checks if the type is a simple type or not.
+ *
+ * @param type
+ * to check
+ *
+ * @return True, if the type is simple, False otherwise.
+ */
+ private static boolean isSimpleType(OVarType type) {
+ boolean result = false;
+
+ if (type instanceof OXsdTypeVarType) {
+ result = ((OXsdTypeVarType) type).isSimple();
+ }
+
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/MethodAttribute.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/MethodAttribute.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/MethodAttribute.java
new file mode 100644
index 0000000..2b3866a
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/MethodAttribute.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight;
+
+/**
+ *
+ * This enumeration is used to decouple DOM attribute names from their
+ * String representation within a certain library (for portability support)
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ *
+ */
+public enum MethodAttribute {
+ REQUEST_URI, REQUEST_PAYLOAD_VARIABLE, RESPONSE_PAYLOAD_VARIABLE, STATUS_CODE_VARIABLE, ACCEPT_HEADER;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HighLevelRestApi.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HighLevelRestApi.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HighLevelRestApi.java
new file mode 100644
index 0000000..2596079
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HighLevelRestApi.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight.http;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.extension.bpel4restlight.Bpel4RestLightExtensionBundle;
+
+/**
+ * This class wraps HTTP method functionality and thereby abstracts from low
+ * level library-specific code to simplify its usage.
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ */
+public class HighLevelRestApi {
+
+ /**
+ * This method implements the HTTP PUT Method
+ *
+ * @param uri
+ * The URI of the target resource
+ * @param requestPayload
+ * The payload of the request message
+ * @param acceptHeaderValue
+ * The value of the accept header field to be set
+ * @return A HttpResponseMessage providing the response message payload and
+ * status code.
+ *
+ * @exception FaultException
+ */
+ public static HttpResponseMessage Put(String uri, String requestPayload, String acceptHeaderValue)
+ throws FaultException {
+
+ PutMethod method = new PutMethod(uri);
+
+ HighLevelRestApi.setAcceptHeader(method, acceptHeaderValue);
+ try {
+ method.setRequestEntity(new StringRequestEntity(requestPayload, "application/xml", "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Execution of HTTP method '" + method.getName() + "' caused an exception.", e);
+ }
+
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ // Remove <?xml... in front of response
+ HighLevelRestApi.cleanResponseBody(responseMessage);
+
+ return responseMessage;
+ }
+
+ /**
+ * This method implements the HTTP POST Method
+ *
+ * @param uri
+ * The URI of the target resource
+ * @param requestPayload
+ * The payload of the request message
+ * @param acceptHeaderValue
+ * The value of the accept header field to be set
+ * @return A HttpResponseMessage providing the response message payload and
+ * status code.
+ *
+ * @exception FaultException
+ */
+ public static HttpResponseMessage Post(String uri, String requestPayload, String acceptHeaderValue)
+ throws FaultException {
+
+ PostMethod method = null;
+ if (uri.contains("?")) {
+ String[] split = uri.split("\\?");
+ method = new PostMethod(split[0]);
+ method.setQueryString(HighLevelRestApi.createNameValuePairArrayFromQuery(split[1]));
+ } else {
+ method = new PostMethod(uri);
+ }
+
+ try {
+ method.setRequestEntity(new StringRequestEntity(requestPayload, "application/xml", "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Execution of HTTP method '" + method.getName() + "' caused an exception.", e);
+ }
+
+ HighLevelRestApi.setAcceptHeader(method, acceptHeaderValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ // Remove <?xml... in front of response
+ HighLevelRestApi.cleanResponseBody(responseMessage);
+
+ return responseMessage;
+ }
+
+ /**
+ * This method implements the HTTP GET Method
+ *
+ * @param uri
+ * The URI of the target resource
+ * @param acceptHeaderValue
+ * The value of the accept header field to be set
+ * @return A HttpResponseMessage providing the response message payload and
+ * status code.
+ *
+ * @exception FaultException
+ */
+ public static HttpResponseMessage Get(String uri, String acceptHeaderValue) throws FaultException {
+ GetMethod method = null;
+ if (uri.contains("?")) {
+ String[] split = uri.split("\\?");
+ method = new GetMethod(split[0]);
+ method.setQueryString(HighLevelRestApi.createNameValuePairArrayFromQuery(split[1]));
+ } else {
+ method = new GetMethod(uri);
+ }
+ HighLevelRestApi.setAcceptHeader(method, acceptHeaderValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ HighLevelRestApi.cleanResponseBody(responseMessage);
+ return responseMessage;
+ }
+
+ /**
+ * This method implements the HTTP DELETE Method
+ *
+ * @param uri
+ * The URI of the target resource
+ * @param acceptHeaderValue
+ * The value of the accept header field to be set
+ * @return A HttpResponseMessage providing the response message payload and
+ * status code.
+ *
+ * @exception FaultException
+ */
+ public static HttpResponseMessage Delete(String uri, String acceptHeaderValue) throws FaultException {
+
+ DeleteMethod method = new DeleteMethod(uri);
+ HighLevelRestApi.setAcceptHeader(method, acceptHeaderValue);
+ HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method);
+ HighLevelRestApi.cleanResponseBody(responseMessage);
+ return responseMessage;
+ }
+
+ private static NameValuePair[] createNameValuePairArrayFromQuery(String query) {
+ // example:
+ // csarID=Moodle.csar&serviceTemplateID={http://www.example.com/tosca/ServiceTemplates/Moodle}Moodle&nodeTemplateID={http://www.example.com/tosca/ServiceTemplates/Moodle}VmApache
+ String[] pairs = query.trim().split("&");
+ NameValuePair[] nameValuePairArray = new NameValuePair[pairs.length];
+ int count = 0;
+ for (String pair : pairs) {
+ String[] keyValue = pair.split("=");
+ NameValuePair nameValuePair = new NameValuePair();
+ nameValuePair.setName(keyValue[0]);
+ nameValuePair.setValue(keyValue[1]);
+ nameValuePairArray[count] = nameValuePair;
+ count++;
+ }
+ return nameValuePairArray;
+ }
+
+ private static void setAcceptHeader(HttpMethodBase method, String value) {
+ if (!value.equals("")) {
+ method.setRequestHeader("Accept", value);
+ } else {
+ method.setRequestHeader("Accept", "application/xml");
+ }
+ }
+
+ private static void cleanResponseBody(HttpResponseMessage responseMessage) {
+ if (responseMessage.getResponseBody() != null) {
+ String temp = responseMessage.getResponseBody()
+ .replace("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", "");
+ responseMessage.setResponseBody(temp);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpMethod.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpMethod.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpMethod.java
new file mode 100644
index 0000000..650d095
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpMethod.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight.http;
+
+/**
+ * This enumeration is intended to simplify identifying different HTTP-methods
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ */
+public enum HttpMethod {
+ PUT, POST, GET, DELETE
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpResponseMessage.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpResponseMessage.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpResponseMessage.java
new file mode 100644
index 0000000..7695598
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/HttpResponseMessage.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight.http;
+
+/**
+ * This class is used to wrap information of a HTTP response message in a
+ * library neutral format
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ */
+public class HttpResponseMessage {
+
+ private int statusCode;
+ private String responseBody;
+
+ /**
+ * @return the statusCode
+ */
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+
+ /**
+ * @param statusCode
+ * the statusCode to set
+ */
+ protected void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ /**
+ * @return the responseBody
+ */
+ public String getResponseBody() {
+ return this.responseBody;
+ }
+
+ /**
+ * @param responseBody
+ * the responseBody to set
+ */
+ protected void setResponseBody(String responseBody) {
+ this.responseBody = responseBody;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/LowLevelRestApi.java
----------------------------------------------------------------------
diff --git a/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/LowLevelRestApi.java b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/LowLevelRestApi.java
new file mode 100644
index 0000000..474d5ed
--- /dev/null
+++ b/bpel-rest-extensions/src/main/java/org/apache/ode/bpel/extension/bpel4restlight/http/LowLevelRestApi.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.bpel.extension.bpel4restlight.http;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.extension.bpel4restlight.Bpel4RestLightExtensionBundle;
+
+/**
+ * This class eases HTTP method execution by providing fault handling and
+ * automated response information processing
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ */
+public class LowLevelRestApi {
+
+ // HttpClient used for communication
+ private static HttpClient httpClient = new HttpClient();
+
+ /**
+ * Executes a passed HttpMethod (method type is either PUT, POST, GET or DELETE)
+ * and returns a HttpResponseMessage
+ *
+ * @param method
+ * Method to execute
+ * @return HttpResponseMessage which contains all information about the
+ * execution
+ */
+ public static HttpResponseMessage executeHttpMethod(HttpMethod method) throws FaultException {
+
+ HttpResponseMessage responseMessage = null;
+
+ try {
+ // Execute Request
+ LowLevelRestApi.httpClient.executeMethod(method);
+
+ responseMessage = LowLevelRestApi.extractResponseInformation(method);
+ } catch (HttpException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Execution of HTTP method '" + method.getName() + "' caused an exception: " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new FaultException(Bpel4RestLightExtensionBundle.FAULT_QNAME,
+ "BPEL4REST: Execution of HTTP method '" + method.getName() + "' caused an exception: " + e.getMessage(), e);
+ } finally {
+ // Release connection
+ method.releaseConnection();
+ }
+
+ // Extract response information and return
+ return responseMessage;
+ }
+
+ /**
+ * Extracts the response information from an executed HttpMethod
+ *
+ * @param method
+ * The HTTP method
+ * @return The extracted response information
+ * @throws IOException
+ */
+ private static HttpResponseMessage extractResponseInformation(HttpMethod method) throws IOException {
+ // Create and return HttpResponseMethod
+ HttpResponseMessage responseMessage = new HttpResponseMessage();
+
+ responseMessage.setStatusCode(method.getStatusCode());
+ responseMessage.setResponseBody(method.getResponseBodyAsString());
+
+ return responseMessage;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/java/org/apache/ode/test/RestExtensionActivitiesTest.java
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/java/org/apache/ode/test/RestExtensionActivitiesTest.java b/bpel-test/src/test/java/org/apache/ode/test/RestExtensionActivitiesTest.java
new file mode 100644
index 0000000..e300260
--- /dev/null
+++ b/bpel-test/src/test/java/org/apache/ode/test/RestExtensionActivitiesTest.java
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.ode.test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.extension.bpel4restlight.Bpel4RestLightExtensionBundle;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.utils.DOMUtils;
+import org.junit.Test;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+/**
+ * This class runs some initial test cases for the BPEL REST extension bundle
+ *
+ * @author Michael Hahn (mhahn.dev@gmail.com)
+ *
+ */
+public class RestExtensionActivitiesTest extends BPELTestAbstract {
+
+ private HttpServer httpServer;
+
+ private int port = 8085;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ // Register the extension bundle at the ODE server
+ _server.registerExtensionBundle(new Bpel4RestLightExtensionBundle());
+
+ // Start a test HTTP server for executing the REST extension activities
+ httpServer = HttpServer.create(new InetSocketAddress(port), 0);
+
+ // Create handler to reply HTTP calls
+ httpServer.createContext("/test", new HttpHandler() {
+ public void handle(HttpExchange exchange) throws IOException {
+ handleHttpRequest(exchange);
+ }
+ });
+
+ httpServer.start();
+ }
+
+ /**
+ * Tests the "GET" REST extension activity.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testGetExtAct() throws Throwable {
+ go("/bpel/2.0/TestRestGetExtAct");
+ }
+
+ /**
+ * Tests the "POST" REST extension activity.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testPostExtAct() throws Throwable {
+ go("/bpel/2.0/TestRestPostExtAct");
+ }
+
+ /**
+ * Tests the "POST" REST extension activity with a static wrapped request
+ * message.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testPostExtActWithWrappedRequest() throws Throwable {
+ go("/bpel/2.0/TestRestPostExtAct2");
+ }
+
+ /**
+ * Tests the "PUT" REST extension activity.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testPutExtAct() throws Throwable {
+ go("/bpel/2.0/TestRestPutExtAct");
+ }
+
+ /**
+ * Tests the "DELETE" REST extension activity.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testDeleteExtAct() throws Throwable {
+ go("/bpel/2.0/TestRestDeleteExtAct");
+ }
+
+ /**
+ * Tests the HTTP status code variable of a REST extension activity.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testRestExtActStatusCode() throws Throwable {
+ go("/bpel/2.0/TestRestExtActStatusCode");
+ }
+
+ /**
+ * Tests a BPEL REST extension activity with complex type variables.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testRestExtActComplexTypeVar() throws Throwable {
+ go("/bpel/2.0/TestRestExtActComplexTypeVar");
+ }
+
+ /**
+ * Tests the "POST" REST extension activity with an invalid URL value message.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testPostExtActWithWrongURL() throws Throwable {
+ deploy("/bpel/2.0/TestPostExtActWithWrongURL");
+
+ Invocation inv = addInvoke("REST-POST#1", new QName("http://ode/bpel/unit-test.wsdl", "HelloService"), "hello",
+ "<message><TestPart>Hello</TestPart></message>", null);
+ inv.expectedFinalStatus = MessageExchange.Status.FAULT;
+ inv.expectedInvokeException = FaultException.class;
+
+ go();
+ }
+
+ private void handleHttpRequest(HttpExchange exchange) throws IOException {
+ String method = exchange.getRequestMethod();
+
+ if (method.toUpperCase().equals("GET")) {
+ String response = "<service:getResponse xmlns:service=\"http://www.example.org/restApi\">\n"
+ + " <service:result>GET response data</service:result>\n"
+ + " </service:getResponse>";
+
+ byte[] bResponse = response.getBytes();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, bResponse.length);
+ exchange.getResponseBody().write(bResponse);
+ exchange.close();
+ } else if (method.toUpperCase().equals("POST")) {
+ String request = IOUtils.toString(exchange.getRequestBody());
+
+ String requestValue = "";
+ try {
+ Node reqNode = DOMUtils.stringToDOM(request);
+
+ NodeList list = reqNode.getChildNodes();
+ int i = 0;
+ while (i < list.getLength()) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && ((Element) node).getLocalName().equals("value")) {
+ requestValue = node.getTextContent();
+ }
+ i++;
+ }
+
+ String response = "<service:postResponse xmlns:service=\"http://www.example.org/restApi\">\n"
+ + " <service:result>" + requestValue + " Result</service:result>\n"
+ + " </service:postResponse>";
+
+ byte[] bResponse = response.getBytes();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, bResponse.length);
+ exchange.getResponseBody().write(bResponse);
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_INTERNAL_ERROR, 0);
+ }
+
+ exchange.close();
+ } else if (method.toUpperCase().equals("PUT")) {
+ String request = IOUtils.toString(exchange.getRequestBody());
+
+ String requestValue = "";
+ try {
+ Node reqNode = DOMUtils.stringToDOM(request);
+
+ NodeList list = reqNode.getChildNodes();
+ int i = 0;
+ while (i < list.getLength()) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && ((Element) node).getLocalName().equals("value")) {
+ requestValue = node.getTextContent();
+ }
+ i++;
+ }
+
+ String response = "<service:putResponse xmlns:service=\"http://www.example.org/restApi\">\n"
+ + " <service:result>" + requestValue + " Result</service:result>\n"
+ + " </service:putResponse>";
+
+ byte[] bResponse = response.getBytes();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, bResponse.length);
+ exchange.getResponseBody().write(bResponse);
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_INTERNAL_ERROR, 0);
+ }
+
+ exchange.close();
+ } else if (method.toUpperCase().equals("DELETE")) {
+ if (exchange.getRequestURI().getPath().endsWith("/test")) {
+ String response = "<service:deleteResponse xmlns:service=\"http://www.example.org/restApi\">\n"
+ + " <service:result>DELETE Method Test</service:result>\n"
+ + " </service:deleteResponse>";
+
+ byte[] bResponse = response.getBytes();
+
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, bResponse.length);
+ exchange.getResponseBody().write(bResponse);
+ exchange.close();
+ } else {
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_NOT_FOUND, 0);
+ exchange.close();
+ }
+ } else {
+ exchange.sendResponseHeaders(HttpURLConnection.HTTP_NOT_FOUND, 0);
+ exchange.close();
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ // Stop the server
+ httpServer.stop(0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.bpel
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.bpel b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.bpel
new file mode 100644
index 0000000..da9a726
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.bpel
@@ -0,0 +1,100 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<process name="TestPostExtActWithWrongURL"
+ targetNamespace="http://ode/bpel/unit-test"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:tns="http://ode/bpel/unit-test"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://ode/bpel/unit-test.wsdl"
+ xmlns:service="http://www.example.org/restApi"
+ xmlns:bpel4RestLight="http://www.apache.org/ode/bpel/extensions/bpel4restlight"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="TestPostExtActWithWrongURL.wsdl"
+ namespace="http://ode/bpel/unit-test.wsdl"
+ importType="http://schemas.xmlsoap.org/wsdl/" />
+
+ <import location="restApi.xsd"
+ namespace="http://www.example.org/restApi"
+ importType="http://www.w3.org/2001/XMLSchema"/>
+
+ <extensions>
+ <extension mustUnderstand="yes" namespace="http://www.apache.org/ode/bpel/extensions/bpel4restlight"/>
+ </extensions>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink"
+ partnerLinkType="test:HelloPartnerLinkType"
+ myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="restUrl" type="xsd:string"/>
+ <variable name="restRequest" element="service:postRequest"/>
+ <variable name="restResponse" element="service:postResponse"/>
+ <variable name="response" messageType="test:ResponseMessage"></variable>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from><literal>http://localhost:8086/test</literal></from>
+ <to variable="restUrl"/>
+ </copy>
+ <copy>
+ <from>
+ <literal>
+ <service:postRequest xmlns:service="http://www.example.org/restApi">
+ <service:value>POST Method Test</service:value>
+ </service:postRequest>
+ </literal>
+ </from>
+ <to variable="restRequest"/>
+ </copy>
+ </assign>
+
+ <extensionActivity>
+ <bpel4RestLight:POST accept="application/xml" request="restRequest" response="restResponse" uri="$bpelvar[restUrl]"/>
+ </extensionActivity>
+
+ <assign name="assign2">
+ <copy>
+ <from variable="restResponse"></from>
+ <to part="TestPart" variable="response"></to>
+ </copy>
+ </assign>
+
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="response"/>
+ </sequence>
+</process>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.wsdl
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.wsdl b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.wsdl
new file mode 100644
index 0000000..2270a8b
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/TestPostExtActWithWrongURL.wsdl
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<wsdl:definitions
+ targetNamespace="http://ode/bpel/unit-test.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ode/bpel/unit-test.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part name="TestPart" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:message name="ResponseMessage">
+ <wsdl:part name="TestPart" type="xsd:anyType"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:ResponseMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8080/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
+
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/deploy.xml
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/deploy.xml b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/deploy.xml
new file mode 100644
index 0000000..5ee5c95
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/deploy.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ xmlns:pns="http://ode/bpel/unit-test"
+ xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+
+ <process name="pns:TestPostExtActWithWrongURL">
+ <active>true</active>
+ <provide partnerLink="helloPartnerLink">
+ <service name="wns:HelloService" port="HelloPort"/>
+ </provide>
+ </process>
+</deploy>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/restApi.xsd
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/restApi.xsd b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/restApi.xsd
new file mode 100644
index 0000000..b521dc7
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestPostExtActWithWrongURL/restApi.xsd
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/restApi"
+ xmlns:tns="http://www.example.org/restApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+ <xsd:complexType name="postRequestType">
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="postResponseType">
+ <xsd:sequence>
+ <xsd:element name="result" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="postRequest" type="tns:postRequestType"></xsd:element>
+ <xsd:element name="postResponse" type="tns:postResponseType"></xsd:element>
+</schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.bpel
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.bpel b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.bpel
new file mode 100644
index 0000000..82a29fc
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.bpel
@@ -0,0 +1,89 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<process name="TestRestDeleteExtAct"
+ targetNamespace="http://ode/bpel/unit-test"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:tns="http://ode/bpel/unit-test"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://ode/bpel/unit-test.wsdl"
+ xmlns:service="http://www.example.org/restApi"
+ xmlns:bpel4RestLight="http://www.apache.org/ode/bpel/extensions/bpel4restlight"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="TestRestDeleteExtAct.wsdl"
+ namespace="http://ode/bpel/unit-test.wsdl"
+ importType="http://schemas.xmlsoap.org/wsdl/" />
+
+ <import location="restApi.xsd"
+ namespace="http://www.example.org/restApi"
+ importType="http://www.w3.org/2001/XMLSchema"/>
+
+ <extensions>
+ <extension mustUnderstand="yes" namespace="http://www.apache.org/ode/bpel/extensions/bpel4restlight"/>
+ </extensions>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink"
+ partnerLinkType="test:HelloPartnerLinkType"
+ myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="restUrl" type="xsd:string"/>
+ <variable name="restResponse" element="service:deleteResponse"/>
+ <variable name="response" messageType="test:ResponseMessage"></variable>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from><literal>http://localhost:8085/test</literal></from>
+ <to variable="restUrl"/>
+ </copy>
+ </assign>
+
+ <extensionActivity>
+ <bpel4RestLight:DELETE accept="application/xml" response="restResponse" uri="$bpelvar[restUrl]"/>
+ </extensionActivity>
+
+ <assign name="assign2">
+ <copy>
+ <from variable="restResponse"></from>
+ <to part="TestPart" variable="response"></to>
+ </copy>
+ </assign>
+
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="response"/>
+ </sequence>
+</process>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.wsdl
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.wsdl b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.wsdl
new file mode 100644
index 0000000..2270a8b
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/TestRestDeleteExtAct.wsdl
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<wsdl:definitions
+ targetNamespace="http://ode/bpel/unit-test.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ode/bpel/unit-test.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part name="TestPart" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:message name="ResponseMessage">
+ <wsdl:part name="TestPart" type="xsd:anyType"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:ResponseMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8080/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
+
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/deploy.xml
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/deploy.xml b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/deploy.xml
new file mode 100644
index 0000000..46d55f8
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/deploy.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ xmlns:pns="http://ode/bpel/unit-test"
+ xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+
+ <process name="pns:TestRestDeleteExtAct">
+ <active>true</active>
+ <provide partnerLink="helloPartnerLink">
+ <service name="wns:HelloService" port="HelloPort"/>
+ </provide>
+ </process>
+</deploy>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/restApi.xsd
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/restApi.xsd b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/restApi.xsd
new file mode 100644
index 0000000..7aa878b
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/restApi.xsd
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/restApi"
+ xmlns:tns="http://www.example.org/restApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+ <xsd:complexType name="deleteResponseType">
+ <xsd:sequence>
+ <xsd:element name="result" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="deleteResponse" type="tns:deleteResponseType"></xsd:element>
+</schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/test.properties
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/test.properties b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/test.properties
new file mode 100644
index 0000000..9e9d8fe
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestDeleteExtAct/test.properties
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+namespace=http://ode/bpel/unit-test.wsdl
+service=HelloService
+operation=hello
+request1=<message><TestPart>Hello</TestPart></message>
+response1=.*DELETE Method Test.*
+
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.bpel
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.bpel b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.bpel
new file mode 100644
index 0000000..73ee1a9
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.bpel
@@ -0,0 +1,90 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<process name="TestRestExtActComplexTypeVar"
+ targetNamespace="http://ode/bpel/unit-test"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:tns="http://ode/bpel/unit-test"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://ode/bpel/unit-test.wsdl"
+ xmlns:bpel4RestLight="http://www.apache.org/ode/bpel/extensions/bpel4restlight"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="TestRestExtActComplexTypeVar.wsdl"
+ namespace="http://ode/bpel/unit-test.wsdl"
+ importType="http://schemas.xmlsoap.org/wsdl/" />
+
+ <extensions>
+ <extension mustUnderstand="yes" namespace="http://www.apache.org/ode/bpel/extensions/bpel4restlight"/>
+ </extensions>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink"
+ partnerLinkType="test:HelloPartnerLinkType"
+ myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="restRequest" type="xsd:anyType"/>
+ <variable name="restResponse" type="xsd:anyType"/>
+ <variable name="response" messageType="test:ResponseMessage"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from>
+ <literal>
+ <service:postRequest xmlns:service="http://www.example.org/restApi">
+ <service:value>POST Method Test</service:value>
+ </service:postRequest>
+ </literal>
+ </from>
+ <to variable="restRequest"/>
+ </copy>
+ </assign>
+
+ <extensionActivity>
+ <bpel4RestLight:POST accept="application/xml" request="restRequest" response="restResponse" uri="http://localhost:8085/test"/>
+ </extensionActivity>
+
+ <assign name="assign2">
+ <copy>
+ <from variable="restResponse"></from>
+ <to part="TestPart" variable="response"></to>
+ </copy>
+ </assign>
+
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="response"/>
+ </sequence>
+</process>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.wsdl
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.wsdl b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.wsdl
new file mode 100644
index 0000000..2270a8b
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/TestRestExtActComplexTypeVar.wsdl
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<wsdl:definitions
+ targetNamespace="http://ode/bpel/unit-test.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ode/bpel/unit-test.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part name="TestPart" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:message name="ResponseMessage">
+ <wsdl:part name="TestPart" type="xsd:anyType"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:ResponseMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body
+ namespace="http://ode/bpel/unit-test.wsdl"
+ use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8080/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
+
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/deploy.xml
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/deploy.xml b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/deploy.xml
new file mode 100644
index 0000000..f23f17a
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/deploy.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ xmlns:pns="http://ode/bpel/unit-test"
+ xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+
+ <process name="pns:TestRestExtActComplexTypeVar">
+ <active>true</active>
+ <provide partnerLink="helloPartnerLink">
+ <service name="wns:HelloService" port="HelloPort"/>
+ </provide>
+ </process>
+</deploy>
http://git-wip-us.apache.org/repos/asf/ode/blob/f6ab51fe/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/test.properties
----------------------------------------------------------------------
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/test.properties b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/test.properties
new file mode 100644
index 0000000..1c966aa
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestRestExtActComplexTypeVar/test.properties
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+namespace=http://ode/bpel/unit-test.wsdl
+service=HelloService
+operation=hello
+request1=<message><TestPart>Hello</TestPart></message>
+response1=.*POST Method Test Result.*
+