The glue between the two is WS-Addressing. This standard enables the client to put in a little piece of xml in the request-message with information on:
- the address of the endpoint to call to deliver the response message
- the message id to correlate the response message to the request message
To read more you can find a tutorial on OTN. However, unfortunately the pictures don't correspond to the text, so I found it a bit hard to read. Therefor I made a HelloWorld setup myself. I might extend it in next blogs, if my further experiences are worthy to share (and time let me).
Create a Asynchronous BPEL Process
First, let us create a HelloWorld project. For those that are new to SOASuite 11g: in JDeveloper create a SOAApplication with a SOAProject based on a BPEL process:Then name the BPEL process HelloWorld and make sure you base it on the asynchronous BPEL process template.
Then add an assign, drag the Expression Builder Icon (most left "fx" icon in the row of icons top right) on the result node of the output variable. Then add the line
concat("Hello ", bpws:getVariableData('inputVariable','payload','/client:process/client:input'))
to the expression:
then the Assign will look like:
resulting in the following bpel process.
This process can be deployed and run on enterprise manager resulting in the following audit-trail with request message.
Now start SoapUI and create a new project based on the wsdl of the deployed bpel process:
This creates a request message that can be used. to call the BPEL process:
Create a SoapUI Project
As I explained above, the client (our SoapUI setup) will call the BPEL process, and as a result the BPEL process will call back our SoapUI client. This means that we need to create a Test Suite with a Test case with two steps:
- Test Request
- Mock Service
Create a Test Request
So, in SoapUI create a 'Test Suite' with a 'Test Case' in it. Then the request created/generated above can be dragged and dropped into the Test Case. That will create a initiating Test Request:Create a Mock response
Now, at this point, you'll need the host name or ip-address of your SoapUI running computer. If your SoaSuite is running on the same machine as SoapUI then you could use localhost. But if it is on another server (being the host of your development or test environment) than localhost won't do of course. Since most development machines use DHCP to get an ip-address automatically this might change. So get the host name of your machine at the System Properties:(I obfuscated/blurred my hostname since it is a machine at my customer in this example).
With this name you can add a Mock Response step to the testcase:
This will ask you to set the operation to mock. Make sure to set the interface to the HelloWorldCallBackBinding, and the operation to processResponse.
In the port set a free listen port, for example 8989, and the path to "/HelloWorldCallbackBinding/processResponse":
(first set the interface, then the operation above will automatically set to the only one in that interface/binding).
For the path I choose to concatenate the binding-name with the operation-name from the WSDL. These two entries are important since they will make-up the end-point that is mentioned to the BPEL process in the WS-Addressing node as the address it should call to send the response back.
Edit the WS-Addressing properties of the Test Request
Now it's time to edit the WS-Addressing properties of the Test Request. So open the test request step editor. Then click on the WS-Adressing tab at the bottom of the request message:Now you'll see the following tab/panel:
In this tab (see above) edit the following properties:
- Check the "Enable/Disable WS-A addressing" check box
- Set the poplist "Must Understand" to true
- Check the "Add default WS-A:action" check box
- In the Reply to field put in the addres:
http://<name of your SoapUI client host>:8989/HelloWorldCallbackBinding/processResponse
Test the Test Case
Now this is in fact al there is to do to get it working. You run the test case and the response message will appear in the response pane of the Mock Response test step:Conclusion
As simple as that. Now you can expand your test with assertions and adhoc interactions with your BPEL process or call another with the output of this one. Also it might be handy to use the scripts in my former blogs to write the response to a file in a folder on the file system.But how would the message adapted with the WS-Addressing node look like? Well that can be investigated using the HTTP Analyser in JDeveloper. Let me demo that in a next blog.
No comments :
Post a Comment