Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« Previous day (Aug 16, 2007) | Main | Next day (Aug 18, 2007) »

http://blogs.sun.com/arungupta/date/20070817 Friday August 17, 2007

Getting Started with Ruby-on-Rails, GlassFish and NetBeans

Here are few pointers to get you started on Ruby-on-Rails in GlassFish and NetBeans:

Technorati: ruby jruby glassfish netbeans rubyonrails ror

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

TOTD #2: Change the endpoint address on a pre-generated Web services Stub

The client-side stubs generated by JAX-WS (part of Metro) are pre-configured with the endpoint address specified in the WSDL. This allows you to invoke the endpoint directly without any additional configuration. However there may be a need to send the exact same Web service request to an endpoint hosted at a different address. For example, the stubs may be generated from a WSDL hosted in the test environment and the request needs to be sent to an endpoint hosted in production environment that is very likely to be on a different machine.

This tip tells you how to change the endpoint address on a pre-generated stub so that it invokes a different endpoint.

The code to invoke a pre-configured stub (using the endpoint address from the WSDL) looks like:

Hello port = new HelloService().getHelloPort();
String result = port.sayHello("Duke!");

As per the JAX-WS 2.1 specification, each proxy implements javax.xml.ws.BindingProvider interface. In order to invoke an endpoint whose address is different from the one specified in the WSDL, you need to insert the following line between the two lines shown above:

((javax.xml.ws.BindingProvider)port).getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "NEW_ADDRESS_HERE");

Just replace NEW_ADDRESS_HERE with your new endpoint address and the exact same request will be directed to the new endpoint. The WSDL contract must be exactly same though otherwise you may get an exception back.

Please leave suggestions on TOTD that you'd like to see. A complete archive is available here.

Technorati: totd webservices metro soap glassfish

del.icio.us | furl | simpy | slashdot | technorati | digg |
|
« Previous day (Aug 16, 2007) | Main | Next day (Aug 18, 2007) »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.