Tuesday, November 27, 2007

Have-A-Patent : Improvements to Use Case Modelling

The thing about patent applications is that they take so long to process that you tend to forget about them until you find out they have been granted. I just found out that a patent application I put in when I was working on the use case modeler has been granted.

Right back to preparing for UKOUG'07.

Thursday, November 22, 2007

Yikes, Leopard took my account away

I just got around to upgrading my main mac to OS X 10.5; but rather strangely I found that my user account when missing after the first attempt a logging in. Took me a while to fix the problem; but in the end tracked it down to this little treat. Looks like if you have just upgraded since the original version of OS X there is a sting in the tail if you had a nice long secure password. Oh well fixed now.

Thursday, November 15, 2007

XmlAdapter, or what you are looking for it you are missing custom serializers from JAX-RPC

JAX-B 2.0 has a nice little pattern to deal with hard to serialize types. Rather than forcing the user to create xml elements you instead just have to convert your java object into another set of java objects it does know how to persist. There is a clear example of using XmlAdapter here on java.net.

The importance of good certificates and sensible names

I was looking at the latest beta of SOAP UI today and decided to try the web start version to have a play with a few of the features. I dutifully accepted the first cert which was without a root key but appears to be from eviware who write this software.....

... but my nerve failed when I saw this certificate:

I am sure just downloading the software is about as secure; but it did remind me of the importance of using sensible names when you are trying to get somebody to trust you.

Update: A friend gave me a explanation for this rather strange certificate. It comes with this crypto library.

Wednesday, November 14, 2007

Changing the endpoint location for a JAX-WS SE Client

Some things JAX-WS makes easy; but other things are not so obvious. One of the quite common issues that confuses developer new to this area is how you change the endpoint location for a web service proxy/client without having to regenerate/recompile the code.

It turns out you have to make use of one of those maps I enumerated in my previous entry and your code needs to looks something like this:

 1  import java.net.URI;

 2  import java.net.URL;
 3  
 4  import java.util.Map;

 5  
 6  import javax.xml.ws.BindingProvider;
 7  import javax.xml.ws.WebServiceRef;

 8  
 9  import project2.proxy.Hello;
10  import project2.proxy.HelloService;
16  

17  public class HelloPortClient
18  {
19    @WebServiceRef
20    private static HelloService helloService;

21  
22    public static void main(String [] args)

23    {
24      helloService = new HelloService();
25      Hello hello = helloService.getHelloPort();

26      setEndpointAddress(hello, "http://some.new.addr/endpoint");
27   
28      hello.sayHello("Bob");

29    }
30   
31   
32   
33    public static void setEndpointAddress(Object port, String newAddress) {

34        assert port instanceof BindingProvider : "Doesn't appear to be a valid port";
35        assert newAddress !=null :"Doesn't appear to be a valid address";

36   
37        //
38   
39        BindingProvider bp = (BindingProvider)port;

40        Map<String, Object> context = bp.getRequestContext();

41        Object oldAddress = context.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);

42        context.put(
43          BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
44          newAddress);

45    }
46  }

Note that I extracted the relevant code into a separate method, this you would probably want to move to some kind of utility class. For some reason there isn't a nice helper method to do this that comes with JAX-WS; but hopefully they will fix this in a future revision.

Update: As noted by Kurt in the comments you will probably need to have a local copy of the WSDL in order for this to work properly. Most tools will have an option to help you do this.

Update 22nd Dec 2008: After considering the problem in the real world a little bit more in the cases where you might have policies defined I now consider it better to alter the WSDL location rather than just the endpoint. This means that any extra policies on the new server are read and processed. You could do this using web.xml or a jax-ws catalog file, both can be updated at deploy time with a deployment plan.

Tuesday, November 13, 2007

An alternative JDK 6 for OS X

Some bods have been working at porting over the FreeBSD version of JDK 1.6 to OS X. As you might expect it usees X11 rather than native swing bindings; but that is sufficient for a lot of service side stuff. Hello I spend a lot of my day running X11 apps anyhow. Also of interest is that they have this running on 10.4 and 10.5 which the apple version of the JDK certainly wont.

Take a look at Landon Fuller's site for more information. A bit more to do on hotsport stability; but this is a valuable resource when you just gotta have the latest and greatest JDK on your mac.