Sunday, December 25, 2005

Merry Christmas

Just a quick note to wish all those who celebrate the holiday - Merry Christmas!

I am spending time in Portland Oregon with my family - eating and opening presents. Coolest present I gave this year was a Palm Tx to my wife with built-in Bluetooth and WiFi. She is still trying to get used to it as I am 'force' upgrading her from a Palm M5 - I can't seem to convince her that having WiFi on her Palm will be cool. :-)

Best present I got this year was a neato atomic travel clock from my sister that can set it self in North America (which most can) but can also read the clock signals in Europe, Japan and other places. I also received lots of good stuff from my Amazon wish list.

Happy New Year too, as my bloging frequency is low enough that I should be proactive!

Monday, December 05, 2005

Macromedia is now Adobe


More info at http://www.adobe.com/aboutadobe/acquisition.html

I am not to "attempt to act as a company spokesperson" about it, but I will say that we are all excited on the CF team for the opportunities that being part Adobe will offer us.

Adobe sells servers too you know.

Friday, December 02, 2005

Changing the target endpoint on a web service object

Just answered a question for a customer that I should probably get out into the googlesphere for others to know.

When you create a web service object in ColdFusion MX, what you are really creating is a Java object that acts as a proxy to the web service. This object derives from an Apache Axis type, org.apache.axis.client.Stub, which in turn implements the standard JAX-RPC type javax.xml.rpc.Stub. Why is this important? Well, these object have an API that you can use to affect the operation of the proxy.

Specifically, you can change the endpoint that the stub will send the HTTP POST that contains the SOAP request. Here is a code snippet that invokes a CFC web service named service.cfc that has an operation "echo" which takes a string and returns it.

ws = CreateObject("webservice", "http://localhost:8500/service.cfc?WSDL");
ret = ws.echo("hello world");


Now lets say we want to watch the request with tcpmon, the TCP/HTTP sniffer that is bundled in with Axis, JRun and ColdFusion. First we start up tcpmon (called 'sniffer' by JRun), on Windows you run c:/CFusionMX7/runtime/bin/sniffer.exe.

Fill in a listener port (try 8501) and then a target hostname (localhost) and port (8500 if CF is running its internal webserver, or port 80 if you are running a standard web server). Click the "Add" button and then switch to the "Port 8501" tab. Just to make the output look nice, check the "XML Format" check box at the bottom so tcpmon will make the SOAP more readable.

Now we can run this CFML cfscript snippet:


ws._setProperty("javax.xml.rpc.service.endpoint.address", "http://localhost:8501/service.cfc");
ret = ws.echo("Through the tunnel");


You will see the SOAP request in the to pane, and the response in the bottom pane.

How does this work? Well JAX-RPC defines a standard property name, "javax.xml.rpc.service.endpoint.address", that will change the URL the stub will send to request to.
Note that we do NOT use "?WSDL" on this URL as this is the endpoint that gets the request, not the URL of the WSDL document.

What else can you do to the Stub? Well, you can read the Javadocs for Stub class in Axis at http://ws.apache.org/axis/java/apiDocs/org/apache/axis/client/Stub.html
and you will see a few interesting APIs. With the addition of the get/set SOAP Header functions in CFMX7 however, ColdFusion already provides access to almost everything via those functions or tag attributes to cfobject or cfinvoke.