AnsweredAssumed Answered

response web service return null

Question asked by carlosrp on Feb 25, 2015
Latest reply on Apr 13, 2015 by carlosrp
Hi, I have tried to create a Hello world with activities where you consume a web service, took a week doing this and finally today I could consume the web service but the value that returned was null and I don't know why.
This example is very short, you will not take much time to help me
I don't speak English very well, i speak spanish, so please forgive my mistakes

this is my wsdl

<wsdl:definitions name="HelloWorldImplService"
   targetNamespace="http://webservicecxf.cdae.uci.cu/">
   <wsdl:types>
      <xs:schema elementFormDefault="unqualified"
         targetNamespace="http://webservicecxf.cdae.uci.cu/" version="1.0">
         <xs:element name="sayHi" type="tns:sayHi" />
         <xs:element name="sayHiResponse" type="tns:sayHiResponse" />
         <xs:complexType name="sayHi">
            <xs:sequence>
               <xs:element minOccurs="0" name="arg0" type="xs:string" />
            </xs:sequence>
         </xs:complexType>
         <xs:complexType name="sayHiResponse">
            <xs:sequence>
               <xs:element minOccurs="0" name="return" type="xs:string" />
            </xs:sequence>
         </xs:complexType>
      </xs:schema>
   </wsdl:types>
   <wsdl:message name="sayHiResponse">
      <wsdl:part element="tns:sayHiResponse" name="parameters">
      </wsdl:part>
   </wsdl:message>
   <wsdl:message name="sayHi">
      <wsdl:part element="tns:sayHi" name="parameters">
      </wsdl:part>
   </wsdl:message>
   <wsdl:portType name="HelloWorld">
      <wsdl:operation name="sayHi">
         <wsdl:input message="tns:sayHi" name="sayHi">
         </wsdl:input>
         <wsdl:output message="tns:sayHiResponse" name="sayHiResponse">
         </wsdl:output>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="HelloWorldImplServiceSoapBinding"
      type="tns:HelloWorld">
      <soap:binding style="document"
         transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="sayHi">
         <soap:operation soapAction="" style="document" />
         <wsdl:input name="sayHi">
            <soap:body use="literal" />
         </wsdl:input>
         <wsdl:output name="sayHiResponse">
            <soap:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="HelloWorldImplService">
      <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding"
         name="HelloWorldImplPort">
         <soap:address location="http://localhost:8080/webservicecxf/HelloWorld" />
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>



this is my process.bpmn20.xml

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   targetNamespace="http://www.bpmnwithactiviti.org"
   xmlns:tns="http://www.bpmnwithactiviti.org"
   xmlns:activiti="http://activiti.org/bpmn"
   xmlns:myservice="http://webservicecxf.cdae.uci.cu/">
   
   <import importType="http://schemas.xmlsoap.org/wsdl/"
      location="http://localhost:8080/webservicecxf/HelloWorld?wsdl"
      namespace="http://webservicecxf.cdae.uci.cu/" />
      
   <message id="sayHiRequestMessage"
      itemRef="tns:sayHiRequestItem" />
   <message id="sayHiResponseMessage"
      itemRef="tns:sayHiResponseItem" />
      
   <itemDefinition id="sayHiRequestItem"
      structureRef="myservice:sayHi" />
   <itemDefinition id="sayHiResponseItem"
      structureRef="myservice:sayHiResponse" />
      
   <interface name="Say Hi"
            implementationRef="myservice:HelloWorld">
      <operation id="sayHiOperation"
               name="Say Hi operation"
               implementationRef="myservice:sayHi">
         <inMessageRef>
            tns:sayHiRequestMessage
         </inMessageRef>
         <outMessageRef>
            tns:sayHiResponseMessage
         </outMessageRef>
      </operation>
   </interface>
   
   <itemDefinition id="arg0"
               structureRef="string" />
   <itemDefinition id="return"
               structureRef="string" />
               
   <itemDefinition id="name"
               structureRef="string" />
   <itemDefinition id="greet"
               structureRef="string" />
               
   <process id="webServiceProcess">
   
      <startEvent id="startevent" name="Start"/>
      <sequenceFlow sourceRef="startevent" targetRef="webService"/>
      
      <serviceTask id="webService"
                name="Say hi web service"
                implementation="##WebService"
                operationRef="tns:sayHiOperation">
               
         <ioSpecification>
            <dataInput itemSubjectRef="tns:sayHiRequestItem" id="dataInput" />
            <dataOutput itemSubjectRef="tns:sayHiResponseItem" id="dataOutput" />
            <inputSet>
               <dataInputRefs>dataInput</dataInputRefs>
            </inputSet>
            <outputSet>
               <dataOutputRefs>dataOutput</dataOutputRefs>
            </outputSet>
         </ioSpecification>
         
         <dataInputAssociation>
            <sourceRef>name</sourceRef>
            <targetRef>arg0</targetRef>
         </dataInputAssociation>
         <dataOutputAssociation>
            <sourceRef>return</sourceRef>
            <targetRef>greet</targetRef>
         </dataOutputAssociation>
         
      </serviceTask>
      <sequenceFlow sourceRef="webService" targetRef="scriptTask1"/>
      
      <scriptTask id="scriptTask1" scriptFormat="groovy">
         <script>
            out:println greet;
         </script>
       </scriptTask>
       <sequenceFlow sourceRef="scriptTask2" targetRef="endevent"/>
      
      <endEvent id="endevent" name="End"/>
   </process>
</definitions>


this is my test unit, where greet variable return null and i don't why

public class WebServiceTest {

   @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg-mem.xml");

   @Test
   @Deployment(resources = { "process.bpmn20.xml" })
   public void queryTask() {
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("name", "Carlos");
      
      ProcessInstance processInstance = activitiRule.getRuntimeService()
            .startProcessInstanceByKey("webServiceProcess", variableMap);
      
      Object responseValue = activitiRule.getRuntimeService().getVariable(
            processInstance.getProcessInstanceId(), "greet");
      Assert.assertEquals("Hello Carlos", responseValue);
   }

}

Outcomes