Server-Side XML Validation with CXF Webservice

You can override validation error messages, inserting a line number, by using a custom ValidationEventHandler: package example; import javax.xml.bind.ValidationEvent; import javax.xml.bind.helpers.DefaultValidationEventHandler; public class MyValidationEventHandler extends DefaultValidationEventHandler { @Override public boolean handleEvent(ValidationEvent event) { if (event.getSeverity() == ValidationEvent.WARNING) { return super.handleEvent(event); } else { throw new RuntimeException(event.getMessage() + ” [line:”+event.getLocator().getLineNumber()+”]”); } } } If you configure … Read more

How can I use an HTTP proxy for a JAX-WS request without setting a system-wide property?

I recommend using a custom ProxySelector. I had the same problem and it works great and is super flexible. It’s simple too. Here’s my CustomProxySelector: import org.hibernate.validator.util.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.*; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; /** * So the way a ProxySelector works is that … Read more

JAX-WS vs. JAX-RPC

You didn’t mention anything about the implementations you’re using so it’s hard to say anything about them 🙂 I don’t know if your benchmark is representative of anything, I’m not sure it allows to make any valid conclusion. JAX-WS is supposed to perform better in general than JAX-RPC, see the already mentioned article. JAX-RPC is … Read more

How to manually deploy a web service on Tomcat 6?

How to MANUALLY build and deploy a jax-ws web service to tomcat I was trying to figure out how to MANUALLY build and deploy a web service for learning pourposes. I began with this excellent article http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/ (new URL: http://www.oracle.com/technetwork/articles/javase/jax-ws-2-141894.html) The idea was to do the whole thing using only a notepad and the command … Read more

How can I access the ServletContext from within a JAX-WS web service?

The servlet context is made available by JAX-WS via the message context, which can be retrieved using the web service context. Inserting the following member will cause JAX-WS to inject a reference to the web service context into your web service: import javax.annotation.Resource; import javax.servlet.ServletContext; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext; … @Resource private WebServiceContext context; Then, … Read more