AnsweredAssumed Answered

How can I get output when I use Webservice in process

Question asked by morexpool on Jan 30, 2013
Latest reply on Jan 30, 2013 by morexpool
My Web Service :



package com.morex.test;

import javax.ejb.Stateless;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

@Stateless
@WebService
public class AddressService {

   @WebResult(name="findCustomerAddressResponseItem")
   public String findCustomerAddress(@WebParam(name="findCustomerAddressRequestItem") String customerName) {
      
      System.out.println("——————————————————- ");
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");      
      System.out.println("|         customerName = "+ customerName);      
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");
      System.out.println("|                                                     | ");
      System.out.println("——————————————————- ");
            
      return "Customer [ "+ customerName + " ] has address ABC…" ;
   }
}




My BPMN file :



<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
   xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
   typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath"
   xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" targetNamespace="com.morex.test.AddressService"
   xmlns:tns="com.morex.test.AddressService" xmlns:classObject="http://test.morex.com/">

   <import importType="http://schemas.xmlsoap.org/wsdl/"
      location="http://192.168.7.166:8381/CreateWS-1/AddressService?wsdl"
      namespace="http://test.morex.com/" />

   <message id="findCustomerAddressRequestMessage" itemRef="tns:findCustomerAddressRequestItem" />
   <message id="findCustomerAddressResponseMessage" itemRef="tns:findCustomerAddressResponseItem" />

   <itemDefinition id="findCustomerAddressRequestItem"       structureRef="classObject:findCustomerAddress" />
   <itemDefinition id="findCustomerAddressResponseItem"       structureRef="classObject:findCustomerAddressResponse" />

   <interface name="Find customer address" implementationRef="classObject:AddressService">
      <operation id="findCustomerAddressOperation" name="Find Customer Address by name" implementationRef="classObject:findCustomerAddress">
         <inMessageRef>tns:findCustomerAddressRequestMessage</inMessageRef>
         <outMessageRef>tns:findCustomerAddressResponseMessage</outMessageRef>
      </operation>
   </interface>

   <process id="call_wsdl">

      <dataObject id="dataInputOfProcess" itemSubjectRef="tns:findCustomerAddressRequestItem" />
      <dataObject id="dataOutputOfProcess" itemSubjectRef="tns:findCustomerAddressResponseItem" />      

      <startEvent id="startevent" name="Start" />
      <sequenceFlow id="flow1" sourceRef="startevent"          targetRef="theScriptTask" />
      <scriptTask id="theScriptTask" scriptFormat="groovy"          name="Execute script">
         <script>
            System.out.println("dataInputOfProcess : "+dataInputOfProcess);
            System.out.println("dataOutputOfProcess : "+dataOutputOfProcess);
         </script>
      </scriptTask>
      <sequenceFlow id="flow1a" sourceRef="theScriptTask" targetRef="webService" />

      <serviceTask id="webService" name="Find customer address web service" implementation="##WebService" operationRef="tns:findCustomerAddressOperation">
         <ioSpecification>
            <dataInput itemSubjectRef="tns:findCustomerAddressRequestItem" isCollection="false"    id="requestItem" />
            <dataOutput itemSubjectRef="tns:findCustomerAddressResponseItem" isCollection="false" id="responsetItem" />
            <inputSet>
               <dataInputRefs>requestItem</dataInputRefs>
            </inputSet>
            <outputSet>
               <dataOutputRefs>responsetItem</dataOutputRefs>
            </outputSet>            
         </ioSpecification>
         <dataInputAssociation>
            <sourceRef>dataInputOfProcess</sourceRef>
            <targetRef>requestItem</targetRef>            
         </dataInputAssociation>
         <dataOutputAssociation>
              <targetRef>dataOutputOfProcess</targetRef>
              <transformation>${responsetItem}</transformation>
         </dataOutputAssociation>         
      </serviceTask>

      <sequenceFlow id="flow21" sourceRef="webService" targetRef="theScriptTask2" />
      <scriptTask id="theScriptTask2" scriptFormat="groovy" name="Execute script 2">
         <script>
            System.out.println("dataInputOfProcess : "+dataInputOfProcess);
            System.out.println("dataOutputOfProcess : "+dataOutputOfProcess);
         </script>
      </scriptTask>
      <sequenceFlow id="flow2" sourceRef="theScriptTask2" targetRef="endevent" />
      <endEvent id="endevent" name="End" />
      
   </process>

</definitions>



And my java code :



package com.bpmn.test;

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

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;

public class ProcessRunner {
   
   public static void main(String[] args) {
      
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

      RepositoryService repositoryService = processEngine.getRepositoryService();

      repositoryService.createDeployment() .addClasspathResource("call_WSDL.bpmn20.xml") .deploy();

      RuntimeService runtimeService = processEngine.getRuntimeService();      
      
      Map<String, Object> variables = new HashMap<String, Object>();
      variables.put("dataInputOfProcess", "morex");
      variables.put("dataOutputOfProcess", "x");

      runtimeService.startProcessInstanceByKey("call_wsdl",variables);   
   }   
}


Okey , Now look at result :

web service log :



01:23:55,332 INFO  [STDOUT] ——————————————————-
01:23:55,333 INFO  [STDOUT] |                                                     |
01:23:55,333 INFO  [STDOUT] |                                                     |
01:23:55,333 INFO  [STDOUT] |                                                     |
01:23:55,333 INFO  [STDOUT] |                                                     |
01:23:55,333 INFO  [STDOUT] |         customerName = morex
01:23:55,334 INFO  [STDOUT] |                                                     |
01:23:55,334 INFO  [STDOUT] |                                                     |
01:23:55,334 INFO  [STDOUT] |                                                     |
01:23:55,334 INFO  [STDOUT] |                                                     |
01:23:55,334 INFO  [STDOUT] ——————————————————-


and java code result :



Jan 30, 2013 3:17:38 PM org.activiti.engine.ProcessEngines init
INFO: Initializing process engine using configuration 'file:/F:/morteza-pooladi-share/JAVA/workspace/Test21/target/classes/activiti.cfg.xml'
Jan 30, 2013 3:17:38 PM org.activiti.engine.ProcessEngines initProcessEnginFromResource
INFO: initializing process engine for resource file:/F:/morteza-pooladi-share/JAVA/workspace/Test21/target/classes/activiti.cfg.xml
Jan 30, 2013 3:17:38 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from resource loaded through InputStream
Jan 30, 2013 3:17:39 PM org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
Jan 30, 2013 3:17:39 PM org.activiti.engine.ProcessEngines initProcessEnginFromResource
INFO: initialised process engine default
Jan 30, 2013 3:17:39 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource call_WSDL.bpmn20.xml
Jan 30, 2013 3:17:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
Jan 30, 2013 3:17:39 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
Jan 30, 2013 3:17:40 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseProcessDefinitions
INFO: Process with id='call_wsdl' has no attribute isExecutable. Assuming it is executable. Better set the attribute explicitely, especially to be compatible with future engine versions which might change the default behavior.
dataInputOfProcess : morex
dataOutputOfProcess : x
Jan 30, 2013 3:17:41 PM org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
INFO: Created classes: com.morex.test.FindCustomerAddress, com.morex.test.FindCustomerAddressResponse, com.morex.test.ObjectFactory

dataInputOfProcess : morex
dataOutputOfProcess : org.activiti.engine.impl.bpmn.data.ItemInstance@260829


Now my question : How can I check content of [ org.activiti.engine.impl.bpmn.data.ItemInstance@260829 ] ???

Thanks for your help .

Outcomes