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.

No comments: