I don't think saying it's "silly" is really helpful, or even necessarily
accurate...

If the idea is that the request to the outside server is meant to to
asynchronous, i.e., maybe it feeds a queue or something, then it's a
reasonable model.  It doesn't sound like that's what the OP meant, but if
it was, it would be reasonable.

Of course, even in that case the servlet is not "receiving its own
request", it is simply making a request, at which point it is done, and at
some future time receiving a request with the results.

I agree with you that Web Services need not be as complicated as some make
it out to be... no need to involve SOAP or XML-RPC or any other of the
numerous alphabet soup entries.  I was doing "Web Services" seven years
ago, long before I heard the term.  I suppose you could say that's not
"standards-compliant", which is one of the goals behind Web Services of
course... if everyone used the same mechanisms than theoretically it would
all be interoperable with no effort, and that's not the case if you
essentially cook up your own protocols, but since the reality is that even
following the standards you rarely get that right now, it's not such a
problem :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, May 18, 2005 2:53 pm, Will Hartung said:
>> From: "Michael Mehrle" <[EMAIL PROTECTED]>
>> Sent: Wednesday, May 18, 2005 8:58 AM
>
>
>> - Servlet issues https request to an outside server (via
>> getServletContext().getRequestDispatcher(https://www.someoutsideserver/)
>> )
>> - Outside server processes request and responds with POST response (also
> via
>> https).
>> - Servlet [somehow] is able to be the recipient of the response.
>> - Servlet parses the response and stores data to the database.
>
> Your problem is with the whole model.
>
> There is no reason why a Servlet can't send an HTTP(S) request to another
> server.
>
> But the server that you are making the request shouldn't be making an
> independent POST back to you, rather it should just send you the data you
> want back as the reply body. You then parse the reply and move on.
>
> IF you insist that the "reply" be in the manner of a POST from the other
> server (really really silly IMHO), then, simply, you need to make the
> request to the other server be the last thing your Servlet does. Then when
> the POST comes back, you pick up where you left off, tracking your state
> through a request parameter.
>
> So, your Servlet may start with a request like:
> http://otherserver.com/processData?mysession=123&stage=1
>
> Then the otherserver replies with a POST to:
> http://yourserver.com/yourServlet?mysession=123&stage=2
>
> You use the mysession information to maintain your state between requests.
> But the key is that your servlet ends each time, and Tomcat then restarts
> it
> when the POST comes back.
>
> It's still a silly idea. You don't need Webservices, SOAP, XML-RPC, etc to
> talk to another server via HTTP. You can easily stream serialized Java
> objects to each other if you want, use the simple Java Properties file
> format for your responses, etc. I think if you have control over both
> servers, "WEB RPC" can be very simple for a limited domain. If you don't
> have control over the other server, then you do what you have to do.
>
> I mean, seriously:
>
> public class AddNumberServlet extends HttpServlet {
>     public void doGet(HttpServletRequest request, HttpServletResponse
> response)
>     throws ServletException, IOException {
>         PrintWriter out = response.getWriter();
>         String arg1 = request.getParameter("arg1");
>         String arg2 = request.getParameter("arg2");
>         int i1 = Integer.parseInt(arg1);
>         int i2 = Integer.parseInt(arg2);
>         int result = i1 + i2;
>         out.println("answer=" + result);
>     }
> }
>
> public class RequesterServlet extends HttpServlet {
>     public void doGet(HttpServletRequest request, HttpServletResponse
> response)
>     throws ServletException, IOException {
>         PrintWriter out = response.getWriter();
>
>         URL reqURL = new
> URL("http://otherserver/AddNumberServlet?arg1=2&arg2=4);
>         Properties result = new Properties();
>         result.load(reqURL.openStream());
>         String answer = result.get("answer");
>         out.println("<HTML><BODY>When you add up 2 and 4 you get " +
> answer
> + "</BODY></HTML>");
>     }
> }
>
> There. Instant "web service".
>
> Error checking and robustness are left as an exercise for the reader, but
> you can see that you don't need a 500 page book to get some data from
> another web server.
>
> Not to discount the XML-RPC and SOAPs, they have their place most
> certainly.
> No doubt XML-RPC started just like this and grew from there (and then into
> SOAP), but its just a simple example of how easy this can be when you have
> control over the whole shebang.
>
> Regards,
>
> Will Hartung
> ([EMAIL PROTECTED])
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to