cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
249
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 09-02-2005 05:42:16 AM
Hi,

I need to send requests in XML format over HTTP to a remote server from within my Audium scripts, and receive the response also in XML format. I need to create the XML document using information obtained from the caller and, of course, obey the schema; and when I get the reply I need to parse it to quantify what just occured on the server, and read/speak some details back to the caller. The XML server is not under my control, so it can't be changed to be compliant to the Audium XML specs - so the action elements are in Java.

I have used the Java Web Services Developer Pack 1.5 samples in JAXB to build programs that go both ways - they work from internal Java class to write an XML file; and they read an XML file and populate the Java class. The bindings and parsers (marshallers/unmarshallers) are generated using the XML schema.

The system works fine, and after testing I tried to fold the code into a working action class. This class was already fetching an XML file from a server and parsing it, so I am familiar with adding JAR files to Server\common\lib. I have tested retrieving the XML file with standard Java code, and a helper class - HttpClient from Apache. I had played around with parsing bits of the XML using Xparse. This was working but I was looking for a more sophisticated method.

I can build the class OK, and see the class in Studio. When I start to add to the server the JAR files necessary to run the application, I seem to have to put many more in there than I require to run the test application. I ended up adding many JAR files but still could not resolve the class not found errors.

Starting off with jaxb-api.jar, adding jaxb-impl.jar, jaxb-libs.jar - three normal JARS for JAXB. Tomcat then wants classes from relaxngDatatype.jar, namespace.jar, xsdlib.jar. Then it can't resolve a class called jp.co.swiftinc.relax.verifier.RELAXErrorHandler.

Even when I put all the JARS from Web Services that don't class with JARs already in Tomcat, I can't resolve this class.

And yet my experiments outside Tomcat work correctly with just the four jaxb JAR files.

My question has three parts:

(a) Have you successfully used Java Web Services Developer Pack 1.5 with Tomcat 4.1.

(b) I know that the servlet side of these Web Services is enabled in Tomcat 5.0. (Not that I need that part - I am really a client of the XML Web service). Is that what's preventing it from working? If so, when do you expect to migrate to Tomcat 5.0?

(c) Is there a better way to send and receive complex XML documents, populating the request document with data from the caller, and using the information from the reply document to read back to the caller.

My voice applications have to talk to the Gateway and I was excited by the functionality offered by JBIND. I am disappointed that I can't make it work inside Audium action classes. Any tips are greatly appreciated.

Regards,
Geoff

Subject: RE: JAXB (Java Arch. For XML Binding) in Configurable Action Classes
Replied by: Michael Bochynski on 09-02-2005 09:20:42 PM
Hi Geoff,

Audium Call Services does support Tomcat 5. The supported version is Tomcat 5.0.24.

While we have not tested Java Web Services Developer Pack, I would suggest putting all the third-party libraries in TOMCAT_HOME/common/lib instead of CallServices/common/lib folder. It should resolve the issue.

Audium offers set of elements to build complex voice applications, however integration with external systems has to be added by developers. The sugessted and preferred way to integrate with the external system is to build a custom action element. This element would communicate with external system, either using XML or any other technology, and return translated information to the Audium Call Services application.

Hope it helps,
Michael

Subject: RE: JAXB (Java Arch. For XML Binding) in Configurable Action Classes
Replied by: null on 10-02-2005 12:40:18 AM
Audium Call Services does support Tomcat 5. The supported version is Tomcat 5.0.24.[/quote:ea07e1fdbc]

Thanks so much for responding. I actually just installed Tomcat 5.0 on another machine and Audium did start OK and "Hello World" ran when invoked from a Web browser. I should have said I'm on Windows 2000 Server.

[quote:ea07e1fdbc]While we have not tested Java Web Services Developer Pack[/quote:ea07e1fdbc]
OK. I'm on the edge. I'd like to see this stuff work though - it's powerful.

[quote:ea07e1fdbc]I would suggest putting all the third-party libraries in TOMCAT_HOME/common/lib instead of CallServices/common/lib folder. It should resolve the issue.[/quote:ea07e1fdbc]
I'm trying that now, but I'm appear to be getting the same errors. I've installed the 4 main JAXB jar files, and I'm getting an error with Relax. I'll finish this experiment and maybe take it over to Tomcat 5.

Hold the phone!! I installed relaxngDatatype.jar and started getting namespace class not found errors, but then I installed namespace.jar and Tomcat is staying up!! This is fabulous. I had been through this in detail with the jars under Server\common\lib - I think I know the names and content of these jars by heart. 😉

[quote:ea07e1fdbc]...integration with external systems has to be added by developers.[/quote:ea07e1fdbc]
Yes, that's fine. I get paid for that.

Now, let's see if this custom action component actually works.

Mmm, no. It can't find the properties file that's part of the JAXB marshaller - but this is definitely an improvement. The jaxb.properties file is built by the binding compiler and lives under the package I created "com.hp.cis". There is a directory of class files com\hp\cis along with the Action element class file in Server\common\classes.

More work to do, but thanks for the pointers. Before I go too far here I'll take the app onto Tomcat 5 and see if things work over there.

Regards,
Geoff

