8 Replies Latest reply on Apr 5, 2010 7:07 AM by 843830

    How to call BPEL from java Client code?

      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?
          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?
            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?
              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: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">
                      <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"/>
                  <message name="SynchronousSampleOperationRequest">
                      <part name="a" type="xsd:int"/>
                      <part name="b" type="xsd:int"/>
                  <message name="SynchronousSampleOperationReply">
                      <part name="r" type="xsd:int"/>
                  <portType name="SynchronousSamplePortType">
                      <operation name="SynchronousSampleOperation">
                          <input name="input1" message="tns:SynchronousSampleOperationRequest"/>
                          <output name="output1" message="tns:SynchronousSampleOperationReply"/>
                  <binding name="SynchronousSampleBinding" type="tns:SynchronousSamplePortType">
                      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
                      <operation name="SynchronousSampleOperation">
                          <input name="input1">
                              <soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/SynchronousSample"/>
                          <output name="output1">
                              <soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/SynchronousSample"/>
                  <service name="SynchronousSampleService">
                      <port name="SynchronousSamplePort" binding="tns:SynchronousSampleBinding">
                          <soap:address location="http://localhost:18181/SynchronousSampleService/SynchronousSamplePort"/>
                  <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"/>
              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.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);
                          String result = call.invoke(new Object[]{"1000", "123456"}).toString();
                      } catch (Exception ex) {
              • 4. Re: How to call BPEL from java Client code?
                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?
                  Is it a working example/code - anybody tested it?
                  • 6. Re: How to call BPEL from java Client code?
                    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?
                      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.

                      • 8. Re: How to call BPEL from java Client code?

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


                        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" />
                        <soap:body use="literal" />
                        <soap:body use="literal" />

                        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.setOperationName(new QName(NAMESPACE, "process"));

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

                        your urgent help is much appreciated....