7 Replies Latest reply on Oct 29, 2007 6:32 AM by zazzaz

    Beginner: invoce web services from process: Hello, ATM,  Loa

      Hallo community,

      I'm back know after few week of silence due that i muss finish some theoretical part of my work and that my notebook was defect. So it's a great pleasure to find all the community again.

      The last time i post it was related to some issues with an process invocing a service. That examples didn't work.

      More than one beginners in JBPM need more examples after playing with the ATM and Hello business process included in the BPEL-Extension and need more examples for training. I had the same problem at my beginning with the JBPM-extension.

      This Loan Approval Process can be used for training purpose by beginners and also advanced users because. Advanced users can challenge them self by extending this simple Loanprocess by including an Assessor-Service, which first analyse the request depending on the creditamount like explained at : http://activebpel.org/docs/tutorial.html.

      Know i have designed (adapted) a standart Loan Approval Process in BPEL which calls the Loan Approver Web Service and forward clients LoanRequests containing LoanRequester firstName, lastName and the credit amount; I have already successfully deployed the Business process and the web service to jboss using the jbpm-Extension and every think work 100%.


      To my configuration: JBOss AS-4.0.1SP1, jbpm-bpel-1.0-alpha4, MYSQL-4.1 java-1.5 (jdk+jre) Update 6, JWSDP-1,6 on Pentium 3, 600 MHZ, Windows XP-SP2, 256 MB.

      I hope it's help some of you !


      Best regards

      Bertrand Njipwo


      My configuration Files:

      loanapproval.bpel

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process
      name="loanapproval"
      suppressJoinFailure="yes"
      targetNamespace="urn:samples:loanapproval"
      xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
      xmlns:tns= "urn:samples:loanapproval"
      xmlns:loanapproval="urn:samples:loanapproval"
      xmlns:loanapprover="urn:samples:loanapprover"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      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/">
      
      
      
       <partnerLinks>
       <partnerLink name="LoanProcessing" partnerLinkType="loanapproval:LoanProcessingPLT" myRole="lender"/>
       <partnerLink name="Approving" partnerLinkType="loanapprover:ApprovingPLT" partnerRole="approver"/>
       </partnerLinks>
       <variables>
       <variable name="applyRequest" messageType="loanapproval:applyRequest"/>
       <variable name="applyResponse" messageType="loanapproval:applyResponse"/>
       <variable name="approveRequest" messageType="loanapprover:approveRequest"/>
       <variable name="approveResponse" messageType="loanapprover:approveResponse"/>
       </variables>
       <sequence>
       <receive createInstance="yes" name="LoanApplication" operation="apply" partnerLink="LoanProcessing" portType="loanapproval:LoanProcessPortType" variable="applyRequest"/>
      
       <!--assign name="AssignLoanInfo_forApproval">
       <copy>
       <from part="loanRequestParameters" query="/types:apply/types:LoanApplication/types:firstName" variable="applyRequest"/>
       <to part="firstName" variable="approveRequest"/>
       </copy>
       <copy>
       <from part="loanRequestParameters" query="/types:apply/types:LoanApplication/types:lastName" variable="applyRequest"/>
       <to part="lastName" variable="approveRequest"/>
       </copy>
       <copy>
       <from part="loanRequestParameters" query="/types:apply/types:LoanApplication/types:amount" variable="applyRequest"/>
       <to part="amount" variable="approveRequest"/>
       </copy>
       </assign-->
      
       <assign name="AssignLoanInfo_forApproval">
       <copy>
       <from variable="applyRequest" query="/loanRequestParameters/firstName" part="loanRequestParameters"/>
       <to variable="approveRequest" part="firstName" />
       </copy>
       <copy>
       <from variable="applyRequest" query="/loanRequestParameters/lastName" part="loanRequestParameters"/>
       <to variable="approveRequest" part="lastName"/>
       </copy>
       <copy>
       <from variable="applyRequest" query="/loanRequestParameters/amount" part="loanRequestParameters"/>
       <to variable="approveRequest" part="amount"/>
       </copy>
       </assign>
      
      
       <invoke inputVariable="approveRequest" name="ApproveLoan" operation="approve" outputVariable="approveResponse" partnerLink="Approving" portType="loanapprover:LoanApproverPortType"/>
       <assign name="AssignLoanApprovalDecision">
       <!--copy>
       <from part="approved" variable="approveResponse"/>
       <to part="loanResponse" query="/types:applyResponse/types:ApprovalDecision/types:approved" variable="applyResponse"/>
       </copy-->
      
       <copy>
       <from variable="approveResponse" part="approved"/>
       <to variable="applyResponse" query="/loanResponse/approved" part="loanResponse"/>
       </copy>
      
       </assign>
       <reply name="ApprovalDecision" operation="apply" partnerLink="LoanProcessing" portType="loanapproval:LoanProcessPortType" variable="applyResponse"/>
       </sequence>
      </process>
      


      loanapproval.wsdl:

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:samples:loanapproval" xmlns:loanapproval="urn:samples:loanapproval" xmlns:loanapprover="urn:samples:loanapprover" xmlns:types="urn:samples:loanapprovalTypes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpel="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" targetNamespace="urn:samples:loanapproval">
       <import namespace="urn:samples:loanapprover" location="interface/loanapprover.wsdl"/>
       <types/>
       <types>
       <schema targetNamespace="urn:samples:loanapprovalTypes" xmlns="http://www.w3.org/2001/XMLSchema">
       <!--element name="applyLoanRequest" type="types:LoanApplicationType"/>
       <element name="applyResponse" type="types:ApprovalDecisionType"/-->
       <element name="loanProcessFault" type="types:loanProcessFaultType"/>
       <complexType name="loanApplicationType">
       <sequence>
       <element name="firstName" type="string"/>
       <element name="lastName" type="string"/>
       <element name="amount" type="float"/>
       </sequence>
       </complexType>
       <complexType name="approvalDecisionType">
       <sequence>
       <element name="approved" type="boolean"/>
       </sequence>
       </complexType>
       <complexType name="loanProcessFaultType">
       <sequence>
       <element name="ErrorCode" type="int"/>
       <element name="ErrorMessage" type="string"/>
       </sequence>
       </complexType>
       </schema>
       </types>
       <message name="applyRequest">
       <part name="loanRequestParameters" type="types:loanApplicationType"/>
       </message>
       <message name="applyResponse">
       <part name="loanResponse" type="types:approvalDecisionType"/>
       </message>
       <message name="applyLoanProcessFault">
       <part name="loanFault" element="types:loanProcessFault"/>
       </message>
       <portType name="LoanProcessPortType">
       <operation name="apply">
       <input message="tns:applyRequest"/>
       <output message="tns:applyResponse"/>
       <fault name="LoanProcessFault" message="tns:applyLoanProcessFault"/>
       </operation>
       </portType>
       <plt:partnerLinkType name="LoanProcessingPLT">
       <plt:role name="lender">
       <plt:portType name="tns:LoanProcessPortType"/>
       </plt:role>
       </plt:partnerLinkType>
      </definitions>
      


      approver.wsdl:

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="urn:samples:loanapprover"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
      targetNamespace="urn:samples:loanapprover"
      name="LoanApproverService">
      
       <message name="approveRequest">
       <part name="firstName" type="xsd:string"/>
       <part name="lastName" type="xsd:string"/>
       <part name="amount" type="xsd:float"/>
       </message>
      
       <message name="approveResponse">
       <part name="approved" type="xsd:boolean"/>
       </message>
      
       <portType name="LoanApproverPortType">
       <operation name="approve" parameterOrder="firstName lastName amount">
       <input message="tns:approveRequest"/>
       <output message="tns:approveResponse"/>
       </operation>
       </portType>
      
       <plt:partnerLinkType name="ApprovingPLT">
       <plt:role name="approver">
       <plt:portType name="tns:LoanApproverPortType"/>
       </plt:role>
       </plt:partnerLinkType>
      </definitions>
      


      approver.svc.wsdl:
      <?xml version="1.0" encoding="UTF-8"?>
      <definitions
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="urn:samples:loanapprover"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       targetNamespace="urn:samples:loanapprover"
       si:schemaLocation="http://schemas.xmlsoap.org/wsdl/
       http://schemas.xmlsoap.org/wsdl/">
       <import namespace="urn:samples:loanapprover" location="loanapprover.wsdl"/>
       <binding name="LoanApproverSOAPBinding" type="tns:LoanApproverPortType">
       <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="approve">
       <soap:operation soapAction="urn:samples:loanapprover:approve"/>
       <input>
       <soap:body use="literal" namespace="urn:samples:loanapprover"/>
       </input>
       <output>
       <soap:body use="literal" namespace="urn:samples:loanapprover"/>
       </output>
       </operation>
       </binding>
       <service name="LoanApproverService">
       <port name="LoanApproverPort" binding="tns:LoanApproverSOAPBinding">
       <soap:address location="REPLACE_WITH_ACTUAL_URI"/>
       </port>
       </service>
      </definitions>
      


      wscompile-cfg.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
       <wsdl location="wsdl/service.wsdl" packageName="org.jbpm.bpel.tutorial.loanapproval">
       <namespaceMappingRegistry>
       <namespaceMapping namespace="urn:samples:loanapprovalTypes" packageName="org.jbpm.bpel.tutorial.loanapproval.types"/>
       </namespaceMappingRegistry>
       </wsdl>
      </configuration>
      


      webservices.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <webservices version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:impl="urn:samples:loanapproval"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://java.sun.com/xml/ns/j2ee/j2ee_web_services_1_1.xsd">
       <webservice-description>
       <!-- descriptive name for the service -->
       <webservice-description-name>Loan Approval Service</webservice-description-name>
       <!-- WSDL implementation file (AUTO GENERATE FILE ) -->
       <!-- IMPLEMENTATIONDETAILS OF THE LOANAPPROVALSERVICE ARE SEPARED AND WILL BE GENERATED AUTOMATICALY BY THE GENERATE-SERVICE TOOL FOR THE WS4EE AND WRITE IN WEB-INF/wsdl/service.wsdl-->
       <wsdl-file>WEB-INF/wsdl/service.wsdl</wsdl-file>
       <!-- Java<->XML mapping file -->
       <jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
      
       <port-component>
       <!-- logical name for the port (unique within the module) -->
       <port-component-name>LoanProcessingPort</port-component-name>
      
       <!-- WSDL port element (in WSDL implementation file) -->
       <wsdl-port>impl:LoanProcessingPort</wsdl-port>
      
       <!-- service endpoint interface class -->
       <service-endpoint-interface>org.jbpm.bpel.tutorial.loanapproval.LoanProcessPortType</service-endpoint-interface>
      
       <!-- associated servlet (in web-app [web.xml] descriptor) -->
       <service-impl-bean>
       <servlet-link>LoanProcessingServlet</servlet-link>
       </service-impl-bean>
      
       <handler>
       <handler-name>LoanProcessingHandler</handler-name>
       <!-- handler class (in BPEL extension library) -->
       <handler-class>org.jbpm.bpel.service.messager.PortHandler</handler-class>
       <init-param>
       <description>
       name of the port; should match the partner link name
       </description>
       <!-- WAS IST WENN MANN MEHR GENAU " PARTNERLINK IN DER PROCESS-BESCHREIBUNGSFILE HAT ? MUSS MAN HIER 2 SOLCHE ELEMENTE DEFINIEREN ? -->
       <param-name>portName</param-name>
       <param-value>LoanProcessing</param-value>
       </init-param>
       <init-param>
       <description>time to wait for response messages, in milliseconds</description>
       <param-name>responseTimeout</param-name>
       <param-value>60000</param-value>
       </init-param>
       </handler>
       </port-component>
       </webservice-description>
      </webservices>
      


      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
       <servlet>
       <servlet-name>LoanProcessingServlet</servlet-name>
       <!-- service implementation bean class -->
       <servlet-class>org.jbpm.bpel.tutorial.loanapproval.LoanProcessPortType_Impl</servlet-class>
       </servlet>
      
       <servlet>
       <servlet-name>messagerServlet</servlet-name>
       <servlet-class>org.jbpm.bpel.service.messager.MessagerServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>LoanProcessingServlet</servlet-name>
       <url-pattern>/LoanProcessing</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>messagerServlet</servlet-name>
       <url-pattern>/messager</url-pattern>
       </servlet-mapping>
      
       <resource-ref>
       <res-ref-name>jms/ConnectionFactory</res-ref-name>
       <res-type>javax.jms.ConnectionFactory</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
       </resource-ref>
      
       <message-destination-ref>
       <message-destination-ref-name>jms/LoanProcessingQueue</message-destination-ref-name><!-- ADD NEW DESTION IN THE FILE.-->
       <message-destination-type>javax.jms.Queue</message-destination-type>
       <message-destination-usage>ConsumesProduces</message-destination-usage>
       </message-destination-ref>
      </web-app>
      ,

      jboss-web.xml

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
      <jboss-web>
       <resource-ref>
       <res-ref-name>jms/ConnectionFactory</res-ref-name>
       <jndi-name>java:ConnectionFactory</jndi-name>
       </resource-ref>
      <message-destination-ref>
       <message-destination-ref-name>jms/LoanProcessingQueue</message-destination-ref-name>
       <jndi-name>queue/loanApprovalQueue</jndi-name>
       </message-destination-ref>
      </jboss-web>


      bpel-application

      <?xml version="1.0" encoding="UTF-8"?>
       <bpelApplication name="loanapproval" xmlns="http://jbpm.org/bpel"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://jbpm.org/bpel
       http://jbpm.org/bpel/bpel_application_1_0.xsd"
       <partnerLinks>
       <!-- HIER WE HAVE TO ASSIGN A QUEUE TO CLIENTS BY ASSIGNING QUEUE TO THE CLIENT PARTNERLINK WICH NAME IS THE LoanProcessing -->
      
       <partnerLink name="LoanProcessing">
       <!-- name bound to the queue assigned to this partner link -->
       <myRole destination="jms/LoanProcessingQueue" />
       </partnerLink>
       <!-- AT THE OTHER END OF THE LOANAPPROVALPROCESS WE NEED TO BIND THE LOANAPPROVER WEB-SERVICE BY GIVING BINDINGINFORMATIONS FOR THIS SERVICE -->
      
       <partnerLink name="Approving">
       <partnerRole>
       <wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
       <wsa:Address>USE_ACTUAL_URI_FROM_CATALOG</wsa:Address>
       <wsa:ServiceName xmlns:loanapprover="urn:samples:loanapprover">loanapprover:LoanApproverService</wsa:ServiceName>
       </wsa:EndpointReference>
       </partnerRole>
       </partnerLink>
       </partnerLinks>
      
       <serviceCatalogs>
       <definitionCatalog>
       <definition location="http://localhost:8080/loanapprover/loanApproverPortType?wsdl" />
       </definitionCatalog>
       </serviceCatalogs>
      </bpelApplication>


      jboss-client

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE jboss-client PUBLIC "-//JBoss//DTD Application Client 4.0//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-client_4_0.dtd">
      <jboss-client>
       <!-- JNDI name bound to client's environment context -->
       <jndi-name>loanapproval-client</jndi-name>
       <service-ref>
       <!-- The service-ref element to configure IS DEFINED IN APPLICATION-CLIENT:XML -->
       <service-ref-name>service/Loanapproval</service-ref-name>
       <wsdl-override>http://localhost:8080/loanapproval/LoanProcessing?wsdl</wsdl-override>
       </service-ref>
      </jboss-client>


      application-client.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <application-client version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd">
       <display-name>Loanapproval service client</display-name>
       <service-ref>
       <service-ref-name>service/Loanapproval</service-ref-name>
       <!-- service interface class -->
       <service-interface>org.jbpm.bpel.tutorial.loanapproval.LoanApprovalService</service-interface>
       <!-- placeholder for published WSDL file -->
       <wsdl-file>USE_JBOSS_CLIENT_XML_OVERRIDE</wsdl-file>
       <!-- Java<->XML mapping file -->
       <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
       <port-component-ref>
       <service-endpoint-interface>org.jbpm.bpel.tutorial.loanapproval.LoanProcessPortType</service-endpoint-interface>
       </port-component-ref>
       </service-ref>
      </application-client>


      application-clientx.xml

      <?xml version="1.0" encoding="UTF-8"?>
       <bpelDefinition location="loanapproval.bpel" xmlns="http://jbpm.org/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">
       <!-- makes WSDL interface elements available to the process -->
       <imports>
       <wsdl namespace="urn:samples:loanapproval" location="loanapproval.wsdl"/>
       </imports>
      </bpelDefinition>


        • 1. Re: Beginner: invoce web services from process: Hello, ATM,
          aguizar

          Wonderful! Thanks for sharing this with the community.

          Now I'd like to know if this can be added to the examples distributed with jBPM BPEL...

          • 2. Re: Beginner: invoce web services from process: Hello, ATM,

            Hi Alex,

            sorry because ot the wating time for my answer. So after consulting my tutors they is no and seems to be no problem because of copyright and so one ....

            If there is no restriction from activeBPEL using a modificated version of the loanRequest from my one side you have green ! and it will be nice to see that this example helps other new users understanding this new technologie.

            Best Regard


            Bertrand

            • 3. Re: Beginner: invoce web services from process: Hello, ATM,
              aguizar

              Bertrand,

              I appreciate your quick response. I'll check things out on my side.

              • 4. Re: Beginner: invoce web services from process: Hello, ATM,

                I am little bit confused about providing the endpoint for the external webservice. The userguide says -


                Note
                The endpoint address comes from the port element in the WSDL file, not from the URL in the catalog. To
                invoke a partner service, jBPM BPEL requires the full WSDL definition, not the endpoint URL alone.


                Does that mean the endpoint address comes from the actual live wsdl file /wsdl bundled in the project? Is there a way to override that setting and provide new endpoint address like this thread shows in bpel-application.xml? It will be nice to have that feature. I tried providing the 'wsa' addressing in my bpel-application file but JBPM didn't like it - I got following exception -

                17:45:19,183 ERROR [[/hello]] Exception sending context initialized event to lis
                tener instance of class org.jbpm.bpel.integration.server.IntegrationConfigurator
                
                org.jbpm.bpel.graph.exe.BpelFaultException: org.jbpm.bpel.graph.exe.FaultInstanc
                e@1f6a763[name={http://schemas.xmlsoap.org/ws/2004/03/business-process/}unsuppor
                tedReference,id=0]
                 at org.jbpm.bpel.endpointref.EndpointReference.readServiceRef(EndpointRe
                ference.java:85)
                 at org.jbpm.bpel.xml.AppDescriptorReader.readPartnerRole(AppDescriptorRe
                ader.java:192)
                 at org.jbpm.bpel.xml.AppDescriptorReader.readPartnerLink(AppDescriptorRe
                ader.java:169)
                 at org.jbpm.bpel.xml.AppDescriptorReader.readPartnerLinks(AppDescriptorR
                eader.java:150)
                 at org.jbpm.bpel.xml.AppDescriptorReader.readScope(AppDescriptorReader.j
                


                If someone can clarify this for me, it will be very useful.

                Thanks,
                Meghana

                • 5. Re: Beginner: invoce web services from process: Hello, ATM,

                  Can someone tell me if JBPM-BPEL supports wsa addressing like it shows here in this thread?

                  Where can I get schema for bpel-application.xml? 'http://jbpm.org/bpel/bpel_application_1_0.xsd' is not valid.

                  Thank you,
                  Meghana

                  • 6. Re: Beginner: invoce web services from process: Hello, ATM,
                    aguizar

                     

                    Does that mean the endpoint address comes from the actual live wsdl file /wsdl bundled in the project?

                    No. The /wsdl directory in the WAR is the location of WSDL documents for the process.

                    WSDL documents for partner services reside in external locations. The < urlCatalog > section of bpel-application.xml references those external locations. At runtime, when you < invoke > a partner service, jBPM reads the external WSDL documents and selects the first < service > having a < port > that implements the port type you specified in your < bpel:partnerLinkType > definition.

                    Alternatively, you can select a specific service yourself using a < wsa:EndpointReference > as shown above. You can find the schema document for bpel-application.xml in directory src/org/jbpm/bpel/xml/util.

                    • 7. Re: Beginner: invoce web services from process: Hello, ATM,
                      zazzaz

                      Hi,
                      I just want to set a new enpoint reference for a partnerlink.

                      Suppose I got from another web service.

                      Is it possible to set it to the partnerlink?

                      I saw examples in Active BPEL and I'm wondering if it is possible to do it with JBPM-bpel.

                      I'm using the version 1.1.3 beta.

                      Thank you! Bye

                      ZazzaZ