Wednesday, June 13, 2007

I know that sometimes I run across stuff that makes me look and feel stupid. Yesterday was one of those days. After searching in all of the wrong places on the web, I found I was not alone. I was trying to create a web service using axis. Simple enough and actually with test cases and everything it didn't take long. What became the issue is I needed to see it work for myself not in a test case but in a browser. Simple enough right? Wrong. For the life of me I could not figure out what the url is to test a soap service. Furthermore I was mentally incapacitated enough I couldn't even describe my issue well enough to find the answer in the oracle of the web Google.

Thanks to xp style paring and my friend Pat we found the answer. The following is taken directly from the apache website so I want to give them credit. The entire doc can be found here

So for those of you searching for a way to do a get against your webservice. Look no further here it is.....

Test a SOAP Endpoint



Now it's time to test a service. Although SOAP 1.1 uses HTTP POST to submit an XML request to the endpoint, Axis also supports a crude HTTP GET access mechanism, which is useful for testing. First let's retrieve the version of Axis from the version endpoint, calling the getVersion method:



http://localhost:8080/axis/services/Version?method=getVersion


This should return something like:


<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>

<getVersionResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getVersionReturn
xsi:type="xsd:string">
Apache Axis version: 1.1 Built on Apr 04, 2003 (01:30:37 PST)
</getVersionReturn>
</getVersionResponse>
</soapenv:Body>
</soapenv:Envelope>

The Axis version and build date may of course be different.




Test a JWS Endpoint



Now let's test a JWS web service. Axis' JWS Web Services are java files you save into the Axis webapp anywhere but the WEB-INF tree, giving them the .jws extension. When someone requests the .jws file by giving its URL, it is compiled and executed. The user guide covers JWS pages in detail.


To test the JWS service, we make a request against a built-in example, EchoHeaders.jws (look for this in the axis/ directory).



Point your browser at http://localhost:8080/axis/EchoHeaders.jws?method=list.



This should return an XML listing of your application headers, such as


<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<listResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<listReturn xsi:type="soapenc:Array"
soapenc:arrayType="xsd:string[6]"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item>accept:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*</item>

<item>accept-language:en-us</item>
<item>accept-encoding:gzip, deflate</item>
<item>user-agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)</item>
<item>host:localhost:8080</item>

<item>connection:Keep-Alive</item>
</listReturn>
</listResponse>
</soapenv:Body>
</soapenv:Envelope>


Again, the exact return values will be different, and you may need to change URLs to correct any host, port and webapp specifics.

Thursday, May 10, 2007

Today I am working with tomcat trying to create a dao using jndi and then writing a test. For those of you that don't know this Tomcat does not allow access from outside the container to the jndi in the way that JBoss does. In order to do this you will need to use a third party tool like Simple-jndi and can be found at: http://www.osjava.org/simple-jndi/.

Fairly simple to use for the most part add it into your project classpath, and set up your jndi for Tomcat in the way the doc says. http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html To make it work correctly you will need to create a few folders and files. One of which is a jndi.properties file. Add the following into this file.

java.naming.factory.initial=org.osjava.sj.SimpleContextFactory
org.osjava.sj.root=file://config/
org.osjava.sj.delimiter=/
org.osjava.sj.space=java:/comp/env

The last line is very important to keep just like it is. If you get the following error when trying to connect this is probably where your issue is.

java.lang.ClassCastException: org.osjava.sj.memory.MemoryContext
at com.yourcompany.util.ServiceLocator.......

Also I am using eclipse and in the root of my project I created a folder I created a folder structure that looks like this [project root]/config/jdbc/

Within that folder I then place a properties file named [jndiName].properties The jndiName is important because Simple-jndi uses the name to look up the properties file. Also for jdbc structure it is important to have the folder structure setup the way I have shown above to ensure it works correctly.

Have fun and it actually works very slick!

Monday, April 30, 2007

Tomorrow I am speaking at the Dynamic Languages User Group in Omaha Ne. For more information please go to http://www.blainebuxton.com/

The talk went well and you can find the presentation notes here --> http://x-celerator.com