Java SE 6: Mustang and WS-TMI



Did you know that Java SE 6, Mustang, features a subset of the Java EE Web Services stack ?

I've been tinkering with it, check it: Its JAX-WS (JSR 224) with a helping of JAXB (JSR 222) for its data binding, a good dollop of WS Metadata Annotations (JSR 181), with a sprinkling of a few of its own. Of course you've already teased a coulis of XML strained with WSDL in a JAX-RPC boullion with sun-dried MTOM/XOP and hand-crushed swaRef...

Yawn, W H A T E V E R . Too much information. Way.

Let's try it this way around....you have a neat little program, see ? It does something cute like adding a couple of numbers, which is self-evidently your market-dominating online service in thin disguise:

public class NumberAdderUpperer {

   public int addNumbers(int number1, int number2) {
        return number1 + number2;
    }
}


And naturally, you know you want to tell all your friends to use it, so in Mustang, they made it so you can do this:

import javax.jws.WebService;

@WebService
public class NumberAdderUpperer {

   public int addEmUp(int number1, int number2) {
        return number1 + number2;
    }

}


OK, so now you'd hit deploy in your IDE of course and stick it on the corporate app server, tell the world, and be done. But for the slightly more cautious amongst you, let's you and I do it with nothing more than the Mustang SDK, which has its own mini-Http server just for things like this:-

      import javax.xml.ws.Endpoint;
            ... 
        Endpoint.publish("http://localhost:8080/ws-tmi/adderupperer", new NumberAdderUpperer ());


Oops ! And now your new number adding service is published at:  "http://<hostname>:8080/ws-tmi/adderupperer".

Could it BE any easier ? (actually, maybe you think it could - let me know....)

And I did mention that adding numbers is an incognito book ordering or drug prescription authorisation service, and your soi-disant friends unmasked: they're your customers or patients, right ?

Ya, two imports and an annotation: that's the kind of simplicity I can go for.



Comments:

I tried this out, but immediately got an error like the following: Exception in thread "main" Server Runtime Error: class: org.nsdev.test.jaxws.Add could not be found at com.sun.xml.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:189) at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:65) at com.sun.xml.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:57) at javax.xml.ws.Endpoint.publish(Endpoint.java:156) at org.nsdev.test.Main.main(Main.java:12) I guess in can be a little easier. And ideas?

Posted by Neal Sanche on February 28, 2006 at 02:15 AM PST #

Hey, if you add the annotation: @SOAPBinding(style=SOAPBinding.Style.RPC) to the web service class, it seems to work fine after that.

Posted by Neal Sanche on February 28, 2006 at 06:52 AM PST #

Hi! Thanks for showing how publication works in Mustang. I really think this is way cool. But, a question: is the "ws-tmi" part of the URL mandatory, or can I use any URL I wish? Mats

Posted by Mats Henricson on March 29, 2006 at 05:32 AM PST #

Very cool! Thanks for this!

Posted by Simon Brocklehurst on April 05, 2006 at 01:08 AM PDT #

Is doing the same thing with RMI this simple? If not, why?

Posted by Curt Cox on June 16, 2006 at 03:02 AM PDT #

Danny, My application connects to .Net web services. The way I do it is first I generate stubs using wsimport and then use those in my application to invoke the web services. Before I look into the new additions to mustang can you tell me if those new additions will make it any easier for me ? Thanks in advance! -Navin

Posted by Navin on June 20, 2006 at 12:21 AM PDT #

Hi Curt, I think we're finding there are more developers interested in using web service protocols nowadays than the older RMI protocols. So we focussed effort on make that part easy.

Posted by Danny Coward on June 21, 2006 at 07:42 AM PDT #

Hi, this is too cool. No need to generate mappings configs using wscompile. But doesnt look like thread safe. Also is there a way to deploy this in App server and specify a transaction scope. or should we go back to J2EE webservices for this.

Posted by Sathish on June 26, 2006 at 05:16 PM PDT #

What happens when you want to use more than just primitive types? I wrote another way, that I think is just as intuitive, but much more flexible, and it works with JREs 1.3 and higher. Adoption of successive JREs is becoming exponentially more difficult. Tying your designs to 1.6 would be a significantly limiting proposition. Though 1.6 is a lot of fun to for geeks play with! :-)

Posted by John Catherino on June 29, 2006 at 03:28 AM PDT #

Danny, looks amazingly simple from the service provider's point of view. Any changes to SOA invocation making it easier?

Posted by Ethan Giordano on July 17, 2006 at 12:07 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

dannycoward

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today