private static WebServiceTemplate createWebServiceTemplate(URI defaultURI) throws SOAPException {

    SaajSoapMessageFactory messageFactory =
        new SaajSoapMessageFactory(MessageFactory.newInstance());
    messageFactory.setSoapVersion(SOAP_11);

    HttpComponentsMessageSender httpSender = new HttpComponentsMessageSender();
    httpSender.setConnectionTimeout(1200000);
    httpSender.setReadTimeout(1200000);

    Jaxb2Marshaller serviceMarshaller = new Jaxb2Marshaller();
    serviceMarshaller.setContextPath("org.apromore.model");

    WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory);
    webServiceTemplate.setMarshaller(serviceMarshaller);
    webServiceTemplate.setUnmarshaller(serviceMarshaller);
    webServiceTemplate.setMessageSender(httpSender);
    webServiceTemplate.setDefaultUri(defaultURI.toString());

    return webServiceTemplate;
  }
  private WebServiceTemplate initializeConnection() {
    // Create message factory
    SOAPMessageFactory1_1Impl impl = new SOAPMessageFactory1_1Impl();
    SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory(impl);

    msgFactory.setSoapVersion(SoapVersion.SOAP_11);

    // Create an instance of jaxbmarshaller
    HashMap<String, Object> properties = new HashMap<String, Object>();
    properties.put(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, false);
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

    marshaller.setContextPaths("com.andrewcraft.schema");
    marshaller.setMarshallerProperties(properties);

    CommonsHttpMessageSender msgSender = new CommonsHttpMessageSender();

    WebServiceTemplate wsTemplate = new WebServiceTemplate(msgFactory);
    wsTemplate.setMarshaller(marshaller);
    wsTemplate.setUnmarshaller(marshaller);
    wsTemplate.setMessageSender(msgSender);
    wsTemplate.setDefaultUri(session.getServerAddress());
    return wsTemplate;
  }