« Another year, another, uh, dollar? | Main | Genyouine Potluck Casserole »

January 19, 2006

Oracle + Java + SOAP + PHP = headache

Well, I promised some stuff about my most recent project; here's the first installment.
I am just completing writing a Web Service in Java that's deployed on Oracle's Application Server. The actual Java code to implement the basic Web Service was very simple to write. I use Oracle's JDeveloper (probably the nicest all-around Java IDE I've used. Not w/out its drawbacks, but overall the best one I've tried), so I just wrote a class with some public methods, used JDeveloper's deployment tools, and I had a Web Service. That was the easy part.

The difficulties reared their ugly heads up when I started getting grand ideas about the WSDL. There are two ways to approach WSDL creation: Write it first, then use it to generate both the server-side and client-side skeleton code, or you can write the server-side skeleton and use a tool to generate a WSDL, from which client code can be generated. I elected to do the latter: writing my Java server-side code and using first AXIS, then JDeveloper to generate a WSDL from the classes. Oracle's Application Server also has the ability to generate a WSDL from a Web Service on the fly, but that WSDL is ugly and not very useful, so I never really considered it as an option.
One of the first ways I wanted to improve upon the WSDL was to remove the Java class package names. For example, if my classes were in the package peter.webservices, then whenever one of my classes appeared in the WSDL, it was referred to as peter_webservices_. Not wanting any consumers of my web service to have to refer to any objects with the package name prepended, I spent a bit of time removing those package names from the WSDL. I first tried creating packageless classes, which looked good in the WSDL, but then I had to use the "tempuri.org" namespace (see tempuri.org for more info about that namespace) in order for the server to recognize the objects.
Cutting through hours of research and testing, I finally figured out that I could add to the web.xml file included in the deployment "war" file, a "custom-bean-qname" parameter that mapped WSDL complex type names to my Java class names. I got the idea here, then extended it to multiple mappings by separating mappings with semi-colons. I never found any mention of using a semi-colon to declare multiple mappings; found that through trial and error (mainly error).
My next battle was saving the actual request for auditing purposes. by the time my Java code had access to the request, it was parsed into parameters and classes. More on that later.

Posted by Peter at January 19, 2006 09:21 PM