I am trying to expose some Java web services so that I can interoperate from C# (see this SO question). The proof of concept code below works great with WCF!
My question is about the use of the javax.xml.ws.Endpoint class to publish my service:
The following produces WSDL, is cleanly callable from .Net, and performs well. Why wouldn't I use it?
@javax.jws.WebService
public class TestSvc {
@javax.jws.WebMethod()
public String sayHello() {
return "Hello!";
}
}
import javax.xml.ws.Endpoint;
public class Main {
public static void main(String[] args) throws Exception {
Endpoint.publish("http://localhost:8181/Test", new TestSvc());
}
}
Often the scalability arguments (thread pools etc) are quite forceful, but you've already discounted those.
Next, reliability. Some App Servers have nice clustering capabilities, very easy to add new instances, hence enabling fault tolerance while enabling a consolidated administrative view.
Ease of administration generally is quite handy as your number of services grows.
Security infrastructures and declarative security models can be quite important.
For me, the whole Java EE programming model is worth having when your business logic becomes non-trivial. Now we could get into the whole EJB v Spring v ... debate. But the general point I want to make is that as your business logic gets more serious you need facilities such as thread management, persistence, connection pooling, messaging, caching and scheduling; stuff you find in App Servers. Some of that comes naturally in EJB3+JPA, or Spring, some as a natural add-on in the App Servers. If you have prospects of doing serious enterprise-scale Java development it may be better to buy into a little more complextity now in order to get onto an extensible basis for the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With