	public ServiceInterface create(String interfaceUrl, String username,
			char[] password, String myProxyServer, String myProxyPort,
			Object[] otherOptions) throws ServiceInterfaceException {
		try {
			final QName serviceName = new QName("http://api.grisu",
					"GrisuService");
			final QName portName = new QName("http://api.grisu",
					"ServiceInterfacePort");
			Service s;
			try {
				s = Service.create(
						new URL(interfaceUrl.replace("soap/GrisuService",
								"api.wsdl")), serviceName);
			} catch (final MalformedURLException e) {
				throw new RuntimeException(e);
			}
			final MTOMFeature mtom = new MTOMFeature();
			try {
				s.getPort(portName, ServiceInterface.class, mtom);
			} catch (final Error e) {
				throw new ServiceInterfaceException(
						"Sorry, could not login. Most likely your client version is incompatible with the server.\n\n"
								+ "Please download the latest version from:\n\nhttp://code.ceres.auckland.ac.nz/stable-downloads\n\n"
								+ "If you have the latest version and are still experiencing this problem please contact\n\n"
								+ "eresearch-admin@list.auckland.ac.nz\n\n"
								+ "with a description of the issue.\n\nUnderlying cause: "
								+ e.getLocalizedMessage());
			}
			final ServiceInterface service = s.getPort(portName,
					ServiceInterface.class);
			final BindingProvider bp = (javax.xml.ws.BindingProvider) service;
			bp.getRequestContext().put(
					javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
					interfaceUrl);
			bp.getRequestContext().put(
					JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
			bp.getRequestContext()
			.put("com.sun.xml.internal.ws.transport.http.client.streaming.chunk.size",
					new Integer(4096));
			bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
					username);
			bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
					new String(password));
			bp.getRequestContext().put(
					BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
			final SOAPBinding binding = (SOAPBinding) bp.getBinding();
			binding.setMTOMEnabled(true);
			String clientstring = LoginManager.getClientName()
					+ " "
					+ LoginManager.getClientVersion()
					+ " / "
					+ "frontend "
					+ grisu.jcommons.utils.Version
					.get("grisu-client");
			Map map = Maps.newHashMap();
			map.put("X-login-host", myProxyServer);
			map.put("X-login-port", myProxyPort);
			map.put("X-grisu-client", Collections.singletonList(clientstring));
			String session_id = LoginManager.USER_SESSION;
			if (StringUtils.isNotBlank(session_id)) {
				map.put("X-client-session-id",
						Collections.singletonList(session_id));
			}
			bp.getRequestContext()
			.put(MessageContext.HTTP_REQUEST_HEADERS, map);
			CommandLogHandler authnHandler = new CommandLogHandler(bp);
			List<Handler> hc = binding.getHandlerChain();
			hc.add(authnHandler);
			binding.setHandlerChain(hc);
			return service;
		} catch (final Exception e) {
			throw new ServiceInterfaceException(
					"Could not create JaxwsServiceInterface: "
							+ e.getLocalizedMessage(), e);
		}
	}

	public ServiceInterface create(String interfaceUrl, String username,
			char[] password, String myProxyServer, String myProxyPort,
			Object[] otherOptions) throws ServiceInterfaceException {
		try {
			final QName serviceName = new QName("http://api.grisu",
					"GrisuService");
			final QName portName = new QName("http://api.grisu",
					"ServiceInterfacePort");
			Service s;
			try {
				s = Service.create(
						new URL(interfaceUrl.replace("soap/GrisuService",
								"api.wsdl")), serviceName);
			} catch (final MalformedURLException e) {
				throw new RuntimeException(e);
			}
			final MTOMFeature mtom = new MTOMFeature();
			try {
				s.getPort(portName, ServiceInterface.class, mtom);
			} catch (final Error e) {
				throw new ServiceInterfaceException(
						"Sorry, could not login. Most likely your client version is incompatible with the server.\n\n"
								+ "Please download the latest version from:\n\nhttp://code.ceres.auckland.ac.nz/stable-downloads\n\n"
								+ "If you have the latest version and are still experiencing this problem please contact\n\n"
								+ "eresearch-admin@list.auckland.ac.nz\n\n"
								+ "with a description of the issue.\n\nUnderlying cause: "
								+ e.getLocalizedMessage());
			}
			final ServiceInterface service = s.getPort(portName,
					ServiceInterface.class);
			final BindingProvider bp = (javax.xml.ws.BindingProvider) service;
			bp.getRequestContext().put(
					javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
					interfaceUrl);
			bp.getRequestContext().put(
					JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
			bp.getRequestContext()
			.put("com.sun.xml.internal.ws.transport.http.client.streaming.chunk.size",
					new Integer(4096));
			bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
					username);
			bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
					new String(password));
			bp.getRequestContext().put(
					BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
			final SOAPBinding binding = (SOAPBinding) bp.getBinding();
			binding.setMTOMEnabled(true);
			String clientstring = LoginManager.getClientName()
					+ " "
					+ LoginManager.getClientVersion()
					+ " / "
					+ "frontend "
					+ grisu.jcommons.utils.Version
					.get("grisu-client");
			Map map = Maps.newHashMap();
			map.put("X-login-host", Collections.singletonList(myProxyServer));
			map.put("X-login-port", Collections.singletonList(myProxyPort));
			map.put("X-grisu-client", Collections.singletonList(clientstring));
			String session_id = LoginManager.USER_SESSION;
			if (StringUtils.isNotBlank(session_id)) {
				map.put("X-client-session-id",
						Collections.singletonList(session_id));
			}
			bp.getRequestContext()
			.put(MessageContext.HTTP_REQUEST_HEADERS, map);
			CommandLogHandler authnHandler = new CommandLogHandler(bp);
			List<Handler> hc = binding.getHandlerChain();
			hc.add(authnHandler);
			binding.setHandlerChain(hc);
			return service;
		} catch (final Exception e) {
			throw new ServiceInterfaceException(
					"Could not create JaxwsServiceInterface: "
							+ e.getLocalizedMessage(), e);
		}
	}
