Friday, 30 October 2009

Converting WSDL 1.1 to WSDL 2.0

Share
When I had problems with Apache Woden's classes version mismatch (during deployment on Apache Axis2) I scanned 1.08M package and found out a package called: org.apache.woden.tool.converter. I instantly new what was its purpose :)

Today's post is a short post about converting WSDL 1.1 to WSDL 2.0 using Woden's Convert class.

Monday, 26 October 2009

Running WSDL 2.0 Web Service on Axis2

Share
Remember my previous post Preparing for SCDJWS Part 6: WSDL 2.0?
I created a sample WSDL 2.0 document which today I will show you how to deploy and run on Apache Axis2.

Creating simple Web Service

Using Maven2 create simple Java project. Then create HelloWorldWSDL2 class and copy and paste:
public class HelloWorldWSDL2 {
public String sayHello(String name) {
return "Hi " + name + "! How are you?";
}
}
Next in META-INF directory create Axis2 services.xml descriptor, copy and paste:
<service name="HelloWorldWSDL2" targetNamespace="http://wsdl2.ws.studies.xh.org">
<!-- this is the key property -->
<parameter name="useOriginalwsdl">true</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
<parameter name="ServiceClass" locked="xsd:false">
org.xh.studies.ws.wsdl2.HelloWorldWSDL2</parameter>
</service>
Then, still inside META-INF directory, create HelloWorldWSDL2.wsdl file and copy and paste:
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://wsdl2.ws.studies.xh.org" xmlns:tns="http://wsdl2.ws.studies.xh.org"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/ns/wsdl http://www.w3.org/2007/06/wsdl/wsdl20.xsd
http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
<types>
<xs:schema attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://wsdl2.ws.studies.xh.org"
xmlns:ns="http://wsdl2.ws.studies.xh.org">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<interface name="HelloWorldWSDL2Interface">
<operation name="sayHello" pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="tns:sayHello" wsaw:Action="urn:sayHello" />
<output messageLabel="Out" element="tns:sayHelloResponse"
wsaw:Action="urn:sayHelloResponse" />
</operation>
</interface>
<binding name="HelloWorldWSDL2SOAPBinding" interface="tns:HelloWorldWSDL2Interface"
type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.2"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:sayHello" wsoap:action="urn:sayHello" />
</binding>
<service name="HelloWorldWSDL2" interface="tns:HelloWorldWSDL2Interface">
<endpoint name="HelloWorldWSDL2SOAPBindingEndpoint" binding="tns:HelloWorldWSDL2SOAPBinding"
address="http://localhost:8181/ode/processes/HelloWorldWSDL2">
</endpoint>
</service>
</description>
Deploying on Apache Axis2

Remember my previous post Old school Apache Axis2 Web Services with Maven2?

I built my Web Service using Maven2 and copied it into $CATALINA_HOME/webapps/axis2/WEB-INF/services. There was an error:
14:44:34,033 INFO  [ServiceDeployer] The wsdl2-0.0.1-SNAPSHOT.aar service, which is not valid, caused java.lang.NoClassDefFoundError: org/apache/woden
/wsdl20/xml/DocumentableElement
at org.apache.axis2.deployment.repository.util.ArchiveReader.processWSDLs(ArchiveReader.java:322)
at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:64)
at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:137)
at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:571)
at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:141)
Using M2Eclipse's code completion I added the following Maven dependency to my pom.xml file:
<dependency>
<groupId>org.apache.woden</groupId>
<artifactId>woden-impl-dom</artifactId>
<version>1.0M8</version>
</dependency>
I rebuilt the aar package and tried to deploy it once again.

Nothing, still the same error. But after a second I realised that Woden's classes must be visible to the parent class loader.
So I copied manually woden-impl-dom-1.0M8.jar and woden-api-1.0M8.jar to Axis' WEB-INF/lib and restarted Axis2 application.

I got a new error:
Woden[Warning],0:0,Description-1001,The targetNamespace 'http://wsdl2.ws.studies.xh.org' is not dereferencable.
14:54:50,625 INFO [ServiceDeployer] The wsdl2-0.0.1-SNAPSHOT.aar service, which is not valid, caused java.lang.NoSuchMethodError: org.apache.woden.ws
dl20.xml.DescriptionElement.getNamespaces()Ljava/util/Map;
at org.apache.axis2.description.WSDL20ToAxisServiceBuilder.setup(WSDL20ToAxisServiceBuilder.java:392)
at org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder.populateAllServices(WSDL20ToAllAxisServicesBuilder.java:71)
at org.apache.axis2.deployment.repository.util.ArchiveReader.processWSDLFile(ArchiveReader.java:232)
at org.apache.axis2.deployment.repository.util.ArchiveReader.processWSDLs(ArchiveReader.java:332)
By looking at the stack trace I instantly spotted Woden's version mismatch. I went to Woden's home page and it turned out that 1.0M8 was the latest version.

