Professional Documents
Culture Documents
X Example Tutorial
This Document is intended to guide the user through the practical steps necessary to build Web Services with TIBCO BusinessWorks 5.X. This document contains sample code and an example project, and is not intended for production use.
Building a Document/Literal Web Service with TIBCO BusinessWorks 5.X Version 1.0
TIBCO Software Inc. http://www.tibco.com 3303 Hillview Avenue Palo Alto, CA 94304 1-800-420-8450
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
Table of Contents
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
3
A TIBCO Web Services Tutorial
The diagram above is the schematic for this example. There are two BusinessWorks Process Engines, one that exposes an HTTP Receiver and performs a SOAP Request/Reply to the second engine, which is the SOAP Server that encapsulates the actual service. This second engine is comprised of a SOAPEventSource, a Java Code Task, and a SOAPSendReply. The HTML Client POSTs three elements the principle, the interest rate, and the number of months for the loan. The WebService does the calculation and returns the monthly loan payment. To simplify matters, I will omit the HTML and Browser aspects of the example.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
4
A TIBCO Web Services Tutorial
Start by opening up the WSDLs Folder, and accessing the XML Tools Palette. Drag & Drop a Schema Object into the folder. As shown below, I have named this schema loanpayWS.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
5
A TIBCO Web Services Tutorial
In BusinessWorks 5.X, targetNamespace is entered under the Configuration Tab as shown below:
Double-click on the Schema Icon, and you will see a spreadsheet-like interface with which to build your XSD. Note that the Input Element has as its contents the other elements used in the SOAP client.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
6
Here is the source of this XSD: A TIBCO Web Services Tutorial
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
7
A TIBCO Web Services Tutorial
1. 2. 3. 4. 5.
Click the Plus sign to add a Part to the Part Table Name the Part inputString Choose Element Pick the Binoculars to browse the resources and pick the schema in Part Details Navigate to the XSD, and highlight the element input, click O.K. then Apply.
For the Output message, perform the same process, but in the XSD, choose the element answertext. Next, double-click on the PortType, and Drag & Drop an Operation Ive called this one OperationOne. In a similar fashion to assignment of the messages, you will use the process to add an input type, an output type, and an optional fault type to the Message Table, and then associate each kind with the specific type of message you just built earlier.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
8
A TIBCO Web Services Tutorial
Here you see that Ive created an input type for the Message Table that is associated with the inputMessage that we created for this WSDL. Repeat for the output type.
Now we are done with our Abstract WSDL creation! We will use this WSDL to create the Service, and with the addition of some communication specifics, we can derive the Concrete WSDL for our Client. Here is the WSDL Source:
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
9
A TIBCO Web Services Tutorial
Open the WebServiceProcessDefs Folder (or whatever you called it), and Drag & Drop a Process Definition Object into the folder, and name it WebSvcDocLitLoanPay. Next, Drag & Drop a SOAP Event Source, Java Code Activity, and SOAP SendReply Activities, and connect them as shown. Label them appropriately. We will need to go back to the project view and create a single HTTP Connection in the Communications Folder you created earlier this configuration is as simple as picking a Port number that is not in use, I used Port 88. Configure the SOAPEventSource by using the two binoculars on the Configuration Tab, and choosing the namespace and Port Type of the Abstract WSDL we just created, and check that it has both an Input and an Output. The second binocular will let you browse the Transport, and you will pick the HTTP Connection you just configured.
Configure the SOAP SendReply by simply taking the default, which is to [Reply To: SOAPEventSource].
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
10
A TIBCO Web Services Tutorial
Open the Code Tab, and you will see two radio buttons Invoke Method Body and Full Class. Using the Invoke Method Body format, cut and paste the following java code below the comment lines: float PRIN = Float.parseFloat(prin); float INTEREST = Float.parseFloat(interest); int MONTHS = Integer.parseInt(months); double FIRST = Math.pow((1+INTEREST/1200),(-MONTHS)); float PART = (float)FIRST; float PAYMENT = PRIN/((1-PART)/(INTEREST/1200)); /* answertext is the answer */ answertext = (String.valueOf(PAYMENT));
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
11
A TIBCO Web Services Tutorial
With your code successfully compiled, you need to do some very simple mapping to associate the SOAP Event Source with the Java Code Activity. Move to the Input Tab, and expand both sides to expose the elements, and drag & drop as shown below:
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
12
A TIBCO Web Services Tutorial
Andwe are finished with the Web Service! Now, on to the Client
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
13
A TIBCO Web Services Tutorial
SOAP Client
By taking the schema and building an Abstract WSDL, we set the foundation for a Web Service by the addition of adding a Transport for Binding to the PortType. The result is a service with a port, and then you have a Concrete WSDL. By opening the WSDL Source Tab, you expose the Concrete WSDL. Highlight the Text and cut/paste into your favorite text editor and save. Next, go to Project Import Resources from File, Folder, URL Import the WSDL you just saved into the WSDLs Folder. Ive called it DocLitConc. Alternately, you can drag & drop a new WSDL object, click the source button in the tool bar and then paste/apply/save.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
14
A TIBCO Web Services Tutorial
The configuration is straightforward, with explicit values for: resourcePath filter hostname port
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
15
A TIBCO Web Services Tutorial
The mapping in the HTTP Response is simple dont forget to put in text/xml as the Content-Type. You can run both the Web Service and the Retrieve Resource processes, and then retrieve the Concrete WSDL from a browser to test that it works
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
16
A TIBCO Web Services Tutorial
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
17
A TIBCO Web Services Tutorial
The configuration steps are simple you follow the same steps as you did when configuring the SOAPEventSource, but this time, you pick the Concrete WSDL rather than the Abstract one! The screen shot should look like this:
If you arent using a Browser, I find it useful to create input via the Output Editor in the Start Activity, and then mapping it appropriately to the inputs of the SOAPRequestReply.
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
18
A TIBCO Web Services Tutorial
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary
19
A TIBCO Web Services Tutorial
You pick the Operation in for the SOAPEventSource, like before, but now you have a choice:
Doclit.zip
2002 TIBCO Software Inc. All Rights Reserved. TIBCO Confidential and Proprietary