I've changed the code creating a bean service (SendSensingError) that returns a String to the Repository Service Task (that calls the POST method having that Strins as input parameter). Meanwhile, I've got no error but the resouce in the remote server is not created. Did Switchyard handles with the transformation from String to JSON? This is something missing here?
The bean service
@Service(SendSensingError.class)
public class SendSensingErrorBean implements SendSensingError {
public SendSensingErrorBean() {
// TODO Auto-generated constructor stub
}
@Override
public String sendError(String in) {
System.out.println("PASSOU");
return "folder";
}
The bean service interface:
public interface SendSensingError {
String sendError(String in);
}
I've changed the Resource interface to support parameters
public interface RepositoryResource {
@POST
@Path("")
@Consumes({"application/json"})
public void postRepo(String contentInput) throws Exception;
}
Here is the BPM workflow:
The BPM process code:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools">
<itemDefinition id="_contentInputItem" structureRef="String" />
<itemDefinition id="_contentOutputItem" structureRef="String" />
<itemDefinition id="_3-contentInputItem" structureRef="String" />
<itemDefinition id="_3-contentOutputItem" structureRef="String" />
<itemDefinition id="_5-contentInputItem" structureRef="String" />
<itemDefinition id="_5-contentOutputItem" structureRef="String" />
<process processType="Private" isExecutable="true" id="ProcessInterface" name="ProcessInterface" tns:packageName="com.example.switchyard.postBPM" >
<!-- process variables -->
<property id="contentInput" itemSubjectRef="_contentInputItem"/>
<property id="contentOutput" itemSubjectRef="_contentOutputItem"/>
<!-- nodes -->
<startEvent id="StartEvent_1" />
<task id="_3" name="Repository" tns:taskName="SwitchYard Service" >
<extensionElements>
<tns:onEntry-script scriptFormat="http://www.java.com/java">
<script>System.out.println("_________Content--Input______ " + contentInput);
System.out.println("_________Content--Output______ " + contentOutput);</script>
</tns:onEntry-script>
</extensionElements>
<ioSpecification>
<dataInput id="_3_contentInputInput" name="contentInput" />
<dataInput id="_3_ServiceNameInput" name="ServiceName" />
<dataInput id="_3_ServiceOperationNameInput" name="ServiceOperationName" />
<dataOutput id="_3_contentOutputOutput" name="contentOutput" />
<inputSet>
<dataInputRefs>_3_contentInputInput</dataInputRefs>
<dataInputRefs>_3_ServiceNameInput</dataInputRefs>
<dataInputRefs>_3_ServiceOperationNameInput</dataInputRefs>
</inputSet>
<outputSet>
<dataOutputRefs>_3_contentOutputOutput</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<sourceRef>contentOutput</sourceRef>
<targetRef>_3_contentInputInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_3_ServiceNameInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression">Repository</from>
<to xsi:type="tFormalExpression">_3_ServiceNameInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_3_ServiceOperationNameInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression">postRepo</from>
<to xsi:type="tFormalExpression">_3_ServiceOperationNameInput</to>
</assignment>
</dataInputAssociation>
<dataOutputAssociation>
<sourceRef>_3_contentOutputOutput</sourceRef>
<targetRef>contentOutput</targetRef>
</dataOutputAssociation>
</task>
<endEvent id="_4" name="End" />
<task id="_5" name="ProduceContentInput" tns:taskName="SwitchYard Service" >
<ioSpecification>
<dataInput id="_5_ServiceNameInput" name="ServiceName" />
<dataInput id="_5_ServiceOperationNameInput" name="ServiceOperationName" />
<dataOutput id="_5_contentOutputOutput" name="contentOutput" />
<inputSet>
<dataInputRefs>_5_ServiceNameInput</dataInputRefs>
<dataInputRefs>_5_ServiceOperationNameInput</dataInputRefs>
</inputSet>
<outputSet>
<dataOutputRefs>_5_contentOutputOutput</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<targetRef>_5_ServiceNameInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression">SendSensingError</from>
<to xsi:type="tFormalExpression">_5_ServiceNameInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_5_ServiceOperationNameInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression">sendError</from>
<to xsi:type="tFormalExpression">_5_ServiceOperationNameInput</to>
</assignment>
</dataInputAssociation>
<dataOutputAssociation>
<sourceRef>_5_contentOutputOutput</sourceRef>
<targetRef>contentOutput</targetRef>
</dataOutputAssociation>
</task>
<!-- connections -->
<sequenceFlow id="_5-_3" sourceRef="_5" targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" />
<sequenceFlow id="StartEvent_1-_5" sourceRef="StartEvent_1" targetRef="_5" />
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="ProcessInterface" >
<bpmndi:BPMNShape bpmnElement="StartEvent_1" >
<dc:Bounds x="42" y="16" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="16" y="176" width="100" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="42" y="256" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" >
<dc:Bounds x="16" y="96" width="100" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_5-_3" >
<di:waypoint x="66" y="120" />
<di:waypoint x="66" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_4" >
<di:waypoint x="66" y="200" />
<di:waypoint x="66" y="280" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="StartEvent_1-_5" >
<di:waypoint x="66" y="40" />
<di:waypoint x="66" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
The Switchyard.xml:
<?xml version="1.0" encoding="UTF-8"?>
<switchyard xmlns="urn:switchyard-config:switchyard:1.0"
xmlns:bpm="urn:switchyard-component-bpm:config:1.0" xmlns:http="urn:switchyard-component-http:config:1.0"
xmlns:resteasy="urn:switchyard-component-resteasy:config:1.0"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="postBPM"
targetNamespace="urn:com.example.switchyard:postBPM:1.0">
<sca:composite name="postBPM"
targetNamespace="urn:com.example.switchyard:postBPM:1.0">
<sca:service name="ProcessInterface" promote="ProcessComponent/ProcessInterface">
<sca:interface.java interface="com.example.switchyard.postBPM.ProcessInterface" />
<resteasy:binding.rest>
<resteasy:contextMapper />
<resteasy:interfaces>com.example.switchyard.postBPM.ProcessInterfaceResource</resteasy:interfaces>
<resteasy:contextPath>postBPM</resteasy:contextPath>
</resteasy:binding.rest>
</sca:service>
<sca:component name="ProcessComponent">
<bpm:implementation.bpm persistent="false"
processId="ProcessInterface">
<bpm:actions>
<bpm:action operation="start" type="START_PROCESS">
<bpm:inputs>
<bpm:mapping expression="message.content" variable="contentInput" />
</bpm:inputs>
</bpm:action>
</bpm:actions>
<bpm:manifest>
<bpm:resources>
<bpm:resource location="ProcessComponent.bpmn" type="BPMN2" />
</bpm:resources>
</bpm:manifest>
<bpm:workItemHandlers>
<bpm:workItemHandler
class="org.switchyard.component.bpm.work.SwitchYardServiceWorkItemHandler"
name="SwitchYard Service" />
</bpm:workItemHandlers>
</bpm:implementation.bpm>
<sca:service name="ProcessInterface">
<sca:interface.java
interface="com.example.switchyard.postBPM.ProcessInterface" />
</sca:service>
<sca:reference name="Repository">
<sca:interface.java interface="com.example.switchyard.postBPM.Repository" />
</sca:reference>
<sca:reference name="SendSensingError">
<sca:interface.java
interface="com.example.switchyard.postBPM.SendSensingError" />
</sca:reference>
</sca:component>
<sca:reference name="Repository" multiplicity="0..1"
promote="ProcessComponent/Repository">
<sca:interface.java interface="com.example.switchyard.postBPM.Repository" />
<resteasy:binding.rest>
<resteasy:contextMapper />
<resteasy:interfaces>com.example.switchyard.postBPM.RepositoryResource</resteasy:interfaces>
<resteasy:address>http://10.112.34.32/ArtifactManager/rest/api/createrepository/</resteasy:address>
<resteasy:contextPath>postBPM</resteasy:contextPath>
</resteasy:binding.rest>
</sca:reference>
</sca:composite>
<domain>
<handlers>
<handler class="org.switchyard.handlers.MessageTrace" name="MessageTrace" />
</handlers>
</domain>
</switchyard>
The Message trace:
------- Begin Message Trace -------
Service -> {urn:com.example.switchyard:postBPM:1.0}ProcessInterface
Operation -> start
Phase -> IN
State -> OK
Exchange Context ->
Message Context ->
accept-language : pt-pt,pt;q=0.8,en;q=0.5,en-us;q=0.3
accept : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-encoding : gzip, deflate
org.switchyard.messageId : 231d85d7-614f-4392-9f9d-9d1660dd3614
host : localhost:8080
user-agent : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
connection : keep-alive
Message Content ->
null
------ End Message Trace -------
05:36:28,810 INFO [org.switchyard.handlers.MessageTrace] (http--0.0.0.0-8080-2)
------- Begin Message Trace -------
Service -> {urn:com.example.switchyard:postBPM:1.0}SendSensingError
Operation -> sendError
Phase -> IN
State -> OK
Exchange Context ->
Message Context ->
ServiceOperationName : sendError
org.switchyard.messageId : 9479d423-871b-41d7-b9a9-619c80758b21
org.switchyard.contentType : java:java.lang.String
ServiceName : SendSensingError
Message Content ->
null
------ End Message Trace -------
05:36:28,819 INFO [stdout] (http--0.0.0.0-8080-2) PASSOU
05:36:28,820 INFO [org.switchyard.handlers.MessageTrace] (http--0.0.0.0-8080-2)
------- Begin Message Trace -------
Service -> {urn:com.example.switchyard:postBPM:1.0}SendSensingError
Operation -> sendError
Phase -> OUT
State -> OK
Exchange Context ->
org.switchyard.exchange.transaction.beforeInvoked : true
org.switchyard.exchangeDurationMS : 10
Message Context ->
org.switchyard.messageId : e472391f-fdb8-49b6-98df-55b0ee98f34c
org.switchyard.relatesTo : 9479d423-871b-41d7-b9a9-619c80758b21
org.switchyard.contentType : java:java.lang.String
Message Content ->
folder
------ End Message Trace -------
05:36:28,827 INFO [stdout] (http--0.0.0.0-8080-2) _________Content--Input______ null
05:36:28,828 INFO [stdout] (http--0.0.0.0-8080-2) _________Content--Output______ folder
05:36:28,829 INFO [org.switchyard.handlers.MessageTrace] (http--0.0.0.0-8080-2)
------- Begin Message Trace -------
Service -> {urn:com.example.switchyard:postBPM:1.0}Repository
Operation -> postRepo
Phase -> IN
State -> OK
Exchange Context ->
Message Context ->
ServiceOperationName : postRepo
ServiceName : Repository
contentInput : folder
org.switchyard.contentType : java:java.lang.String
org.switchyard.messageId : 57fc2ca7-1bbd-4238-a372-664f0ecadafa
Message Content ->
folder
------ End Message Trace -------