This discussion is archived
8 Replies Latest reply: Aug 18, 2008 2:04 AM by 843830 RSS

How to call BPEL from java Client code?

843830 Newbie
Currently Being Moderated
I have created one Bpel in netbean 6.1 and want to pass parameters from java client and get back the result.If Any one know how to invoke bpel from java client code do reply soon with java sample code?

Edited by: Avi007 on Feb 22, 2008 1:43 AM
  • 1. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    This is no different from calling any webservice from Java code. your BPEL implemented the service defined in the WSDL. I am assuming you are aware of service assembly and JBI. Use the composite application project type to create the service assembly and deploy the project to the appserver. There are lots of examples/blueprints/videos on doing this stuff. Your WSDL should have some binding section, lets say http. Now from your Java Client call this webservice using JAX-WS or any other mechanism.

    -Kiran B
  • 2. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    Using netbeans you can create a java application project. Right click on the project and select New Web Service Client. This will open up a dialog box, select the WSDL for the BPEL Process. This would generate necessary classes that would allow you to create message and call the web service. I dont have handly examples, but this will get you started.
  • 3. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    The annex to prepare a code from an example in NetBeans (SynchronousSample)
    Le anexo un c�digo que prepare a partir de un ejemplo en NetBeans (SynchronousSample):

    WSDL code:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="SynchronousSample" targetNamespace="http://j2ee.netbeans.org/wsdl/SynchronousSample"
        xmlns="http://schemas.xmlsoap.org/wsdl/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://j2ee.netbeans.org/wsdl/SynchronousSample" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://xml.netbeans.org/schema/SynchronousSample">
        <types>
            <xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/SynchronousSample" xmlns:ns1="http://xml.netbeans.org/schema/SynchronousSample">
                <xsd:import namespace="http://xml.netbeans.org/schema/SynchronousSample" schemaLocation="SynchronousSample.xsd"/>
            </xsd:schema>
        </types>
        <message name="SynchronousSampleOperationRequest">
            <part name="a" type="xsd:int"/>
            <part name="b" type="xsd:int"/>
        </message>
        <message name="SynchronousSampleOperationReply">
            <part name="r" type="xsd:int"/>
        </message>
        <portType name="SynchronousSamplePortType">
            <operation name="SynchronousSampleOperation">
                <input name="input1" message="tns:SynchronousSampleOperationRequest"/>
                <output name="output1" message="tns:SynchronousSampleOperationReply"/>
            </operation>
        </portType>
        <binding name="SynchronousSampleBinding" type="tns:SynchronousSamplePortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="SynchronousSampleOperation">
                <soap:operation/>
                <input name="input1">
                    <soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/SynchronousSample"/>
                </input>
                <output name="output1">
                    <soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/SynchronousSample"/>
                </output>
            </operation>
        </binding>
        <service name="SynchronousSampleService">
            <port name="SynchronousSamplePort" binding="tns:SynchronousSampleBinding">
                <soap:address location="http://localhost:18181/SynchronousSampleService/SynchronousSamplePort"/>
            </port>
        </service>
        <plnk:partnerLinkType name="SynchronousSample1">
            <!-- A partner link type is automatically generated when a new port type is added. Partner link types are used by BPEL processes. 
    In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service. Each partner link is associated with a partner link type.
    A partner link type characterizes the conversational relationship between two services. The partner link type can have one or two roles.-->
            <plnk:role name="SynchronousSamplePortTypeRole" portType="tns:SynchronousSamplePortType"/>
        </plnk:partnerLinkType>
    </definitions>
    Java client code with Axis
    package esbclientapplication;
    
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ParameterMode;
    import org.apache.axis.Constants;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.constants.Style;
    
    /**
     *
     * @author Julian David Rojas Jimenez (juliandrj gmail com)
     */
    public class Main {
    
        final static String NAMESPACE = "http://j2ee.netbeans.org/wsdl/SynchronousSample";
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            try {
                Service service = new Service();
                Call call = (Call) service.createCall();
                call.setTargetEndpointAddress("http://localhost:18181/SynchronousSampleService/SynchronousSamplePort");
                call.setOperationStyle(Style.RPC);
                call.setOperationName(new QName(NAMESPACE, "SynchronousSampleOperation"));
                call.addParameter("a", Constants.XSD_INT, ParameterMode.IN);
                call.addParameter("b", Constants.XSD_INT, ParameterMode.IN);
                call.addParameter("r", Constants.XSD_INT, ParameterMode.OUT);
                call.setReturnType(Constants.XSD_ANY);
                String result = call.invoke(new Object[]{"1000", "123456"}).toString();
                System.out.println(result);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
  • 4. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    Krian: There are many blueprint, exercises and examples, but they are very specific, do not go directly to attack various developments, for example, I created a BPEL and asynchronous, with correlation and assume instead connected to webservices.

    My problem occurs when creating client of the webservice BPEL, and that client of webservices I have no problem in the buildup.

    I have a lot of time trying to find out what happens, look blueprints, examples, etc.. But I fail to fix the error and is as follows:

    *[WARNING] ignoring operation "AsignacionOcrOperation": message part does not refer to a schema type declaration*
    line 21 of file:/home/zidboy/mundial/desarrollo/netbeans6/WebServicesClientGenerator/conf/xml-resources/web-service-references/AsignacionOcrPortTypeBindingPort/wsdl/localhost_18181/AsignacionOcrService/AsignacionOcrPortTypeBindingPort.wsdl

    *[WARNING] Port "AsignacionOcrPortTypeBindingPort" does not contain any usable operations*
    line 46 of file:/home/zidboy/mundial/desarrollo/netbeans6/WebServicesClientGenerator/conf/xml-resources/web-service-references/AsignacionOcrPortTypeBindingPort/wsdl/localhost_18181/AsignacionOcrService/AsignacionOcrPortTypeBindingPort.wsdl

    *[WARNING] Service "AsignacionOcrService" does not contain any usable ports. try running wsimport with -extension switch.*
    line 45 of file:/home/zidboy/mundial/desarrollo/netbeans6/WebServicesClientGenerator/conf/xml-resources/web-service-references/AsignacionOcrPortTypeBindingPort/wsdl/localhost_18181/AsignacionOcrService/AsignacionOcrPortTypeBindingPort.wsdl

    generating code...

    Krian, if you have any idea that I could give would be fabulous, if you need the sources would have problems in sending the draft codes BPEL.

    ... Thanks in advance.
  • 5. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    Is it a working example/code - anybody tested it?
  • 6. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    Hi,
    It doesn't work for me since the client can't find the endpoint of the process.
    I test BPEL with tests in Composite App, but can't call it as a regular Web Service.
    It seems that address is deferent from Web Service deployment.
    Usually, the addres looks http://localhost:8080/MyWSapp/MyService
    It doesn't help if I try http://localhost:8080/MyCompositeApp/MyBpelService

    Probably the port or address generation is different for JBI modules.

    Any ideas about the right address?
  • 7. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    I found it at last >:-|
    The right address is http://localhost:9080/MyBpelProject/MyService/MyServicePort

    This differs a lot from the addresses for regular Web Services. I wonder why.

    Andrey
  • 8. Re: How to call BPEL from java Client code?
    843830 Newbie
    Currently Being Moderated
    Hi,

    I need a urgent help on this. I tried writing the client same way and every time I am getting following exception -

    org.apache.axis.message.SOAPFaultBuilder.createFault

    The soap body in brief ----

    <binding name="HelloWorldBinding" type="tns:HelloWorld">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="process">
    <soap:operation style="document" soapAction="process" />
    <input>
    <soap:body use="literal" />
    </input>
    <output>
    <soap:body use="literal" />
    </output>
    </operation>
    </binding>



    I doubt I am making some mistake on call.addParameter() or call.setReturnType() or call.invoke() . I am trying to use the same client as mentioned setting all axis / soap / mail / activation related jars in the classpath.

    Code snapshot -----

    call.setTargetEndpointAddress("http://localhost:8889/orabpel/default/HelloWorld/1.0");
    call.setOperationStyle(Style.DOCUMENT);
    call.setOperationName(new QName(NAMESPACE, "process"));

    call.addParameter("a", Constants.XSD_STRING, ParameterMode.IN);
    call.addParameter("r", Constants.XSD_INT, ParameterMode.OUT);
    call.setReturnType(org.apache.axis.Constants.XSD_STRING);
    String result = call.invoke( new Object[] { "a"}).toString();

    your urgent help is much appreciated....

    Tx,
    Joy...