public static void main(String[] args) throws Exception {
    WebappAdminStub stub = null;
    try {
      String cookie = authenticate(username, password);
      if (cookie == null) {
        System.err.println("Error authenticating user : "******"WebappAdmin");
      ServiceClient client = stub._getServiceClient();
      Options option = client.getOptions();
      option.setManageSession(true);
      option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
      option.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

      // build webapp data
      WebappUploadData data = getUploadData(inputStream, webappName, webappVersion);
      // upload the war file
      stub.uploadWebapp(new WebappUploadData[] {data});
      System.out.println("Successfully uploaded the webapp");
    } finally {
      if (stub != null) {
        try {
          stub.cleanup();
        } catch (Exception ignore) {

        }
      }
    }
  }
 public void uploadWebapp(WebappUploadData[] webappUploadDataList) throws AxisFault {
   try {
     stub.uploadWebapp(webappUploadDataList);
   } catch (RemoteException e) {
     handleException("cannot.upload.webapps", e);
   }
 }
  public JaxwsWebappAdminClient(
      String cookie, String backendServerURL, ConfigurationContext configCtx, Locale locale)
      throws AxisFault {
    String serviceURL = backendServerURL + "JaxwsWebappAdmin";
    bundle = ResourceBundle.getBundle(BUNDLE, locale);

    stub = new WebappAdminStub(configCtx, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
    option.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
  }