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---
<element id="REST" url="/rest" implementation="my.impl">
<submission name="call">
<param name="script" />
</submission>
</element>
--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
[email protected]
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
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users