Subject: RE: JAXB (Java Arch. For XML Binding) in Configurable Action Classes
Replied by: null on 10-02-2005 01:47:55 AM
It did not work on Tomcat 5, but this stuff with class loaders is fraught with danger.

I can make Tomcat see the jaxb.properties file by copying it (with the directory structure intact) to Tomcat\common\class files, but I get another error.

There is a big difference between running JAXB code in a standard class with a main() function to hooking it in to a J2EE environment. The FAQ on JAXB at Sun indicates some of the issues.

Regards,
Geoff

Subject: RE: JAXB (Java Arch. For XML Binding) in Configurable Action Classes
Replied by: null on 11-02-2005 01:43:06 AM
OK, I have this working now. The classes have to be in the right place, and it's not perfectly obvious where that is. In summary:

Tomcat 4.1\common\lib

-----
Install the Sun jars. These are all from Sun's JWSDP-1.5 installation.

From Sun\JWSDP-1.5\jaxb\lib, install the 4 JAXB jars.

From Sun\JWSDP-1.5\jwsdp-shared\lib, install relaxngDatatype.jar, namespace.jar, jax-qname.jar and xsdlib.jar.

Tomcat 4.1\common\classes

-----
Install the classes built by the binding compiler in the package tree you have named. In my case this was a tree called com\hp\cis - the jaxb.properties file is there too. The whole tree is just copied from where the Sun binding compiler created them.

Don't put these classes with the action class under Server\common\classes. I had them there for a while and it will not work that way.

Server\common\classes

-----
This is where I put my custom action class CisXmlProbe.class

Building the Binding Classes

-----
The easiest way to do this is to go into the Sun\JWSDP-1.5\jaxb\samples directory and copy one of the samples - "create-marshal" is the easiest one to start with. I added my schema file here and changed the build.xml file to use my items. Then I used "ant -emacs" to do the heavy lifting.

Once I got the marshaller to work I added code from the "unmarshal-read" example to do the unmarshalling of the XML - that's what I want to test.

The Main.java we are making here is just used to test. What we really want are the classes generated by the binding compiler.

Building the Action Class

-----
I created a directory called Custom under Studio, and I have directories Source, class, and build. I have the source for CisXmlProbe.java in the Source directory, and a compile.bat file in the build directory.

compile.bat pulls all the JAXB jar files in through the CLASSPATH, and looks for the pre-built binding classes in the class directory. I had copied them from where I built them in the Sun tree.

I copied some of the code from the Main.java and inserted it into my Action class, and compiled it. Then I copied the class as I said above.

Running the Application

-----
I have a simple app that just uses my action element. I have the XML file as one of the Settings. When I hit the page with the browser it does an HTTP fetch of the XML file from the location, uses the parsers to create a Java object, and then uses get methods to print out in a file what it sees on the object.

This is the XML file I used:
[code:1:f2fc1e6775]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FDXTrackRequest>
<RequestHeader>NEW_REQUEST_HEADER</RequestHeader>
<PackageIdentifier>NEW_PACKAGE_ID</PackageIdentifier>
<ShipDateRangeBegin>2004-12-12-08&#58;00</ShipDateRangeBegin>
<ShipDateRangeEnd>2005-01-01-08&#58;00</ShipDateRangeEnd>
<ShipDate>2005-02-01-08&#58;00</ShipDate>
<DestinationCountryCode>NEW_DEST_COUNTRY_CODE</DestinationCountryCode>
<DetailScans>false</DetailScans>
<PagingToken>NEW_PAGING_TOKEN</PagingToken>
</FDXTrackRequest>
[/code:1:f2fc1e6775]

and this is the printout in the file:
[code:1:f2fc1e6775]

-----
HTTP Probe
-----
February 10 16&#58;46&#58;45.666
runProbe&#40;&#41; - URL resource = http&#58;//localhost&#58;8080/CVP/input.xml
Request header&#58; NEW_REQUEST_HEADER
Package ID&#58; NEW_PACKAGE_ID
Ship Date Range Begin&#58; Sun 2004.12.12 at 12&#58;00&#58;00 AM PST
Ship Date Range End&#58; Sat 2005.01.01 at 12&#58;00&#58;00 AM PST
Ship Date&#58; Tue 2005.02.01 at 12&#58;00&#58;00 AM PST
Country Code&#58; NEW_DEST_COUNTRY_CODE
Detail Scans&#58; FALSE
Paging Token&#58; NEW_PAGING_TOKEN

-----
end
-----
[/code:1:f2fc1e6775]

Thanks for your help and encouragement. I have to say that this is very cool. In my current project I have some very extensive XML files to send and receive, and I hope these JAXB objects will save me a lot of time.

I'll look into refining the build environment to use ant so I can do it all in one hit.

Regards,
Geoff

Subject: RE: JAXB (Java Arch. For XML Binding) in Configurable Action Classes
Replied by: Michael Bochynski on 11-02-2005 03:16:21 PM
Hi Geoff,

Thank you for the detailed instructions on the installation steps. Nice to hear that you have everything up and working.

If you have any comments, suggestions and/or feedback about Audium software, please do not hesitate to post it here. We are constantly working on improving our software and adding new functionality and we would like to hear feedback from our customers.

Thanks,
Michael
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links