I downloaded the second latest (at that time): woden-1.0-incubating-M7b (I downloaded it manually, it hadn't been added to Maven2 repository).

I copied woden-1.0-incubating-M7b.jar to Axis' WEB-INF/lib directory, removed both 1.0M8 jars, and again restarted Axis2.

I redeployed my WSDL 2.0 Web Service and this time saw no error.

Summary

I opened http://localhost:8181/axis2/services/listServices and saw my Web Service. I could also invoke it directly from my:
http://localhost:8181/ode/processes/HelloWorldWSDL2?name=Lukasz
Resulted in:
<ns:sayHelloResponse xmlns:ns="http://wsdl2.ws.studies.xh.org">
<ns:return>Hi Lukasz! How are you?</ns:return>
</ns:sayHelloResponse>
Now you know how to create WSDL 2.0 Web Services and how to deploy them on Apache Axis2.

Cheers,
Łukasz

Tuesday, 20 October 2009

Nuntius 0.4 released!

Share
Nuntius is designed to be a lightweight and efficient WS-BPEL broker. Nuntius' goal is to facilitate complex management of business processes and to provide means of quality and performance measurement of the aforesaid. Nuntius is a system which is meant to assist me in my PhD research.

You can use Nuntius to run your WS-BPEL processes completely for free. You can treat it as a free WS-BPEL engine provider.

It's available at: http://nuntius.eti.pg.gda.pl.

The features are:
  • remote deployment of WS-BPEL processes to embedded Apache ODE 1.3.3
  • enhancing WS-BPEL processes by performing XSLT transformations
  • Nuntius configuration allowing controlling the XSLT transformations
  • input, output, errors, and partial results logging
  • browsing partial results using Nuntius web console
Roadmap can be found at http://nuntius.eti.pg.gda.pl/docs/roadmap.jsf.

There is also a demo account which shows you some of the core features of Nuntius. The credentials are demo/nuntius. You can sign in to Nuntius Console here: http://nuntius.eti.pg.gda.pl/nuntius-console/.

Enjoy!
Łukasz

Monday, 19 October 2009

Preparing for SCDJWS Part 6: WSDL 2.0

Share
On many Java Forums many people are writing that they didn't have any question covering WSDL 2.0 during their exam. It might be true.
But remember that Sun expects you to know both WSDL 1.1 http://schemas.xmlsoap.org/wsdl/ and WSDL 2.0 http://www.w3.org/ns/wsdl.

Let's stick to it :)

Friday, 9 October 2009

DB2 Linux - Shared Memory Segments cannot be allocated

Share
Yesterday I had a real problem with connecting to DB2 database using DB2 CLP.

When I wanted to connect to database using the following command:
db2 => connect to lukasz1
I kept getting this errors:
SQL1084C - Shared Memory Segments cannot be allocated. SQLSTATE=57019
I did some googling but couldn't find the answer... after a longer while I finally found the solution.

Thursday, 8 October 2009

Preparing for SCDJWS Part 5: WSDL 1.1

Share
Section 3 of SCDJWS exam objectives covers "Web Services Describing and Publishing" (WSDL and UDDI respectively).

In general WSDL is used to describe a Web Service, its messages, interfaces, bindings, services, and endpoints.

Quoting from a Web Services Description Language spec:
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.
The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint.
Related concrete endpoints are combined into abstract endpoints (services).
WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate.
Today I will write a little bit about WSDL 1.1 and will show you how to manually prepare a WSDL file and use it in JAX-WS.

Monday, 5 October 2009

Wicked integration testing: Maven2 and Cargo

Share
Remember my last post about integration testing: Maven2 integration testing with failsafe and jetty plugins?

At the end of that post I wrote that if you wanted to be able to use different containers you should try Cargo.

I tried Cargo myself and it turned out that it is way better than jetty-maven-plugin :)

What to know why?

Friday, 2 October 2009

Maven2 integration testing with failsafe and jetty plugins

Share
Probably all of you know what does integration testing is. If not, there is a very nice definition of it on wikipedia:
Integration testing is the activity of software testing in which individual software modules are combined and tested as a group. It occurs after unit testing and before system testing. Integration testing takes as its input modules that have been unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to those aggregates, and delivers as its output the integrated system ready for system testing.
Today I will show you how to test Web Services using Maven2, failsafe-maven-plugin and maven-jetty-plugin.