Monique Y. Mudama a écrit :
I'm not sure that idea makes sense (deciding between a Servlet and a
Web Service).
From the client point of view this is indeed strangely formulated but
from the server side to me it more or less makes sense.
I think the question is wether the OP should use "plain old Servlet"
technology to provide an answer to his clients (who would have to
use a plain old http request) or web services.
Web services are usually done using SOAP or using XML RPC (O'Reilly
has a nice "Programming Web Services with XML-RPC" book).
Apache's XML RPC implementation is using, for example, the
following naming scheme :
org.apache.xmlrpc.webserver.XmlRpcServlet
And the web service "entry point" can be defined like this
in web.xml:
<servlet-mapping>
<servlet-name>XmlRpcServlet</servlet-name>
<url-pattern>/ws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GoodOldServlet</servlet-name>
<url-pattern>/fakews</url-pattern>
</servlet-mapping>
Here Apache's XML RPC web services is done using
the servlet dispatcher but it doesn't have to be like
that: the web server could be dispatching normal
requests to, say, Tomcat, and web services XML RPC
request to something else...
I can see why the OP is hesitating which way to go...
Should he ask his clients to do (schematized and
considering clients are calling the API from Java
for the example):
xmlRpcClient.setServerURL("sample.com/ws")
xmlRpcClient.execute("someMethod", new Object[]{"value"})
or
httpClient.executeMethod(new
GetMethod("sample.com/fakews?param=value"))
and then parse the result.
I see this as a more or less legitimate question... It may be
bad style to parse the result (plain text?) of an http request
but then there are cases where web services are overkill.
To answer the OP: given the description I'd go with web
services / SOAP. XML RPC is simpler but not as
standardized, so it may prove more difficult to implement
correctly if the environment of the clients isn't controlled.
Alex