cancel
Showing results for 
Search instead for 
Did you mean: 

UnsupportedOperationException when invoking a ws in workflow

bluerain
Champ in-the-making
Champ in-the-making
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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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[outSmiley Tonguerintln"Hello Activiti, working on webservices !!";
outSmiley Tonguerintln"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 !!
4 REPLIES 4

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Is your code similar or identical? Have you tried searching on google since it does not seem Activiti related and the real error seems kind of clear.

bluerain
Champ in-the-making
Champ in-the-making
yes it is identical.
and what I think the reason for the error (found on google) is probably the webservice I am trying to invoke is a soap 1.2 compliant and I am using the JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(wsdlString);

which is for soap 1.1 compliant…Hence the error !!
So my question is what is activiti way of invoking  a soap 1.2 compliant webservice?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
One of the options is to do it from java like in the example but use the cxf soap 1.2 way… But I think you already figured that out, tried it and failed, right?

bluerain
Champ in-the-making
Champ in-the-making
I found out a way which is something like this

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ChangePurchaseOrderPortType.class);
factory.setAddress(wsdlString);
ChangePurchaseOrderPortType service = (ChangePurchaseOrderPortType) factory.create();

Object response = service.changePurchaseOrder((ChangePurchaseOrderRequestType)parameters.getValue(execution));

But this approach is tightly coupled with the operation name. Is there anyother way that you can suggest?