开发者

Java: using endpoint to publish webservice to tomcat server

开发者 https://www.devze.com 2022-12-16 21:44 出处:网络
i am creating a simple SOAP web service. i am to ensure that it runs on a tomcat web service. im trying to implement this with JAX-WS 开发者_StackOverflow中文版(see code)

i am creating a simple SOAP web service. i am to ensure that it runs on a tomcat web service.

im trying to implement this with JAX-WS 开发者_StackOverflow中文版(see code)

my question is: does the Endpoint.publish use the tomcat server to host this or is it a mini glassfish kind of server?

should i be extending UnicastRemoveObject or something similiar instead?

ideally it would be able to be packaged into a .WAR and dropped in the directory and just work.

It doesn't seem to work with my installed tomcat server as is because it says the port is already in use. I'm using Ubuntu karmic with the tomcat6 package installed, it could also be my user doesnt have permissions to publish to the running tomcat on 8080

i hope this question is clear enough

sample code:

@WebService
public class UserAttributes {
    public static void main(String[] args) {
        UserAttributes instance = new UserAttributes();
        Endpoint.publish("http://localhost:8082/WebServices/userattributes", 
            instance);
    }

    public string Hello() {
       return "Hello World";
    }
}


Does Endpoint.publish use the tomcat server to host this or is it a mini glassfish kind of server?

JAX-WS RI Endpoint.publish API uses by default a light-weight HTTP server implementation that is included in Sun's Java SE 6. So no, it does not use an embedded GlassFish nor an embedded Tomcat and even less your existing Tomcat install: it uses an embedded container i.e. something running inside the same JVM. Just FYI, it is however possible to plug other implementations as long as they provide a Service Provider Implementation (SPI). For example, Jetty 6 does so, see J2se6HttpServerSPI. But I'm not going to cover all the details here :)

It doesn't seem to work with my installed tomcat server as is because it says the port is already in use.

As I said above, the Enpoint.publish API doesn't use your existing Tomcat install. It uses its own server and allows you to deploy your web service without having to package and deploy your app. It is especially useful during development (as it speeds up things). Actually, it's extremely handy.

Now, if you have a Tomcat server running on port 8082 and if you try to publish your Endpoint using the same port, things won't work as you noticed. Use a different (and unused) port during development.

And if you want to deploy your web services to your existing Tomcat install, then you'll have to package them in a war and to deploy this war on Tomcat. But this is totally different and doesn't have anything to do with using the Endpoint.publish API.


Very interesting. It seems to me that the embedded server also contains a soap engine to process the soap messages sent to that port. Is this also an embedded soap engine or is it using one of the popular soap engines (axis2,cxf,metro)


Endpoint.publish() doesn't publish the web service to server instance. If you want to publish end point to web server then it has to be packaged into a WAR using ws gen tool and then be deployed to web server.

Endpoint.publish() publishes the endpoint to run time instance of JVM without creating a server instance. It is very much useful when unit testing a web service using the client test class created using JAX-WS.

0

精彩评论

暂无评论...
验证码 换一张
取 消