Implementing a Petals Service with JAX-WS (WSDL first)

Summary

This tutorial explains how you can implement a Petals service with an annotated Java class, with a top-down approach.
Unlike services that are only configured or proxyfied in Petals, such a service is literally executed in the bus.
The approach presented here aims at creating a Java implementation from a WSDL definition.


Technically, this tutorial shows the creation of a service-unit for the Petals-SE-Jsr181 component in provides mode.

Level: Easy
Estimated time: 10 minutes
Expected skills: develop in Java

Creating the Service-Unit project

Getting started

Start Petals Studio.
In the menu, select File > New > Petals Service Provider.
If you do not see it, go into File > New > Other... Then, select Petals Service Provider under the Petals category.


A wizard opens up, showing three drop-down lists.
In the Use Case list, select Manual Implementation.
In the Petals Component list, select Jsr-181 // petals-se-jsr181.
In the Component Version list, select the version of the Petals-SE-Jsr181 that you are using in Petals.


In the scope of this tutorial, we are going to work with the version 1.2 of the Jsr181 component.
Which gives us:


Click Next.

Defining the project name

This page defines the name and the location of the project that will be created.
Indeed, this wizard will result in the creation of a project containing all the required elements for a Jsr181 service-unit.


Enter a project name for your project.
If you do not want your project to be created in the default workspace, uncheck Use default location.
Then click Browse... and select the location where the project will be created.


Petals service-units have a naming convention.
For a service-unit which provides a service, the convention is su-<Protocol or Technology>-<Service name>-provide


Then, click Next.

Specifying the creation mode

With the Jsr181 tooling, there are two approaches: a top-down one and a bottom-up one.
Since we want to start from a WSDL, we will choose the top-down one.
Select the radio button Start with a WSDL definition and provide the URL of the WSDL definition.
If it is stored on the local file disk, you can click Browse... to select it with a file dialog.



Click Finish to complete the wizard.

Checking the result

When the wizard has completed, a new project has been created and is visible in your workspace.

It contains a jbi.xml file, located under src/main/jbi.
This hierarchy allows you to work with Apache Maven then (a pom.xml was also created at the root of the project).
In the same directory, you can see the WSDL interface you provided in the wizard. It was imported with all its dependencies (e.g. referenced XML schemas or other WSDL interfaces).
And there are annotated Java classes that were generated from the WSDL.


Updating, packaging and deploying

Further edition and packaging

After completion, the service implementation has been open in the Java editor.
Complete the method implementations (it is basic Java development).


Then, you can directly package the project.
The generated jbi.xml was already complete.
However, it is possible (but not required) to update the WSDL and create a new complete jbi.xml.
To do that, right-click the project and select Petals > Generate WSDL(s).



A dialog appears to ask you whether a new jbi.xml should be generated too.
Clicking No only generates WSDL definitions from the classes that are annotated with @WebService.
Clicking Yes will in addition generate a new jbi.xml.


Be careful, all the WSDL definitions of the jbi directory will be deleted.
And take note that the new jbi.xml will erase the previous one, thus loosing hand-made modifications.


The created project being a Service-Unit project, you can package it as any Service-Unit project.
It results in the creation of a Service Assembly for the Petals-SE-Jsr181 component. Its location depends on your export choices.

Deployment

The deployment of the created service assembly can be achieved with the Petals web console.
Or you can do it by dropping the service assembly in the install directory of your Petals installation.
This second option should only be used in development steps.


First, make sure the Petals-SE-Jsr181 is installed in your Petals environment.
Then, install the service assembly in your Petals, using one of the two ways indicated above.


There is no need to update configuration of the Jsr181 component to make it work.
Using the default settings is enough to make the service-unit work.

Labels

petals petals Delete
tutorial tutorial Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.