This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Services and the fly likes accessing  web service through a jsp/html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "accessing  web service through a jsp/html" Watch "accessing  web service through a jsp/html" New topic
Author

accessing web service through a jsp/html

kishani liyanage
Ranch Hand

Joined: Dec 08, 2003
Posts: 40
hey i need some help!
( this is related to the calculator example
given with axis! - As the name implies it has two methods add and
subtract. A client can access this web service given the arguments
at the command line)

Question
---------
suppose u have a web page in which u have a form, where u need to enter
the two numbers required by the Calculator web service through the form,
and callupon the calulator web service to perform the necessary
action (add or subtract)
* How can perform this action?
* can i use a jsp? If so how can i link the jsp to the web services file.
* Please give me a solution
Thanks in advance!
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
The step for using JSP + webservice would be..
  • Generate the java stub of the webservice using WSDL2Java
  • Compile and import the above stub files in to your JSP
  • Invoke the Service after receiving the data from HTML
  • Show the result


  • Spritle Software Blogs
    Anita Wang
    Greenhorn

    Joined: Mar 15, 2004
    Posts: 20
    Balaji,
    I tried to follow your steps. The first step was sucessful, but when I tried to compile the files generated by WSDL2Java, it gave me "cannot solve symble" error.
    Here are the directory generated:
    masterproject
    localhost
    axis
    services
    ShippingArrangementService //all java files are under this folder
    ShippingArrangementService
    ShippingArrangement.java //this is the class the compile cannot find
    All the java files need to access the last java file above (ShippingArrangementService.ShippingArrangement.java), but the compile somehow cannot find it. And I've compile it before I compile all other files.
    It would be great if you can help. Thanks!
    Anita Wang
    Greenhorn

    Joined: Mar 15, 2004
    Posts: 20
    The directory in last message is not clear at all, so here it is again:
    masterproject
    --localhost
    ----axis
    ------services
    --------ShippingArrangementService //all java files are under this folder
    --ShippingArrangementService
    ----ShippingArrangement.java //this is the class the compile cannot find
    Balaji Loganathan
    author and deputy
    Bartender

    Joined: Jul 13, 2001
    Posts: 3150
    Originally posted by Anita Wang:

    It gave me "cannot solve symble" error.

    ShippingArrangementService //all java files are under this folder

    In general, go to ShippingArrangmentService directory and compile it using javac *.java , it will compile all the java files with and without the package name ShippingArrangementService
    Let me know if you get through, if not post error message fully "Cannnot resolve symbol '???'"
    You can also use the UBB [ List ] [ * ] [ /List ] option to display the directory and java file structure.
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Balaji Loganathan:
    You can also use the UBB [ List ] [ * ] [ /List ] option to display the directory and java file structure.

    ...or the [CODE] tag which displays its contents with a monospaced font and preserves whitespace.


    Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
    Anita Wang
    Greenhorn

    Joined: Mar 15, 2004
    Posts: 20
    Thanks for the help, but I don't know much about UBB code, so where should I put *, inside some file?
    Also I tried your way of compile but it still gives me errors. A typical error is like this:
    localhost\axis\services\ShippingArrangementService\ShippingArrangementServiceSoapBindingStub.java:37: cannot resolve symbol
    symbol : class ShippingArrangement
    location: interface localhost.axis.services.ShippingArrangementService.ShippingArrangementService
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Anita Wang:
    Thanks for the help, but I don't know much about UBB code, so where should I put [list]*[/list], inside some file?

    This page explains how to use UBB codes.
    Anita Wang
    Greenhorn

    Joined: Mar 15, 2004
    Posts: 20
    I couldn't compile no matter what I do, so I used a stupid way--put ShippingArrangement together with all other java files and change its package declaration.
    Now it compiles, but I'm not sure if the client can access the service since I changed the files generated by WSDL2Java.
    Balaji Loganathan
    author and deputy
    Bartender

    Joined: Jul 13, 2001
    Posts: 3150
    Originally posted by Anita Wang:
    [QB]I couldn't compile no matter what I do, so I used a stupid way--put ShippingArrangement together with all other java files and change its package declaration.
    [QB]

    If you wish, we can analyse it further..
    if you had used WSDL2Java, it will generate neccessary java stub under the package name either given by you or a default package will be created.
    Can you post the your directory with the java file name and package name. Use either [ code ] which can preserve white space.
    for example

    Regarding your second question, doing WSDL2Java will not affect your service, you are only generating a proxy to access your service.
    [ April 29, 2004: Message edited by: Balaji Loganathan ]
    Anita Wang
    Greenhorn

    Joined: Mar 15, 2004
    Posts: 20
    The original directory for my service is:

    The directory generated by WSDL2Java is:

    The last java file compiles fine, and all other java files need to use it (ShippingArrangementService.ShippingArrangement). But when compiled, whenever ShippingArrangementService.ShippingArrangement is used, it gives "cannot solve symbol" error.
    It would be great if you could give me some ideas why this won't work. Thanks!
     
    GeeCON Prague 2014
     
    subject: accessing web service through a jsp/html