[jboss-user] [JBoss jBPM] - Beginner: invoce web services from process: Hello, ATM, Loa
bertrand.njiipwo
do-not-reply at jboss.com
Mon Sep 4 07:25:02 EDT 2006
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>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969206#3969206
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969206
More information about the jboss-user
mailing list