Re: [Rife-users] Simulating submissions using HTTP POST
Indeed it wasn't clear what you wanted to do exactly ;-) Good you found what you need. Merry Christmas to you too! On 22 Dec 2006, at 14:02, Hynek Schlawack wrote: Hynek Schlawack <[EMAIL PROTECTED]> writes: Uhm, that's exactly what I want, and I actually know how to do it with CURL or via netcat. And I also know how to achieve it in Perl, I'm currently just totally confused how to achieve it in RIFE. :( The first example is _exactly_ what I want, but where can I access the document inside which is supplied there? Ahhh, finally: --8<---cut here---start->8--- setProhibitRawAccess(false); BufferedReader r = getHttpServletRequest().getReader(); --8<---cut here---end--->8--- This _had_ to be easy like that. *sigh* Thanks for you help, I guess I wan't clear enough about my wishes. -- Geert Bevin Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Hynek Schlawack <[EMAIL PROTECTED]> writes: > Uhm, that's exactly what I want, and I actually know how to do it with > CURL or via netcat. And I also know how to achieve it in Perl, I'm > currently just totally confused how to achieve it in RIFE. :( > > The first example is _exactly_ what I want, but where can I access the > document inside which is supplied there? Ahhh, finally: --8<---cut here---start->8--- setProhibitRawAccess(false); BufferedReader r = getHttpServletRequest().getReader(); --8<---cut here---end--->8--- This _had_ to be easy like that. *sigh* Thanks for you help, I guess I wan't clear enough about my wishes. Merry christmas, -hs ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Hi Geert, Geert Bevin <[EMAIL PROTECTED]> writes: >> This works fine however I won't be able to sell it to the Perl guys >> who >> have to use it. ;) >> If I wanted it really to just submit using a post of text/xml and no >> url-stuff -- how hard would that be? I guess I'd have to write an own > What do you mean, no URL stuff? You have to send that information to a > URL otherwise nothing can respond. The URL is your service > endpoint. Uhm yeah, I'm being fuzzy: I meant no url-encoding. The example you gave me would be: submission=call&script=%3Croot%3E%3Cstuff+arg%3D%22value%22%2F%3E%3C%2Froot%3E > If you want to handle several submissions within the same element, you > have to add the submission=name parameter. However, you can just leave > the submissions out altogether and send the XML data as a post request > to an element that will then always handle it the same way. Yeah, that's what I want, ideally w/o the "script" parameter. I want just an Element which receives a XML document via HTTP POST. Ideally with Content-Type "text/xml". >> participant again...I'm just a bit scared as I don't know much about >> this web stuff. My last participant was a home match (-> sockets) and >> I'm not sure how hard it would be, to get the raw Servlet data? >> Any pointers/estimations concerning this? Is somethign like this >> possible/wanted in RIFE? > I really don't understand why you're making such a fuzz about > this. Sending a post request really is one of the most basic tasks of > web remoting. For example, using Curl: > http://erik.thauvin.net/wiki/display/Tips/Quickly+Send+a+HTTP+POST > +Request Uhm, that's exactly what I want, and I actually know how to do it with CURL or via netcat. And I also know how to achieve it in Perl, I'm currently just totally confused how to achieve it in RIFE. :( The first example is _exactly_ what I want, but where can I access the document inside which is supplied there? Sorry for probing your patience, I feel really stupid right now. :/ TIA, -hs ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Hi Hynek, This works fine however I won't be able to sell it to the Perl guys who have to use it. ;) If I wanted it really to just submit using a post of text/xml and no url-stuff -- how hard would that be? I guess I'd have to write an own What do you mean, no URL stuff? You have to send that information to a URL otherwise nothing can respond. The URL is your service endpoint. If you want to handle several submissions within the same element, you have to add the submission=name parameter. However, you can just leave the submissions out altogether and send the XML data as a post request to an element that will then always handle it the same way. participant again...I'm just a bit scared as I don't know much about this web stuff. My last participant was a home match (-> sockets) and I'm not sure how hard it would be, to get the raw Servlet data? Any pointers/estimations concerning this? Is somethign like this possible/wanted in RIFE? I really don't understand why you're making such a fuzz about this. Sending a post request really is one of the most basic tasks of web remoting. For example, using Curl: http://erik.thauvin.net/wiki/display/Tips/Quickly+Send+a+HTTP+POST +Request If your perl guys have a problem sending a post request over HTTP, then they should really get some additional training, sorry to say: http://www.perl.com/pub/a/2002/08/20/perlandlwp.html?page=2 Best regards, Geert -- Geert Bevin Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Hi Geert, Geert Bevin <[EMAIL PROTECTED]> writes: > For example: > > String xmlString = ""; > HttpUtils.Page page = new HttpUtils.Request("http://localhost:8080/ > rest") > .postParam("submission", "call") > .postParam("script", xmlString) > .retrieve(); > System.out.println(page.getContent()); > However, note that this is probably not the most performant, fault- > tolerant, flexible, x, y, z ... way of doing the post request from the > client. This works fine however I won't be able to sell it to the Perl guys who have to use it. ;) If I wanted it really to just submit using a post of text/xml and no url-stuff -- how hard would that be? I guess I'd have to write an own participant again...I'm just a bit scared as I don't know much about this web stuff. My last participant was a home match (-> sockets) and I'm not sure how hard it would be, to get the raw Servlet data? Any pointers/estimations concerning this? Is somethign like this possible/wanted in RIFE? TIA, -hs ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
For example: String xmlString = ""; HttpUtils.Page page = new HttpUtils.Request("http://localhost:8080/ rest") .postParam("submission", "call") .postParam("script", xmlString) .retrieve(); System.out.println(page.getContent()); However, note that this is probably not the most performant, fault- tolerant, flexible, x, y, z ... way of doing the post request from the client. Take care, Geert On 21 Dec 2006, at 17:33, Hynek Schlawack wrote: Geert Bevin <[EMAIL PROTECTED]> writes: basically, you should create a request like this: http://localhost:8080/rest?submission=call but then in post. I don't know which library you're using, but this is what you'd do with RIFE's HttpUtils (yes, by just using the RIFE jar in another application, not necessarily a webapp): HttpUtils.Page page = new HttpUtils.Request("http://localhost:8080/ rest") .postParam("submission", "call") .retrieve(); System.out.println(page.getContent()); I guess the question sounds stupid, but where's the script I want to submit? I'm pretty baffled through the different possibilities now. %/ I need to submit an XML document, I'd say it's a bad idea to URL encode it. %) -- Geert Bevin Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Geert Bevin <[EMAIL PROTECTED]> writes: > basically, you should create a request like this: > > http://localhost:8080/rest?submission=call > > but then in post. > > I don't know which library you're using, but this is what you'd do > with RIFE's HttpUtils (yes, by just using the RIFE jar in another > application, not necessarily a webapp): > > HttpUtils.Page page = new HttpUtils.Request("http://localhost:8080/ > rest") > .postParam("submission", "call") > .retrieve(); > System.out.println(page.getContent()); I guess the question sounds stupid, but where's the script I want to submit? I'm pretty baffled through the different possibilities now. %/ I need to submit an XML document, I'd say it's a bad idea to URL encode it. %) TIA, -hs ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users
Re: [Rife-users] Simulating submissions using HTTP POST
Hi Hynek, basically, you should create a request like this: http://localhost:8080/rest?submission=call but then in post. I don't know which library you're using, but this is what you'd do with RIFE's HttpUtils (yes, by just using the RIFE jar in another application, not necessarily a webapp): HttpUtils.Page page = new HttpUtils.Request("http://localhost:8080/ rest") .postParam("submission", "call") .retrieve(); System.out.println(page.getContent()); However, note that this code is not intended to run on a production system. I use it and I know that if network connections fails that there's not much in there to do any fault handling and such. This might get you started. Take care, Geert On 21 Dec 2006, at 13:09, Hynek Schlawack wrote: Hi, after I finally ditched SOAP (of course, Google had to imitate me ;)) I decided to use simple webservices using HTTP POST. Frankly, the client should simply POST the command using HTTP and receive an answer. As I understand it, I'll have to simulate a submission using the client. My first simple tries were in vain so I used a sniffer to look at the traffic for the number guess game and I'm pretty confused now: submission=performGuess&submissioncontext=VERY_LONG_STRING&guess=4 Is this submission context really necessary? How can I simulate him? Is there some easier way I'm missing? Ideally, the Element should just look something like this: --8<---cut here---start->8--- public class Rest extends Element { public void processElement() { if (hasSubmission()) { Foo.process(getSubmission()); } } --8<---cut here---end--->8--- What I've tried: --8<---cut here---start->8--- --8<---cut here---end--->8--- and: --8<---cut here---start->8--- public class Rest extends Element { public void processElement() { System.out.println("inside"); if (hasSubmission("call")) { System.out.println("submission"); } } public void doCall() { System.out.println("foo"); } } --8<---cut here---end--->8--- Then I try to call it using: --8<---cut here---start->8--- PostMethod post = new PostMethod("http://localhost:8080/rest";); RequestEntity ent = new StringRequestEntity ("submission=call&script=bar", "application/x-www-url-encoded", "utf8"); post.setRequestEntity(ent); HttpClient httpclient = new HttpClient(); int result = httpclient.executeMethod(post); System.out.println("Response status code: " + result); --8<---cut here---end--->8--- I get a 200 back, `inside' is printed but `submission and `foo' not. I'm pretty sure I'm missing something obvious...any hints? TIA, -hs ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users -- Geert Bevin Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com ___ Rife-users mailing list Rife-users@uwyn.com http://lists.uwyn.com/mailman/listinfo/rife-users