[Webtest] Any way to test webservices/SOAP with webtest?

Dierk Koenig webtest@lists.canoo.com
Thu, 25 May 2006 14:42:47 +0200


excellent summary. Thanks Paul.
Mittie

> -----Original Message-----
> From: webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Paul King
> Sent: Donnerstag, 25. Mai 2006 9:55
> To: webtest@gate2.canoo.com
> Subject: Re: [Webtest] Any way to test webservices/SOAP with webtest?
>
>
> Michael Knapp wrote:
> > I need to do a lot of SOAP tesing for an upcoming project  and would
> > love to use WT.  Is it  possible?  Any plans for a SOAP module/steps?
> > Or any other tool that you'd recommend (and if it could be configured to
> > work with ant/WT all the better)?
> >
> > Thanks
> > Mike
>
> I thought I would put some more information into an example.
>
> If you look at the Web Service example at:
>
>     http://groovy.codehaus.org/Groovy+SOAP
>
> Here is how you would test it using traditional webtest:
>
>     <steps>
>         <invoke method="POST" contentFile="addreq.xml" soapAction=""
>             url="http://localhost:6980/MathServiceInterface"/>
>         <verifyXPath xpath="//addResponse/out[text()='3.0']"/>
>         <invoke method="POST" contentFile="squarereq.xml" soapAction=""
>             url="http://localhost:6980/MathServiceInterface"/>
>         <verifyXPath xpath="//squareResponse/out[text()='9.0']"/>
>     </steps>
>
> Where addreq.xml would look something like:
>
>     <?xml version='1.0' encoding='UTF-8'?>
>     <soap:Envelope
>         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>         <soap:Body>
>         <add xmlns="http://DefaultNamespace">
>             <in0 xmlns="http://DefaultNamespace">1.0</in0>
>             <in1>2.0</in1>
>         </add>
>         </soap:Body>
>     </soap:Envelope>
>
> and squarereq.xml would look something like:
>
>     <?xml version='1.0' encoding='UTF-8'?>
>     <soap:Envelope
>             xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>         <soap:Body>
>             <square xmlns="http://DefaultNamespace">
>                 <in0 xmlns="http://DefaultNamespace">3.0</in0>
>             </square>
>         </soap:Body>
>     </soap:Envelope>
>
> Alternatively, testing using groovy within webtest would look like:
>
>     <steps>
>         <groovy>
>             import groovy.net.soap.SoapClient
>
>             def proxy = new
> SoapClient("http://localhost:6980/MathServiceInterface?wsdl")
>
>             def result = proxy.add(1.0, 2.0)
>             assert (result == 3.0)
>
>             result = proxy.square(3.0)
>             assert (result == 9.0)
>         </groovy>
>     </steps>
>
> Note: you will need to place the jars mentioned on that page in your
> webtest lib directory (i.e. groovysoap, stax, jaf and mail jars).
>
> The first approach (traditional webtest) produces more
> information in the test
> summary reporting but requires you to do more work (i.e. keep the
> requests around
> as XML). It depends if you already have those XML files around
> for other purposes,
> e.g. manual testing.
>
>
>
> Cheers ,Paul.
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest