AnsweredAssumed Answered

UnsupportedOperationException when invoking a ws in workflow

Question asked by bluerain on Apr 7, 2011
Latest reply on Apr 9, 2011 by bluerain
I am trying to invoke a webservice (soap 1.2 based) from my workflow
and I am getting an error
java.lang.UnsupportedOperationException: Only document-style SOAP 1.1 http are supported for auto-selection of endpoint; none were found.
at org.apache.cxf.endpoint.ClientImpl.findEndpoint(ClientImpl.java:217)
   at org.apache.cxf.endpoint.ClientImpl.<init>(ClientImpl.java:156)
   at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:255)
   at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:198)
   at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:191)
   at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:146)
   at com.test.WsDelegate.execute(WsDelegate.java:23)

and my code is similar to the once available on the BPM-guide (http://www.bpm-guide.de/2010/12/09/how-to-call-a-webservice-from-bpmn/)

public class WsDelegate implements org.activiti.engine.delegate.JavaDelegate {
  private Expression wsdl;
  private Expression operation;
  private Expression parameters;
  private Expression returnValue;

  public void execute(DelegateExecution execution) throws Exception {
    String wsdlString = (String)wsdl.getValue(execution);

    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient(wsdlString);

    ArrayList paramStrings = new ArrayList();
    if (parameters!=null) {
      StringTokenizer st = new StringTokenizer( (String)parameters.getValue(execution), ",");
      while (st.hasMoreTokens()) {
        paramStrings.add(st.nextToken().trim());
      }
    }
    Object response = client.invoke((String)operation.getValue(execution), paramStrings.toArray(new Object[0]));
    if (returnValue!=null) {
      String returnVariableName = (String) returnValue.getValue(execution);
      execution.setVariable(returnVariableName, response);
    }
  }
}

my bpmn20.xml is like this

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 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" targetNamespace="http://www.activiti.org/test">
  <process id="helloworld" name="helloworld">
    <startEvent id="startevent5" name="Start"></startEvent>
    <serviceTask id="servicetask5" name="Service Task" activiti:class="com.test.WsDelegate">
      <extensionElements>
        <activiti:field name="wsdl">
          <activiti:string>http://pehz-qa1-soa01.company.net:8080/po-services/services/PurchaseOrderLifecycleSOAP12Service?wsdl</activiti:string>
        </activiti:field>
        <activiti:field name="operation">
          <activiti:string>releasePurchaseOrder</activiti:string>
        </activiti:field>
        <activiti:field name="parameters">
          <activiti:expression>${releasePurchaseOrderRequestType}</activiti:expression>
        </activiti:field>
        <activiti:field name="returnValue">
          <activiti:string>releasePurchaseOrderResponseType</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow11" name="" sourceRef="startevent5" targetRef="servicetask5"></sequenceFlow>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">
      <script><![CDATA[out:println"Hello Activiti, working on webservices !!";
out:println"Return value from webservices"+ returnValue;]]></script>
    </scriptTask>
    <endEvent id="endevent6" name="End"></endEvent>
    <sequenceFlow id="flow13" name="" sourceRef="servicetask5" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow14" name="" sourceRef="scripttask1" targetRef="endevent6"></sequenceFlow>
  </process>

what is the issue here ? How can I fix this ?
Thanks for you help !!

Outcomes