From: Jeff T. <jef...@us...> - 2002-10-31 03:13:46
|
On Wed, Oct 30, 2002 at 01:55:50PM -0600, Aimee Ukasick wrote: > Hello all. Here's the story: > 1) client sends XML doc to our servlet I think you're doing this bit wrong.. see below. > 2) server sends 200 response > 3) servlet validates doc and sends an acknowledgement to the client URL > specified in the XML > > So, I need Anteater to post the request to our servlet, verify the 200 OK, > and then listen for the acknowledgement. I've been at this all day and > have tried various things. There's no problem with getting the servers > started or sending the xml doc to our servlet, but I'm having problems > getting the listener set up correctly. Here's the anteater code (yes, I > hear you all shuddering): > <?xml version="1.0"?> > > <project name="Anteater-test" default="main" basedir="."> > <description> > Demonstrates how to do an HTTP post > </description> > > <taskdef resource="META-INF/Anteater.tasks"/> > <typedef resource="META-INF/Anteater.types"/> > > <target name="init"> > <servletContainer port="8500"/> > </target> > > <target name="startJRun"> > <exec executable="jrun.exe"> > <arg line="-start default"/> > </exec> > </target> > > <target name="stopJRun"> > <exec executable="jrun.exe"> > <arg line="-stop default"/> > </exec> > </target> > > <target name="testInvalidCreditApp"> > <parallel> > <antcall target="startJRun"/> > <sequential> > <sleep seconds="30"/> > <antcall target="init"/> > <sleep seconds="10"/> Btw, using waitfor's is often faster than sleep statements: <waitfor> <socket server="127.0.0.1" port="${port}"/> </waitfor> > <parallel> > <antcall target="http"/> > <antcall target="startErrorAckListener"/> > </parallel> > </sequential> > </parallel> > </target> > > <target name="http" description="Demonstrates httpRequest"> > > <property name="url" value="http://localhost:8100/csb/CSBServlet"/> > > <echo>An HTTP request will now be sent off to ${url} to post an > invalid XML doc.</echo> > > <httpRequest href="${url}" > method="POST" > useTidy="true" > debug="10" > description="Post a simple string request"> > > <parameter name="xmldoc" value="invalidCSBCreditApp.xml" > type="POST"/> When you said: 1) client sends XML doc to our servlet This isn't what your script does here. It would simply send: POST /csb/CSBServlet HTTP/1.0 Content-length: xx xmldoc=invalidCSBCreditApp.xml If you want to POST an XML document content (not just the filename), then you need something like: <httpRequest href="${url}"> <method>POST</method> <contentEquals href="invalidCSBCreditApp.xml"/> <match> <responseCode value="200" assign="rc"/> </match> </httpRequest> 'contentEquals' sets (or tests) the HTTP body of the request. Attached is a small script, intended to be run from examples/, which demonstrates POSTing an XML file. HTH, --Jeff ... -- > Aimee Ukasick > Software Developer > Centare Group, Ltd. > Brookfield, WI > USA |