1 Reply Latest reply on Jun 20, 2014 2:13 AM by Maciej Swiderski

    Using a ServiceTask to Call a JSON service with custom HTTP header authentication

    Cameron Smith Newbie

      Hello All,

       

      I am currently attempting to create some BPMN flows which will model a series of calls to JSON services, and make decisions based on the returned values.

       

      The service that I am calling is relying on custom HTTP header authentication information.

       

      From reading the documentation, I know that it is recommended that calls to external web services and the like are modelled by Service Tasks and not script tasks. However, it would be very easy (programmatically) to simply call back from a script task to my main codebase to query the service and get the required results. Why should I use a Service Task and not a Script task in this case?

       

      However, I tried to follow the documentation's advice, and use a Service Task. However I cannot figure out what I need to put in the various fields available. As far as I am concerned I should need the URL, including the port number, any parameters passed to the service, and username and password information (or authentication objects). It is not clear how this maps to the available options.

      I tried to select:

           Implementation: Unspecified     =>     Because I assume web service is only for SOAP style.

           Operation: New

                     In Message : I have no idea

                     Out message: I have no idea

           Input Parameter Mapping and Output Parameter Mapping I am also not sure of.

           There is "On entry script" and "On exit script", I assume I could send a request in the first and poll for the response in the latter? But then what is the meaning of the rest of this stuff?

       

      I guess I want to know where I put the URL, and what all these fields are for.

       

      Please help if you can?

       

      Thanks in advance,

       

      Cameron

       

      P.S. I also tried simply calling some Java code in the on entry and on exit scripts. This did not work, as I assume the parser requires at least a little bit of config. Here is the error I got when I tried to do that:

      [main] ERROR org.drools.core.xml.ExtensibleXmlParser - (null: 56, 32): cvc-complex-type.2.4.a: Invalid content was found starting with element 'bpmn2:extensionElements'. One of '{"http://www.omg.org/spec/BPMN/20100524/MODEL":auditing, "http://www.omg.org/spec/BPMN/20100524/MODEL":monitoring, "http://www.omg.org/spec/BPMN/20100524/MODEL":categoryValueRef, "http://www.omg.org/spec/BPMN/20100524/MODEL":incoming, "http://www.omg.org/spec/BPMN/20100524/MODEL":outgoing, "http://www.omg.org/spec/BPMN/20100524/MODEL":ioSpecification, "http://www.omg.org/spec/BPMN/20100524/MODEL":property, "http://www.omg.org/spec/BPMN/20100524/MODEL":dataInputAssociation, "http://www.omg.org/spec/BPMN/20100524/MODEL":dataOutputAssociation, "http://www.omg.org/spec/BPMN/20100524/MODEL":resourceRole, "http://www.omg.org/spec/BPMN/20100524/MODEL":loopCharacteristics}' is expected.

      java.lang.IllegalArgumentException: No interfaces found

          at org.jbpm.bpmn2.xml.ServiceTaskHandler.handleNode(ServiceTaskHandler.java:52)

       

      At this point I am leaning towards using a script task.

       

      Message was edited by: Cameron Smith