Creating a Simple JAX-WS WebService in Eclipse

前端 未结 2 881
野趣味
野趣味 2021-01-14 03:16

I\'m trying to create a simple web service in eclipse. First i created an empty java project and added the three following files in the src folder

  1. Greeting.jav
相关标签:
2条回答
  • 2021-01-14 03:51

    The tutorial i'm following doesn't specify any server to run the web service on! I'm wondering if I need to specify any server.

    You don't need a server with this code.
    Your main in:

    Endpoint.publish("http://localhost:8081/WS/Greeting", new GreetingImp());  
    

    starts a light http server under the hood (available after JKD 1.6) and it deploys your web service handling all incoming/outgoing traffic.

    The problem here is that you missed a step:
    You have to generate the required artifacts using the wsgen tool (available in java).

    Check out here: JAX WS tutorial for
    wsgen -d build -s build -classpath build helloservice.endpoint.Hello
    and read about wsgen.

    To be honest I don't remember how you do it via Eclipse (actually I am not sure if this can work in Eclipse automatically without you needing to run wsgen yourself) but you can run it manually and just copy the generated artifacts in your project.

    As for the

    Server Runtime Error: java.net.BindException: Address already in use

    This is self-explanatory: Just use another port. 8081 is already used.

    0 讨论(0)
  • 2021-01-14 03:52

    check this link out,

    http://www.myeclipseide.com/documentation/quickstarts/webservices_jaxws/

    Above link gives step-by-step details for generating both web-service server and client.

    You start with POJO, no annotation needed, JAX-WS runtime will take care after deployment on Tomcat server.

    0 讨论(0)
提交回复
热议问题