Using a local copy of a WSDL with JAX-WS

By default when JAX-WS auto-generates a proxy stub via wsimport, it will reference the live web version of the WSDL in the stub definition. This means that when the stub object is instantiated, JAX-WS will go over the wire to get a copy of the WSDL. Recently, we had a WAR deploy break because Spring was instantiating one of these on start up, and the actual third party WSDL wasn't there.

I little research turned up a few ways to make this WSDL a local resource, instead. In our case, we just put it in the META-INF directory in the WAR, and made a small manual change to the stub code.

What used to be...

@WebServiceClient(name = "MonsterBusinessGatewayService", targetNamespace = "", wsdlLocation = "")
public class MonsterBusinessGatewayService
    extends Service

    private final static Logger logger = Logger.getLogger(;

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl =".");
            url = new URL(baseUrl, "");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: '', retrying as a local file");


@WebServiceClient(name = "MonsterBusinessGatewayService", targetNamespace = "", wsdlLocation = "META-INF/wsdl/MonsterWSDL.xml")
        try {
            URL baseUrl = MonsterBusinessGatewayService.class.getClassLoader().getResource(".");
            url = new URL(baseUrl, "META-INF/wsdl/Monster.xml");
        } catch (MalformedURLException e) {

I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter