• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Developing Java 6 Webservice with Tomcat-project

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a prob:

1.create a Tomcat-Project named "TomWs"
2.in WEB-INF\src create "HelloServlet.java"

import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.swing.JOptionPane;
import javax.xml.ws.Endpoint;


public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
Endpoint endpoint = Endpoint.publish( "http://localhost:8080/services",
new sayHello() );
res.setContentType( "text/html" );
PrintWriter out = res.getWriter();
out.println( "<html>" );
out.println( "Hallo, mein erstes Servlet meldet sich." );
out.println( "</html>" );
out.close();
JOptionPane.showMessageDialog( null, "Server beenden" );
endpoint.stop();

}
}

"sayHello.java"

import javax.jws.soap.SOAPBinding;
import javax.jws.*;

@WebService(name="XinServ",targetNamespace="http:///")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class sayHello
{
@WebMethod
public String hello( String name )
{
return "Hello " + name + "!";
}

@WebMethod(operationName="body-mass-index")
@WebResult(name = "your-bmi")
public double bmi( @WebParam(name="height") double height,
@WebParam(name="weight") double weight )
{
return weight / (height * height) / 100 * 100;
}
}

3. compile the tow classes in Web-Inf\classes
4. create web.xml in WEB-INF\web.xml

<!DOCTYPE web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>

5. start Tomcat-server in eclipse
6. (Problem)
-- input the "http://localhost:8080/TomWs/hello" --> nothing in the
browser, but there are small dialog "server beenden"
-- input the "http:localhost:8080/services?wsdl" --> nothing and nothing


Why??? How can i see my WSDL-file?
please help me!!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

This is an uncommon way to create a web service. See this thread for a more standard way.

-- input the "http://localhost:8080/TomWs/hello" --> nothing in the
browser, but there are small dialog "server beenden"
-- input the "http:localhost:8080/services?wsdl" --> nothing and nothing



I think the URLs should be http://localhost:8080/TomWs/services/XinServ and http://localhost:8080/TomWs/services/XinServ?wsdl, respectively, but I'm not sure about that.

Also, the URL in the EndPoint constructor (http://localhost:8080/services) looks wrong; "http://localhost:8080/TomWs/services" might be correct (assuming that the name of the web app is "TomWs").
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I'll be. After playing around with this it looks as if the EndPoint constructor URL is correct. The WSDL is served at http://localhost:8080/services?wsdl, although the name of the web app is not "services".

(This only works until the little dialog is dismissed, because that causes the endpoint to be stopped.)
 
xin sa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your Welcom and your Reply very much.

Does it mean, that you have seen the wsld-File? How did you do it?
i need this wsdl-file with "wsimport" to create the Stubs for client-side programm. But I cann't see it, even now. Or have you a another better idear for this?

ps: befor, this worked without Tomcat (only java6) very good, for my job i must do it with tomcat, but now it doesn't work
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does it mean, that you have seen the wsld-File? How did you do it?


It's at the URL shown in my second post (which is the same one you posted initially). What are you seeing at that URL? As I said, this only works as long as you don't close the little dialog.
 
xin sa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh Yes!!! I see it! Thank you!! Thank you!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic