Pronouncing acronyms makes my head spin
July 31, 2006It seems that any technology loves to spawn acronyms and, at times, it can all seem like alphabet soup. Sometimes acronyms evolve from being an acronym to being the name of something. For example, I spent many years thinking that JDBC was an acronym for Java Data Base Connectivity. Now, however, knowledgable folks, including the authors of the Sun JDBC API Tutorial, tell us that JDBC is not an acronym for anything. It’s the name of an API.
I’m OK with JDBC being the name of an API but I like to pronounce it by saying each letter: J-D-B-C. This makes sense to me even if it isn’t an acronym.
What has been making my head spin lately is a growing trend to “pronounce” acronyms as words. JNDI (Java Naming and Directory Interface) is the acronym for the naming API specified by JEE (Java Extended Edition). I pronounce it J-N-D-I. Several weeks ago I was talking with a technology instructor who kept pronouncing it Gin-Dee. I had to ask him what Gin-Dee meant which probably didn’t do much to bloster my stock in his view. But I had never heard J-N-D-I called Gin-Dee before.
Since that time I have noticed this trend more and more:
- SOA pronounced Sew-Ahh
- URL pronounced Earl
- JEE pronounced Gee
I am starting to become concerned that one day I will no longer understand my colleagues when they speak to me.
“The Earl for the Sew-Ahh service will be stored in the Gee Gin-Dee tree”.
Meet Amelia
July 30, 2006Tom Cruise on my mind
July 30, 2006I was thinking this morning about Tom Cruise. No, I’m not gay and, allegedly, neither is he. I was listening to a random shuffle of tunes from my iTunes and Take My Breath Away by Berlin came on. It got me thinking about Top Gun and all the great Tom Cruise movies like Jerry Maguire, A Few Good Men, and Risky Business. It made me realize that I’m a Tom Cruise fan, or at least I used to be.
I generally try not to let my opinions of artists personal lives affect how I feel about their work. For example, I like most of Madonna’s music even though I think she’s a moron. Well, Tom has been making this pretty hard to do lately. I don’t have a problem with his religion. I don’t have a problem with anyone’s religion but Tom wants to make his religion my problem. He wants to make it your problem too. Plus, he’s forgotten how to make really good movies.
So, I guess I’m no longer a Tom Cruise fan but at least I can still watch his old movies.
Cowboy Chicken is Awwwwwww-some
July 29, 2006If you live, or visit, the Dallas area and you haven’t been to Cowboy Chicken you just don’t know what you are missing. Incredible meals, reasonable prices, served from two locations.
- 17437 Preston Road
- 5315 Greenville Ave #125
No time for Starbuck’s?
July 29, 2006Serializing an Axis JavaBean object to XML
July 29, 2006Several weeks ago I needed to implement an Axis 1.1 web service server. Axis is a really nice package for abstracting the infinitely complex specifications surrounding current web services. Why is it that once a technology gets standardized it grows in complexity by an order of magnitude? Ah well, that’s a rant for another time. Anyway, as I was saying, Axis does a really nice job of abstracting all this complexity.
I had XML schema’s for the messages that were to be passed and returned by the web service and I created a WSDL describing the operations I would make available for these messages. I did this by importing these schemas into a Schema project in BEA WebLogic Workshop. I then used Workshop to define the methods I wanted to export and asked Workshop to create a WSDL describing these operations. This was quick and simple. Kudos BEA.
Next I ran the generated WSDL through the Axis tool WSDL2Java to generate classes used to interface with Axis and the SOAP messages received. Axis complained about the WSDL generated by BEA Workshop. The error messages generated were not particularly useful to me but by trial and error I determined that Axis was not happy with some of the liberties the BEA tool was taking with respect to namespaces. I manually corrected the WSDL, generated the Axis classes, and was on my way.
Shout out to BEA: The WSDL generated by your tools is not very useful if it is not portable to other Web Service tools. I was using the 8.1 version of Workshop so maybe this is fixed in the new 9.x Eclipse based versions.
OK, now I’m cooking. I quickly add my server specific code and I’m testing the service in short order. Excluding the time I spent dinking around with the WSDL file this whole process took about an hour. Pretty impressive.
Finally, I get a requirement to log the incoming XML data message. Not the whole SOAP message but the payload represented by the Axis generated classes passed to my server object. No problem right? I’ll just ask Axis to serialize the JavaBean class to XML and I’m done. After spending an hour or so looking I just don’t see any way to do this and it isn’t even mentioned in the Axis documentation. Time to Google the Internet for help.
I find a lot of other people asking this same question but no one seems to be answering them. I do find a blog on IBM’s site addressing this subject but it basically just states that serializing an Axis object to XML is non-intutive without offering any insight about how to accomplish it. Great!
So I delve into the Axis source (thank God for open source) and after a couple of hours I’ve cobbled together a generic utility routine to handle this which I’ll share here. I’m not claiming that this is the best way to accomplish this but it seems to work pretty well.
Shout out to Axis Developers: Guys you’ve got to make this easier. Take a look at how simple this is in Apache XMLBeans.
First I created an Exception class to be thrown if an error is encountered.
public class AxisObjectException extends Exception
{
public AxisObjectException()
{
super();
}
public AxisObjectException(final String message, final Throwable cause)
{
super(message, cause);
}
public AxisObjectException(final String message)
{
super(message);
}
public AxisObjectException(final Throwable cause)
{
super(cause);
}
}
Finally, here is the utility code. If there is a better way of doing this please let me know.
/**
* This is a utility class for working with Axis generated objects.
*
* @author Bob Withers 7/6/06
*/
import java.io.StringWriter;
import java.lang.reflect.Method;
import javax.xml.namespace.QName;
import org.apache.axis.MessageContext;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SerializationContextImpl;
import org.apache.axis.encoding.ser.BeanSerializer;
import org.apache.axis.server.AxisServer;
import org.xml.sax.helpers.AttributesImpl;
public class AxisObjectUtil
{
/**
* Convert an Axis data object (as generated by WSDL2Java) to an XML string.
*
* @param obj The xis JavaBean object.
* @param removeNamespaces If true all namespace attributes will be removed from
* the returned XML string.
*
* @return A string containing the XML of the seriaslized Axis JavaBean object.
* @throws AxisObjectException If an error is encountered while serializing
* the Axis JavaBean.
*/
public static String serializeAxisObject(final Object obj, final boolean removeNamespaces,
final boolean prettyPrint) throws AxisObjectException
{
final StringWriter outStr = new StringWriter();
final TypeDesc typeDesc = getAxisTypeDesc(obj);
QName qname = typeDesc.getXmlType();
String lname = qname.getLocalPart();
if (lname.startsWith(">") && lname.length() > 1)
lname = lname.substring(1);
qname = removeNamespaces ? new QName(lname)
: new QName(qname.getNamespaceURI(), lname);
final AxisServer server = new AxisServer();
final BeanSerializer ser = new BeanSerializer(obj.getClass(), qname, typeDesc);
final SerializationContextImpl ctx = new SerializationContextImpl(outStr, new MessageContext(server));
ctx.setSendDecl(false);
ctx.setDoMultiRefs(false);
ctx.setPretty(prettyPrint);
try
{
ser.serialize(qname, new AttributesImpl(), obj, ctx);
}
catch (final Exception e)
{
throw new AxisObjectException("Unable to serialize object "
+ obj.getClass().getName(), e);
}
String xml = outStr.toString();
if (removeNamespaces)
{
// remove any namespace attributes
xml = xml.replaceAll(" xmlns[:=].*?\".*?\"", "")
.replaceAll(" xsi:type=\".*?\"", "");
}
return(xml);
}
/**
* Return the Axis TypeDesc object for the passed Axis JavaBean.
*
* @param obj The Axis JavaBean object.
*
* @return The Axis TypeDesc for the JavaBean.
* @throws AxisObjectException If the passed object is not an Axis JavaBean.
*/
public static TypeDesc getAxisTypeDesc(final Object obj) throws AxisObjectException
{
final Class objClass = obj.getClass();
try
{
final Method methodGetTypeDesc = objClass.getMethod("getTypeDesc", new Class[] {});
final TypeDesc typeDesc = (TypeDesc) methodGetTypeDesc.invoke(obj, new Object[] {});
return(typeDesc);
}
catch (final Exception e)
{
throw new AxisObjectException("Unable to get Axis TypeDesc for "
+ objClass.getName(), e);
}
}
}
My first blog entry
July 29, 2006This is my first blog entry. I’m not exactly sure why I’m starting a blog. I mean I don’t expect to be particularly good at blogging. Nor to I expect my blog entries will be especially interesting. So…. I guess that means I don’t plan on becoming a blog super star and with these low expectations I’m sure to meet all my goals.
I guess a little about myself is in order. I am a professional programmer by trade. Well, maybe semi-professional. I currently code in Java maintaining and enhancing the web site of a major retailer. I’ve been a software engineer for thirty some years and have worked with languages ranging from IBM 360 assembly to Java.
I’m married and live with my wife, a couple of cats, and three parrots. When Confucius originally said, “May you live in interesting times” he wasn’t talking about me (really!) but he might have been. Living with birds and cats (don’t get me started on wives!) makes life interesting.
That’s about it. Just an average guy whose life can be summed up in two paragraphs.

Posted by bwithers 
Posted by bwithers
Posted by bwithers 

