By James Taylor on Nov 12, 2014
This blog post is really for my reference as I started playing with OSB 12.1.3 this week and noticed there is some tooling changes, especially in regards to xquery. I had a few issues trying to run my OSB when I used xquery. This may have been a red herring as there are other changes in 12.1.3 that I needed to come to grips with, i.e. splitting pipelines proxy services and the addition of adapters and transports in the one component pallet. This blog post steps through the procedures I used to implement a simple OSB service with a Webservice Proxy Service and a DB Adapter business service. I will call out what I initially tried and failed so you don't make the same mistakes.
- Firstly, create an OSB Application, your choice if you choose with OSB project or not.
- Create or use the OSB project created in step 1 and open up the composite overview.
- Right-Click the External Services swim lane and select Insert Adapters... -> Database. Configure the DB as you always have in SOA. As an optional extra you can deploy now to test that your business service works.
- Up until now there are no real issues, the tooling feels very similar to SOA Suite. The creation of the proxy service was slightly different to my experience in SOA Suite. When I develop an Exposed service in SOA Suite I create the service then link it to mediator, or BPEL, etc. I followed the same process in OSB and created the Proxy service before the pipeline and I think I ran into my first issue. What I do now is create a Pipeline first and configure the proxy service at the same time.
Before we can create a proxy service or pipe line we need to have an xsd to be used as the base for the Proxy service.
- Drag a pipeline from the component pallet to the pipeline / split-join swimlane, and give a name for the pipeline.
- Click the create WSDL icon
- The WSDL configuration is very similar to what you do in SOA Suite. I have provided a screen shot of mine. I have 1 xsd called product.xsd, and it has the request and response elements in that file.
- The pipeline config should look like this. In my initial development that did not work I chose ws for webservice. I'm unsure if this gave me issues down the track but I would keep the transport set to http.
- Before I start to connect the pipeline to the business service I want to create the xQueries that will transform the Proxy service request and the the DB select.
Right-click a folder (I created an xquery folder) in the OSB Project and select XQuery File 1.0 (you will notice that OSB 12.1.3 does not support XQuery 2004 a design time, only run time. Therefore if you need to edit upgraded 11g OSB projects with XQuery you need to do this manually)
- The creation of xQueries looks different from 11g. Don't stress if you follow these steps you will soon be in the comfort of mapping source and target schemas as we did in 11g in just a few quick steps.
Name the xQuery, I also name the function the same a the xQuery
- Click the plus sign to add a source schema. At first impression it looks like everything is greyed out and nothing working. This is not the case, specify a name and click the the pencil to for sequence to specify the source schema.
- Once again the screen looks like nothing is enabled, this is expected. Click on the Schema Object Reference icon to select the schema
- When I first attempted creating my first xQuery I selected the xsd under the Application Schema Files folder, as this is what you do in a SOA composite. Then I remembered in OSB 11g you select the WSDL. The issue here is that there are 2 folders presented here. Select the element under the Imported Schema as presented below.
I did try the element under the blank folder, but when I did this the xQuery map would not draw. Therefore if you have WSDLs as the source and target select the Imported Schemas. I have not tried this for WSDLs with the schema inline within the WSDL, you may have to select another folder.
- Your completed parameter should look something like this.
- The parameter should look like this
- Do the same for the target and repeat steps 12 - 15. In my instance I used a DB adapter, this creates the WSDL in the resources folder, it also provide a concrete WSDL. When I choose the target I choose the actual WSDL as the screenshot below shows.
- You have now completed the configuration of the xQuery, it should look something like this.
- Now its just a matter of mapping from source to target. I'm not going to go into details here as all mappings are different.
- In this example I have a synchronous webservice, I have mapped the request, but now need to map the response. Create a response xQuery using the steps 9 - 18.
- The final step is to configure the pipeline to route to the business service and assign all the variables.
Open the pipeline and add a pipeline pair under the Proxy service.
- In the Request Pipeline in Stage 1 add and Assign, and under that add a Replace, Do the same for the Response Pipeline. You will notice some red markers, these just mean that the actions have not been configured. We will do that in the following steps.
- Click on the Assign for the Request Pipeline and in the properties panel change the expression to a xQuery Resource.
- Choose the xQuery and assign the binding. It should look something like this.
- Now provide a variable that holds the mapped output, in my instance I created it as requestVar.
- In the Replace under the Assign and enter the values as per below. It may be difficult to see but there is a '.' under the location text box.
- Do the same for the Response Pipeline.
- The last step in the process is to route the business service. Under the Pipeline add a routing action and select the business service created in step 1.
- Save your project, you can now deploy your OSB and test. If testing in the service bus console make sure you test with the pipeline, not the proxy service. Testing the proxy service you see all the assigns and service calls as you got in 11g. Also introduced in 12C is the debugger in JDeveloper. You can set break points so you can step through the process for greater analysis of your code.