dynamic web service

S

Sascha Effert

Dear all,

I am working on web services in Java. In our project we are using axis
(not axis 2). Preferred I would like to stay, but if there is no other
way I could change.

For any reason I need to deploy dynamically web services. A very easy
example of what I need to do could be the following:

I have an stock excahnge service responsible for adding new stocks.
This could be reachable unter http://localhost/stock and have for
example the method "void addStock(String name, Double value)". Each
time a new stock is added it shall be reachable a a new webservice,
e.g. after using addStock("SUN", 6.41) there shall appear a new Web
Service http://localhost/stocks/SUN with a method "Double getValue()".
This Web Service should be bound to a class Stock, which gets on any
way that it is called for the stock SUN.

I could not find anything in the WWW or in any books about how to
solve this issue. I would be very happy, if anybody could give me a
hint (or a tutorial, or book) how to solve this task.

I know that for this example it would be much easier to write a simple
webservice, getting the Name of the stock as parameter and returning
the right value, but that`s no option for my real problem... The
example above shall just make it easier to understand what I need to
do...

thanks

Sascha Effert
 
L

lord.zoltar

Sascha said:
Dear all,

I am working on web services in Java. In our project we are using axis
(not axis 2). Preferred I would like to stay, but if there is no other
way I could change.

For any reason I need to deploy dynamically web services. A very easy
example of what I need to do could be the following:

I have an stock excahnge service responsible for adding new stocks.
This could be reachable unter http://localhost/stock and have for
example the method "void addStock(String name, Double value)". Each
time a new stock is added it shall be reachable a a new webservice,
e.g. after using addStock("SUN", 6.41) there shall appear a new Web
Service http://localhost/stocks/SUN with a method "Double getValue()".
This Web Service should be bound to a class Stock, which gets on any
way that it is called for the stock SUN.

I could not find anything in the WWW or in any books about how to
solve this issue. I would be very happy, if anybody could give me a
hint (or a tutorial, or book) how to solve this task.

I know that for this example it would be much easier to write a simple
webservice, getting the Name of the stock as parameter and returning
the right value, but that`s no option for my real problem... The
example above shall just make it easier to understand what I need to
do...

thanks

Sascha Effert

Hi,
I think this technique in webservices is called REST. Might want to do
a web search on "REST webservice".
Here's the first result I found:
http://www.xfront.com/REST-Web-Services.html
 
S

Sascha Effert

Hi,
I think this technique in webservices is called REST. Might want to do
a web search on "REST webservice".
Here's the first result I found:http://www.xfront.com/REST-Web-Services.html

Damm... There is a second problem: My web service has to be reachable
using SOAP only, because there are tunnels in the way only able to
forward SOAP Messages. More over I need some session data, as an
authorized user, locking states and other informations. Therefore it
seems not possible for me to use a REST-Web-Service, if I understood
this area correctly... Am I wrong? Is there another way to solve it?

bests

Sascha Effert
 
L

Lew

Sascha said:
I have an stock excahnge service responsible for adding new stocks.
This could be reachable unterhttp://localhost/stockand have for
example the method "void addStock(String name, Double value)". Each
time a new stock is added it shall be reachable a a new webservice,
e.g. after using addStock("SUN", 6.41) there shall appear a new Web
Service <http://localhost/stocks/SUN> with a method "Double getValue()".
This Web Service should be bound to a class Stock, which gets on any
way that it is called for the stock SUN.

I don't know the answer to your question, but on the side I suggest
that you not use double (or Double) for money amounts. People tend to
want their financial data to be accurate.

FWIW, Sunoco is at $28.62 as of when I made this post.

I do see architectural problems with your approach. You're going to
have a class 'Stock' for every different stock, and you are defining a
whole new service based on the stock name but also feeding it a
price. (Is that the bid or ask price, BTW?) How is the price part of
the service definition.

You might be able to do what you want by modifying a template WSDL
with the stock name, firing off WSDL2Java on the new WSDL, then
invoking the deployer on the result. I just don't see that you want
the right thing.
 
M

Mike Schilling

Sascha said:
Damm... There is a second problem: My web service has to be
reachable
using SOAP only, because there are tunnels in the way only able to
forward SOAP Messages. More over I need some session data, as an
authorized user, locking states and other informations. Therefore it
seems not possible for me to use a REST-Web-Service, if I understood
this area correctly... Am I wrong? Is there another way to solve it?

The obvious way is to use the stock name (or some unique id for the
stock) as an input parameter in the request message rather than as
part of the URL. That lets you write a perfectly standard SOAP
service using Axis or whatever other toolkit you like.
 
R

Roedy Green

For any reason I need to deploy dynamically web services. A very easy
example of what I need to do could be the following:

You write a servlet to accept the new info and store it in a SQL
database.

You write a servlet that given the name of the service fishes it out
of the database and returns it.

Normally you set up your query to include the name of the service as a
parameter. If you want it to be part of the action, you need to
configure your Servlet Womb to route all such requests to a common
servlet.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Nature provides a free lunch, but only if we control our appetites."
~ William Ruckelshaus, America’s first head of the EPA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top