6 Replies Latest reply on Jul 3, 2006 9:08 AM by User Anonymous

    BPEL and Java

    User Anonymous Newbie

      Hello,

      I would like to create a process in BPEL (to work with jbpm).

      A client application coded in Java creates a new instance of the process. Then, the state node of the process wait that the client send a data (receive node).
      Here, the partner link is the client application. But with the BPEL Process, I have to give the partner link type information, but how can I give the partner link information because it is a link to a WSDL file (and with my client application, I don't have a WSDL file).

      Also, how my client can send data to BPEL process ?


      In fact, how can I do the communication between the BPEL process and a client application coded in Java.

      Thanks.

        • 1. Re: BPEL and Java
          Alejandro Guizar Master

           

          I would like to create a process in BPEL (to work with jbpm)

          Go for it!
          A client application coded in Java creates a new instance of the process. Then, the state node of the process wait that the client send a data (receive node).

          This is not the way a BPEL process is supposed to work. Initial activities in your process must be capable of taking an inbound message (i.e. be either receive or pick). Upon message arrival, the engine creates a new instance of the process.

          But remember, Processes in WS-BPEL export and import functionality by using Web Service interfaces exclusively. This is stated in the abstract of the BPEL specification.
          how my client can send data to BPEL process ?

          By sending a message to one of the endpoints published by the process. Use JAX-RPC, SAAJ or your favorite client side web service framework.

          Your use case does not fit well in the BPEL model. The requirements you specify are more directly covered by our workflow/BPM language, jPDL. You might want to check it out. The user guide is available online.

          • 2. Re: BPEL and Java
            User Anonymous Newbie

             

            "alex.guizar@jboss.com" wrote:
            I would like to create a process in BPEL (to work with jbpm)

            Go for it!
            A client application coded in Java creates a new instance of the process. Then, the state node of the process wait that the client send a data (receive node).

            This is not the way a BPEL process is supposed to work. Initial activities in your process must be capable of taking an inbound message (i.e. be either receive or pick). Upon message arrival, the engine creates a new instance of the process.

            But remember, <em>Processes in WS-BPEL export and import functionality by using Web Service interfaces exclusively</em>. This is stated in the abstract of the BPEL specification.
            how my client can send data to BPEL process ?

            By sending a message to one of the endpoints published by the process. Use JAX-RPC, SAAJ or your favorite client side web service framework.

            Your use case does not fit well in the BPEL model. The requirements you specify are more directly covered by our workflow/BPM language, jPDL. You might want to check it out. The user guide is available <a href="http://docs.jboss.com/jbpm/v3/userguide/">online</a>.


            Thanks for your response.

            In fact, I want to do like the "hello process" in the bpel tutorial of jbpm, where the process receive the name from a client (coded in Java for me).


            You talk about the jPDL (with tasks node ?), unfortunately, I can't use the Jpdl (because I have to use BPEL) :(

            • 3. Re: BPEL and Java
              User Anonymous Newbie

               

              "alex.guizar@jboss.com" wrote:

              how my client can send data to BPEL process ?

              By sending a message to one of the endpoints published by the process.


              I don't understand what do you mean with this ? I have red the bpel specification, but what is an endpoint ? And how is it modeled in the bpel process ?

              Thanks.

              • 4. Re: BPEL and Java
                User Anonymous Newbie

                Hello,

                I tried to make my own process from the hello process of jbpm bpel.

                1/ I can't deploy the process, what is wrong ?
                2/ With this process definition, is it possible after to communicate and exchange data with my client application coded in Java ?
                3/ Can I use different operations with differents partners link, but with same variables ?
                4/ I don't understand very well the role of "service" ?

                pwf.bpel :

                <?xml version="1.0" encoding="UTF-8"?>
                <process name="pwf" targetNamespace="http://jbpm.org/examples/hello"
                 xmlns:tns="http://jbpm.org/examples/hello"
                 xmlns:bpel="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://schemas.xmlsoap.org/ws/2003/03/business-process/
                 http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                 xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
                
                 <partnerLinks>
                 <!-- realizes the abstract relationship with the caller -->
                 <partnerLink name="client" partnerLinkType="tns:loanformPLT" myRole="service"/>
                 <partnerLink name="CallCenter" partnerLinkType="tns:rdvPLT" myRole="service"/>
                 <partnerLink name="Agent" partnerLinkType="tns:loaninsurancePLT" myRole="service"/>
                 </partnerLinks>
                
                 <variables>
                 <!-- Variables of pwf -->
                 <variable name="carloan" messageType="tns:carloanMessage"/>
                 <variable name="callcenterbasket" messageType="tns:callcenterbasketMessage"/>
                 <variable name="rendezvous" messageType="tns:rendezvousMessage"/>
                 <variable name="driverprofile" messageType="tns:driverprofileMessage"/>
                 <variable name="carprofile" messageType="tns:carprofileMessage"/>
                 <variable name="insuranceinfo" messageType="tns:insuranceinfoMessage"/>
                 </variables>
                
                 <sequence>
                 <!-- receive a message carrying by the client (loan form) -->
                 <receive operation="pwf" partnerLink="client" portType="tns:carloanPT"
                 variable="carloan" createInstance="yes"/>
                
                 <!-- reply with a message carrying the launch of the process to the call center basket -->
                 <reply operation="pwf" partnerLink="client" portType="tns:callcenterbasketPT"
                 variable="callcenterbasket"/>
                
                 <!-- receive a message carrying by the call center (rendez-vous) -->
                 <receive operation="pwf" partnerLink="callcenter" portType="tns:rendezvousPT"
                 variable="rendezvous" createInstance="no"/>
                
                 <!-- reply with a message carrying the date of the rendez-vous to the agent -->
                 <reply operation="pwf" partnerLink="agent" portType="tns:rendezvousPT"
                 variable="rendezvous"/>
                
                 <!-- reply with a message carrying the car loan to the agent (Car Loan) -->
                 <reply operation="pwf" partnerLink="agent" portType="tns:carloanPT"
                 variable="carloan"/>
                
                 <!-- receive a message carrying by the agent (Car Loan) -->
                 <receive operation="pwf" partnerLink="agent" portType="tns:carloanPT"
                 variable="carloan" createInstance="no"/>
                
                 <!-- receive a message carrying by the agent (Driver Profile) -->
                 <receive operation="pwf" partnerLink="agent" portType="tns:driverprofilePT"
                 variable="driverprofile" createInstance="no"/>
                
                 <!-- receive a message carrying by the agent (Car Profile) -->
                 <receive operation="pwf" partnerLink="agent" portType="tns:carprofilePT"
                 variable="carprofile" createInstance="no"/>
                
                 <!-- receive a message carrying by the agent (Insurance Info) -->
                 <receive operation="pwf" partnerLink="agent" portType="tns:insuranceinfoPT"
                 variable="insuranceinfo" createInstance="no"/>
                 </sequence>
                
                </process>
                



                pwf.wsdl :

                <?xml version="1.0" encoding="UTF-8"?>
                <definitions targetNamespace="http://jbpm.org/examples/hello"
                 xmlns:tns="http://jbpm.org/examples/hello"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/
                 http://schemas.xmlsoap.org/wsdl/
                 http://schemas.xmlsoap.org/ws/2003/05/partner-link/
                 http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                 xmlns="http://schemas.xmlsoap.org/wsdl/">
                
                 <!-- characterizes the relationship between the process and the client -->
                 <plt:partnerLinkType name="loanformPLT">
                 <plt:role name="service">
                 <plt:portType name="tns:carloanPT"/>
                 </plt:role>
                 </plt:partnerLinkType>
                
                 <!-- characterizes the relationship between the process and the call center -->
                 <plt:partnerLinkType name="rdvPLT">
                 <plt:role name="service">
                 <plt:portType name="tns:callcenterbasketPT"/>
                 </plt:role>
                 <plt:role name="service">
                 <plt:portType name="tns:rendezvousPT"/>
                 </plt:role>
                 </plt:partnerLinkType>
                
                 <!-- characterizes the relationship between the process and the agent -->
                 <plt:partnerLinkType name="loaninsurancePLT">
                 <plt:role name="service">
                 <plt:portType name="tns:carloanPT"/>
                 </plt:role>
                 <plt:role name="service">
                 <plt:portType name="tns:accountdataPT"/>
                 </plt:role>
                 <plt:role name="service">
                 <plt:portType name="tns:driverprofilePT"/>
                 </plt:role>
                 <plt:role name="service">
                 <plt:portType name="tns:carprofilePT"/>
                 </plt:role>
                 <plt:role name="service">
                 <plt:portType name="tns:insuranceinfoPT"/>
                 </plt:role>
                 </plt:partnerLinkType>
                
                
                 <!-- carries the structure of car loan -->
                 <message name="carloanMessage">
                 <part name="idclient" type="xsd:string"/>
                 <part name="globaleffectiverate" type="xsd:float"/>
                 <part name="globalfixedrate" type="xsd:float"/>
                 <part name="loanamount" type="xsd:double"/>
                 <part name="duedatequantity" type="xsd:int"/>
                 <part name="duedateamount" type="xsd:double"/>
                 <part name="standingcharges" type="xsd:double"/>
                 <part name="vehicletype" type="xsd:string"/>
                 <part name="firstduedatewish" type="xsd:date"/>
                 <part name="homecharges" type="xsd:double"/>
                 <part name="totalotherloanamount" type="xsd:double"/>
                 <part name="othercharges" type="xsd:double"/>
                 <part name="grossincome" type="xsd:double"/>
                 <part name="otherincome" type="xsd:double"/>
                 </message>
                
                 <!-- carries the id client in the call center basket -->
                 <message name="callcenterbasketMessage">
                 <part name="idclient" type="xsd:string"/>
                 </message>
                
                 <!-- carries the date of the rendez-vous -->
                 <message name="rendezvousMessage">
                 <part name="daterdv" type="xsd:string"/>
                 </message>
                
                 <!-- carries the structure of the driver profile -->
                 <message name="driverprofileMessage">
                 <part name="drivinglicensedate" type="xsd:string"/>
                 <part name="isconduiteaccompagnee" type="xsd:boolean"/>
                 <part name="isdrivinglicensesuspension" type="xsd:boolean"/>
                 <part name="suspensiondate" type="xsd:string"/>
                 <part name="bonus" type="xsd:float"/>
                 <part name="insuranceduration" type="xsd:int"/>
                 <part name="accidentnumber" type="xsd:int"/>
                 <part name="isalreadyinsured" type="xsd:boolean"/>
                 <part name="vehicleusage" type="xsd:string"/>
                 <part name="kilometrage" type="xsd:int"/>
                 </message>
                
                 <!-- carries the structure of the car profile -->
                 <message name="carprofileMessage">
                 <part name="brandname" type="xsd:string"/>
                 <part name="model" type="xsd:string"/>
                 <part name="powersourcetype" type="xsd:string"/>
                 <part name="bodywork" type="xsd:string"/>
                 <part name="codevehicle" type="xsd:string"/>
                 <part name="version" type="xsd:string"/>
                 <part name="enginepower" type="xsd:string"/>
                 <part name="minetype" type="xsd:string"/>
                 <part name="firstbuildyear" type="xsd:string"/>
                 </message>
                
                 <!-- carries the structure of insurance information -->
                 <message name="insuranceinfoMessage">
                 <part name="couvertureassurance" type="xsd:string"/>
                 </message>
                
                
                 <!-- describes the interface presented to clients -->
                 <portType name="carloanPT">
                 <operation name="pwf">
                 <input message="tns:carloanMessage"/>
                 <output message="tns:carloanMessage"/>
                 </operation>
                 </portType>
                
                 <portType name="callcenterbasketPT">
                 <operation name="pwf">
                 <output message="tns:callcenterbasketMessage"/>
                 </operation>
                 </portType>
                
                 <portType name="rendezvousPT">
                 <operation name="pwf">
                 <input message="tns:rendezvousMessage"/>
                 <output message="tns:rendezvousMessage"/>
                 </operation>
                 </portType>
                
                 <portType name="driverprofilePT">
                 <operation name="pwf">
                 <input message="tns:driverprofileMessage"/>
                 </operation>
                 </portType>
                
                 <portType name="carprofilePT">
                 <operation name="pwf">
                 <input message="tns:carprofileMessage"/>
                 </operation>
                 </portType>
                
                 <portType name="insuranceinfoPT">
                 <operation name="pwf">
                 <input message="tns:insuranceinfoMessage"/>
                 </operation>
                 </portType>
                </definitions>
                



                bpel-definition.xml :

                <?xml version="1.0" encoding="UTF-8"?>
                <!-- specifies the location of the process definition -->
                <bpelDefinition location="pwf.bpel"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://jbpm.org/bpel
                 http://jbpm.org/bpel/bpel_definition_1_0.xsd"
                 xmlns="http://jbpm.org/bpel" >
                
                 <!-- makes WSDL interface elements available to the process -->
                 <imports>
                 <wsdl namespace="http://jbpm.org/examples/hello" location="pwf.wsdl"/>
                 </imports>
                
                </bpelDefinition>
                



                Thanks for your help.

                • 5. Re: BPEL and Java
                  Alejandro Guizar Master

                  Hi,

                  1/ I can't deploy the process, what is wrong ?

                  It's hard to tell without more details. What step of the deployment procedure failed? What is the error message?

                  2/ With this process definition, is it possible after to communicate and exchange data with my client application coded in Java ?

                  Refer to the tutorial chapter of the jBPM BPEL manual. It explains, step by step, how to create and deploy a J2EE application client, and how to use that from a Java client application (a JUnit test case).

                  3/ Can I use different operations with differents partners link, but with same variables ?

                  Often, operations from different partners use different messages. The type of the variable used to read/write an outgoing/incoming message should match the operation input, output or fault message.

                  That said, you can always reuse variables for different operations that share a message definition.
                  4/ I don't understand very well the role of "service" ?

                  Let's consider one of your partner links:
                  <partnerLink name="CallCenter" partnerLinkType="tns:rdvPLT" myRole="service"/>

                  This means the process will assume the role named "service" in the relationship characterized by "tns:rdvPLT". The role in turn points to a WSDL port type definitions whose operations define the responsibilities assiged to that role.

                  Since there is no partnerRole attribute, this relationship is unidirectional: the process will not invoke any operation on this partner.

                  The referenced partner link type is:
                  <plt:partnerLinkType name="rdvPLT">
                   <plt:role name="service">
                   <plt:portType name="tns:callcenterbasketPT"/>
                   </plt:role>
                   <plt:role name="service">
                   <plt:portType name="tns:rendezvousPT"/>
                   </plt:role>
                   </plt:partnerLinkType>

                  Things get clumsy here. In the first place this is an invalid partner link type because roles must have different names. Second, the partner link above only assigns one role, but the partner link type defines two. You must either define a partnerRole in the partner link (if the relationship is bidirectional) or remove one role in the partner link type (if the relationship is unidirectional).

                  • 6. Re: BPEL and Java
                    User Anonymous Newbie

                    Thank you very much for your help. :)

                    I have another question, in my process, I use the partnerLink "Agent". But in fact, there will be many agents in my java program. Do I have operations to realize on the process ? How the process will know that it has to send (with a reply node) a data to this agent and not to another?