« February 2006 | Main | April 2006 »
March 30, 2006
Operating at the XML Message Level in JAX-WS 2.0
Document-oriented communication with JAX-WS 2.0. Great...
I'm not sure yet how to deploy this, but we'll see..
Posted by Dominik Marks at 5:24 PM | Comments (0)
March 29, 2006
Changing interfaces with RPC and document-oriented style
I did some of the tests mentioned in an earlier weblog entry (The other way round...).
A simple Web service was created and tested successfully. Then the interface of the server part was changed a bit without changing the client. Here is what happened:
Document-oriented style | RPC style | |
---|---|---|
Adding a parameter | No problems | Exception thrown |
Changing parameter order | No problems (w/ XPath) Semantics changed (w/o XPath) |
Semantics changed (same datatypes) Exception thrown (diff. datatypes) |
Deleting a parameter | No problems | Exception thrown |
Changing parameter data types | No problems (datatypes convertable) Exception thrown (not convertable) |
Exception thrown |
Changing return type | No problems (datatypes convertable) Exception thrown (not convertable) |
Exception thrown Semantic changed (null value for void type) |
Adding a new method | No problems | No problems |
Renaming a method | Not applicable | Exception thrown |
What can be tested else?
BTW, here is the sample code used for RPC and document-oriented communication (basis version, without the changes described above):
Download file
Posted by Dominik Marks at 7:35 PM | Comments (15)
March 24, 2006
Microsoft on loosely coupled Web services
Found a very interesting movie from "MSDN TV" that shows how a service can be developed further (and change the interface) and nevertheless use the old client to communicate with it.
It is called MSDN TV: Loosely Coupled Web Services.
Posted by Dominik Marks at 6:51 PM | Comments (1)
March 22, 2006
SAAJ 1.3
To create document-oriented communication between Web services I tried to use SAAJ today.
Therefore I downloaded the new Java WSDP 2.0 package that contains SAAJ version 1.3. The really interesting part of SAAJ 1.3 is that javax.soap.xml.SOAPElement
now implements org.w3c.dom.Element
. There is no more need to use difficult transformations to use XPath and things like that.
So the problem described earlier in this blog about Converting SOAP to XML is solved.
Sample code extract:
//Send message and get reply |
Posted by Dominik Marks at 8:58 PM | Comments (849)
March 21, 2006
Eclipse Web Tools Platform
I installed and tested the Eclipse Web Tools Platform to create a HelloWorld (RPC-style) Web service. It's quite easy. You just have to provide a simple Java class and the plugin generates everything for you: The server, the WSDL, the client, a JSP-page to test the Web service and a TCP/IP-Monitor to see the exchanged SOAP messages.
I have to figure out how to use this plugin to create document-oriented Web services...
Posted by Dominik Marks at 5:14 PM | Comments (2)
March 15, 2006
Document-based Web services
I found an interesting article about Patterns and Strategies for Building Document-Based Web Services at the Sun Developer Network.
Most of the shown concepts look very RPC-stylish to me. Stubs and Ties are generated and I don't see any XML parsing in the source code.
The only interesting part I found is to use the xsd:any element in the WSDL description. But how and where is the XML Schema for the XML documents that are exchanged then?
Posted by Dominik Marks at 6:01 PM | Comments (10768)
March 10, 2006
The other way round...
I was able to reproduce the main problem of RPC concering loose coupling (see Reproduction of main problem with RPC).
Now I tried it the other way round, i.e. using JAXM. JAXM is used to access, create and process the SOAP messages directly. The same Hello World sample was developed using JAXM. It took a litte bit longer, because the messages must be created and parsed by hand.
The lucky result is:
Adding another parameter that caused the problems with JAX-RPC did not make any problems, the application runs perfectly with this changed interface.
It must be examined which changes cause problems with JAX-RPC and which cause problems with JAXM. These may be (incomplete list):
- Adding parameters
- Changing parameter sequence
- Deleting parameters (important / optional ones)
- Changing datatypes
- Changing result values / datatypes
- Adding / deleting methods
- Renaming methods
Posted by Dominik Marks at 11:48 AM | Comments (3)
March 9, 2006
Java 5, XPath and independent namespace declarations
Easy use of XPath expression with XML documents seems to be new in Java 5 (see
XML Validation and XPath Evaluation in J2SE 5.0).
Playing around with javax.xml.xpath.XPath
led me to setNamespaceContext
that enables you to provide an independent mapping of namespace prefixes to namespace URIs.
Sample XML-File:
<abc:root xmlns:abc="http://www.abc.com"> |
By typing
nsCtxImpl.setNamespaceURI("xyz","http://www.abc.com");
you can use the XPath-Expression "/xyz:root/xyz:element"
instead of abc
. As long as the namespace URI stays the same the prefix may be changed to anything by this...
Posted by Dominik Marks at 5:41 PM | Comments (0)
Converting SOAP to XML
At a first view there is no difficult to convert a SOAP message into an XML document (to be used as a org.w3c.dom.Document) as a SOAP message is an XML document. But how to tell this JAVA?
First approach:
org.w3c.dom.Document doc = (org.w3c.dom.Document)soapMessage;
This doesn't work (ClassCastException)
The only way I found is to do the following:
Use soapMessage.writeTo(Stream)
to write this to a Byte Array stream and then read the stream again with a DocumentBuilder to create a org.w3c.dom.Document.
Isn't there an easier way?
Posted by Dominik Marks at 5:33 PM | Comments (2)
March 6, 2006
Reproduction of main problem with RPC
I installed Systinet Developer 6.0 Plugin for Eclipse. Installation is quite easy (note: just copy files to Eclipse directory, don't use Update Manager. This won't work).
Using the provided tutorial I developed a simple HelloWorld Web service. A Client using this service can be generated automatically. It took about 20 minutes to do this all, i.e. RPC-style Web service development with a plugin is quite easy.
Then I was able to reproduce the main problem of RPC-style communication:
I changed the server method from public String getMessage()
to public String getMessage(String option)
. I redeployed the classes but did not re-generate the client. This is what I got:
Exception in thread "main" java.lang.NullPointerException
at org.idoox.wasp.wsdl.SOAPMethodInfo._setSchemaElement(SOAPMethodInfo.java:376)
at org.idoox.wasp.wsdl.SOAPMethodInfo._setPart(SOAPMethodInfo.java:364)
at org.idoox.wasp.wsdl.SOAPMethodInfo.setCorrectSchema(SOAPMethodInfo.java:351)
at com.systinet.wasp.client.ClientProxy._invoke(ClientProxy.java:327)
at com.systinet.wasp.client.ClientProxy.invoke(ClientProxy.java:109)
at $Proxy63.getMessage(Unknown Source)
at hello.HelloWorldClient.main(HelloWorldClient.java:29)
Posted by Dominik Marks at 9:48 AM | Comments (1)
March 2, 2006
Searching for red thread...
I'm going to use those two concepts to use document-oriented communication between web service "the easy way":
- Being able to check XPath expressions at compile time (use XPath to access specific SOAP nodes)
- Being able to be more flexible which methods and attributes to expose/to use using Java 5 annotations
Now I'm trying to combine those two concepts to have a "red thread" for my thesis. This is what I thought of (just brainstorming, I'm not sure if it will work like this):
- Use Java 5 annotations to map method attributes to XPath expressions.
- Then proove if these XPath expressions are correct using the first concept.
I know this is a very early stage of my thesis, but having a "red thread" would be very helpful.
Posted by Dominik Marks at 1:06 PM | Comments (0)
March 1, 2006
Apache Axis Installation
Installation of Apache Axis has some caveats:
- Install to a directory without spaces in the name!
- Add Libraries: commons-discovery-0.2.jar, commons-logging-1.0.4.jar, tools.jar
- Add activation.jar, mail.jar and xmlsec-1.3.0.jar to common\lib of Tomcat Webserver
- Add wsdl4j-1.5.1.jar to AXISCLASSPATH
This is not documented in the documentation.
Posted by Dominik Marks at 1:07 PM | Comments (0)
Master thesis, day 1
I started writing my master thesis today.
The topic is "Concepts for loose coupling in service-oriented architectures with special web services / XML proxy modifications". I did some research and I think this is a very interesting topic.
Short summary of planned content:
- What are web services, technologies used, connection to Java (JAX-RPC)
- What is loose coupling, description using table from (Carlos Perez: Principles of Loosely Coupled APIs).
- Why JAX-RPC is not really loosely coupled (unusable stubs if interfaces are changed) and what to use else (conversational style)
- How to use conversational style and how to make it more easy to use this way
- Two main concepts:
- Being able to check XPath expressions at compile time (use XPath to access specific SOAP nodes)
- Being able to be more flexible which methods and attributes to expose/to use using Java 5 annotations
Posted by Dominik Marks at 9:04 AM | Comments (11)