Merging changes from WTP 3.0.1.
diff --git a/bundles/org.eclipse.jst.ws.axis2.consumption.core/src/org/eclipse/jst/ws/axis2/consumption/core/command/Axis2ClientOutputCommand.java b/bundles/org.eclipse.jst.ws.axis2.consumption.core/src/org/eclipse/jst/ws/axis2/consumption/core/command/Axis2ClientOutputCommand.java
new file mode 100644
index 0000000..1d57618
--- /dev/null
+++ b/bundles/org.eclipse.jst.ws.axis2.consumption.core/src/org/eclipse/jst/ws/axis2/consumption/core/command/Axis2ClientOutputCommand.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007 WSO2 Inc., IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * WSO2 Inc. - initial API and implementation
+ * yyyymmdd bug      Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080621   210817 samindaw@wso2.com - Saminda Wijeratne, Setting the proxyBean and proxyEndPoint values
+ *******************************************************************************/
+package org.eclipse.jst.ws.axis2.consumption.core.command;
+
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.ws.internal.wsrt.IContext;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+
+
+public class Axis2ClientOutputCommand extends AbstractDataModelOperation {
+	
+	private IWebServiceClient wsc_;
+	private String proxyBean_;
+	private String proxyEndpoint_;
+	  
+		/**
+		* Default CTOR
+		*/
+		public Axis2ClientOutputCommand() {
+		}
+		
+		public Axis2ClientOutputCommand(IWebServiceClient wsc, IContext context) {
+			wsc_ = wsc;
+		}
+		
+	public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable ) 
+	{	
+		wsc_.getWebServiceClientInfo().setImplURL(proxyBean_);
+		wsc_.getWebServiceClientInfo().setProxyEndpoint(proxyEndpoint_);
+		return Status.OK_STATUS;
+	  }
+
+	public void setProxyBean(String proxyBean) {
+		this.proxyBean_ = proxyBean;
+	}
+
+	public void setProxyEndpoint(String proxyEndpoint) {
+		this.proxyEndpoint_ = proxyEndpoint;
+	}
+	  
+		
+}
diff --git a/bundles/org.eclipse.jst.ws.axis2.consumption.ui/src/org/eclipse/jst/ws/internal/axis2/consumption/ui/wsrt/Axis2WebServiceClient.java b/bundles/org.eclipse.jst.ws.axis2.consumption.ui/src/org/eclipse/jst/ws/internal/axis2/consumption/ui/wsrt/Axis2WebServiceClient.java
index 22ae8a0..12f29de 100644
--- a/bundles/org.eclipse.jst.ws.axis2.consumption.ui/src/org/eclipse/jst/ws/internal/axis2/consumption/ui/wsrt/Axis2WebServiceClient.java
+++ b/bundles/org.eclipse.jst.ws.axis2.consumption.ui/src/org/eclipse/jst/ws/internal/axis2/consumption/ui/wsrt/Axis2WebServiceClient.java
@@ -12,6 +12,9 @@
  * 20070230   168762 sandakith@wso2.com - Lahiru Sandakith, Initial code to introduse the Axis2 
  * 										  runtime to the framework for 168762
  * 20070518   187311 sandakith@wso2.com - Lahiru Sandakith, Fixing test resource addition
+ * 20080620   192527 samindaw@wso2.com - Saminda Wijeratne, Update the model information with the axis2 preference settings
+ * 20080621   210817 samindaw@wso2.com - Saminda Wijeratne, Setting the proxyBean and proxyEndPoint values
+ * 20080625   210817 samindaw@wso2.com - Saminda Wijeratne, Setting the proxyBean and proxyEndPoint values - Refactoring
  *******************************************************************************/
 package org.eclipse.jst.ws.internal.axis2.consumption.ui.wsrt;
 
@@ -20,9 +23,12 @@
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.jst.ws.axis2.consumption.core.command.Axis2ClientCodegenCommand;
 import org.eclipse.jst.ws.axis2.consumption.core.command.Axis2ClientDefaultingCommand;
+import org.eclipse.jst.ws.axis2.consumption.core.command.Axis2ClientOutputCommand;
 import org.eclipse.jst.ws.axis2.consumption.core.command.Axis2ClientTestCaseIntegrateCommand;
 import org.eclipse.jst.ws.axis2.consumption.core.command.Axis2WebservicesServerCommand;
 import org.eclipse.jst.ws.axis2.consumption.core.data.DataModel;
+import org.eclipse.jst.ws.axis2.core.context.PersistentAxis2EmitterContext;
+import org.eclipse.jst.ws.axis2.core.utils.Axis2CoreUtils;
 import org.eclipse.jst.ws.internal.axis2.consumption.ui.task.DefaultsForHTTPBasicAuthCommand;
 import org.eclipse.wst.command.internal.env.core.ICommandFactory;
 import org.eclipse.wst.command.internal.env.core.SimpleCommandFactory;
@@ -57,15 +63,50 @@
 		EclipseEnvironment environment = (EclipseEnvironment)env;
 		registerDataMappings( environment.getCommandManager().getMappingRegistry());
 		model.setWebProjectName(project);
+		setupDataModelDefaultPreferenceValues(model);
 		Vector commands = new Vector();
 		commands.add(new Axis2ClientDefaultingCommand(model,this));
+		Axis2ClientOutputCommand axis2ClientOutputCommand = new Axis2ClientOutputCommand(this,ctx);
+		commands.add(axis2ClientOutputCommand);
 		commands.add(new Axis2WebservicesServerCommand(model, project));
 		commands.add(new Axis2ClientCodegenCommand(model));
 		commands.add(new Axis2ClientTestCaseIntegrateCommand(
 				ResourcesPlugin.getWorkspace().getRoot().getProject(project),model));
-		
+		setProxyBeanAndEndPointValues(axis2ClientOutputCommand);
 		return new SimpleCommandFactory(commands);
 	}
+	
+	public void setupDataModelDefaultPreferenceValues(DataModel model){
+		PersistentAxis2EmitterContext axis2Pref = PersistentAxis2EmitterContext.getInstance();
+		model.setASync(axis2Pref.isAsync());
+		model.setSync(axis2Pref.isSync());
+		model.setTestCaseCheck(axis2Pref.isClientTestCase());
+		model.setGenerateAllCheck(axis2Pref.isClientGenerateAll());
+	}
+	
+
+	/**
+	 * extract the proxyBean value and the proxyEndPoint value from the selected WSDL file and
+	 * set those values in the Axis2ClientOutputCommand object
+	 * @param axis2ClientOutputCommand
+	 */
+	public void setProxyBeanAndEndPointValues(Axis2ClientOutputCommand axis2ClientOutputCommand){
+
+		String fileName;
+		//Get the valid filename
+		fileName=this.getWebServiceClientInfo().getWsdlURL();
+
+		String Stub="Stub";
+		String serviceName=Axis2CoreUtils.getServiceNameFromWSDL(fileName);
+		String proxyEndPoint=Axis2CoreUtils.getServiceEndPointFromWSDL(fileName, serviceName);
+		
+		if (proxyEndPoint!=null){
+			String proxyBean=serviceName+Stub;
+			axis2ClientOutputCommand.setProxyBean(proxyBean);
+			axis2ClientOutputCommand.setProxyEndpoint(proxyEndPoint);
+		}
+	}
+		
 
 	public ICommandFactory install(IEnvironment env, IContext ctx,
 			ISelection sel, String project, String earProject) {
diff --git a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java
index 3f43432..7293545 100644
--- a/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java
+++ b/bundles/org.eclipse.jst.ws.axis2.core/src/org/eclipse/jst/ws/axis2/core/utils/Axis2CoreUtils.java
@@ -14,6 +14,7 @@
  * 20070426   183046 sandakith@wso2.com - Lahiru Sandakith
  * 20070501   180284 sandakith@wso2.com - Lahiru Sandakith
  * 20070824   200515 sandakith@wso2.com - Lahiru Sandakith, NON-NLS move to seperate file
+ * 20080625   210817 samindaw@wso2.com - Saminda Wijeratne, Setting the proxyBean and proxyEndPoint values - Refactoring
  *******************************************************************************/
 package org.eclipse.jst.ws.axis2.core.utils;
 
@@ -23,9 +24,19 @@
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.jst.ws.axis2.core.constant.Axis2Constants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 public class Axis2CoreUtils {
 	
@@ -74,4 +85,116 @@
 	       out.close();
 	}
 
+	public static String getServiceEndPointFromWSDL(String fileName, String serviceName){
+		String proxyEndPoint=null;
+		try{
+			Document doc;
+			doc = Axis2CoreUtils.getDocumentFromLocation(fileName);
+			Element documentElement = doc.getDocumentElement();
+			HashMap<String, String> portElements=new HashMap<String, String>();
+
+			//Iterate the root element children to find service nodes
+			for (int i = 0; i < documentElement.getChildNodes().getLength(); i++) {
+				Node serviceElement = documentElement.getChildNodes().item(i);
+				if (serviceElement.getNodeName().equals("wsdl:service")){
+					if (serviceName.equalsIgnoreCase(serviceElement.getAttributes().getNamedItem("name").getNodeValue())){
+
+						//iterate the service node children to find wsdl:port nodes
+						for (int j = 0; j < serviceElement.getChildNodes().getLength(); j++) {
+							Node portElement = serviceElement.getChildNodes().item(j);
+							if (portElement.getNodeName().equals("wsdl:port")){
+								String portBinding=portElement.getAttributes().getNamedItem("binding").getNodeValue().toUpperCase();
+	
+								//iterate the port node children to find the soap address node
+								for (int k = 0; k < portElement.getChildNodes().getLength(); k++) {
+									Node soapElement = portElement.getChildNodes().item(k);
+									if (!soapElement.getNodeName().equals("#text")){
+										String soapLocation=soapElement.getAttributes().getNamedItem("location").getNodeValue();
+										while (portElements.containsKey(portBinding))
+											portBinding="K"+portBinding;
+										portElements.put(portBinding, soapLocation);
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+			String portBindType="";
+			String soap11B="SOAP11Binding".toUpperCase();
+			String soap12B="SOAP12Binding".toUpperCase();
+			String httpB="HttpBinding".toUpperCase();
+			String https="https";
+
+			//iterating through all found end points to determine the required endpoint in the order soap11, soap12, http
+			for (String string : portElements.keySet()) {
+				if (proxyEndPoint==null){
+					proxyEndPoint=portElements.get(string);
+					portBindType=string;
+				}
+				if (string.endsWith(soap11B)){
+					if (proxyEndPoint.startsWith(https)||(!portBindType.endsWith(soap11B))){
+						proxyEndPoint=portElements.get(string);
+						portBindType=string;
+					}
+				}
+				if ((!portBindType.endsWith(soap11B))&&(string.endsWith(soap12B))){
+					if (proxyEndPoint.startsWith(https)||(!portBindType.endsWith(soap12B))){
+						proxyEndPoint=portElements.get(string);
+						portBindType=string;
+					}
+				}
+				if (!((portBindType.endsWith(soap11B))||(portBindType.endsWith(soap12B)))&&(string.endsWith(httpB))){
+					if (proxyEndPoint.startsWith(https)||(!portBindType.endsWith(httpB))){
+						proxyEndPoint=portElements.get(string);
+						portBindType=string;
+					}
+				}
+			}
+		}catch(Exception e){}
+		return proxyEndPoint;
+	}
+
+	public static String getServiceNameFromWSDL(String fileName){
+		String serviceName="";
+		try{
+			Document doc;
+			doc = Axis2CoreUtils.getDocumentFromLocation(fileName);
+			Element documentElement = doc.getDocumentElement();
+
+			//Iterate the root element children to find services
+			for (int i = 0; i < documentElement.getChildNodes().getLength(); i++) {
+				Node serviceElement = documentElement.getChildNodes().item(i);
+				if (serviceElement.getNodeName().equals("wsdl:service")){
+					serviceName=serviceElement.getAttributes().getNamedItem("name").getNodeValue();
+				}
+			}
+		}catch(Exception e){}
+		return serviceName;
+	} 
+
+	private static Document getDocumentFromLocation(String location){
+		Document doc=null;
+		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+		dbf.setIgnoringElementContentWhitespace(true);
+		dbf.setNamespaceAware(false);
+		DocumentBuilder db;
+		try {
+			db = dbf.newDocumentBuilder();
+			if (location.toUpperCase().startsWith("HTTP:")){
+				URL url = new URL(location);
+				doc=db.parse(url.openStream());
+			}else{
+				if (location.toUpperCase().startsWith("FILE:")) location=location.substring(5,location.length());
+				doc=db.parse(new File(location));
+			}		
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		} catch (SAXException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			//e.printStackTrace();
+		}
+		return doc;
+	}
 }
diff --git a/bundles/org.eclipse.jst.ws.axis2.creation.ui/src/org/eclipse/jst/ws/internal/axis2/creation/ui/wsrt/Axis2WebService.java b/bundles/org.eclipse.jst.ws.axis2.creation.ui/src/org/eclipse/jst/ws/internal/axis2/creation/ui/wsrt/Axis2WebService.java
index 23a4479..db8111e 100644
--- a/bundles/org.eclipse.jst.ws.axis2.creation.ui/src/org/eclipse/jst/ws/internal/axis2/creation/ui/wsrt/Axis2WebService.java
+++ b/bundles/org.eclipse.jst.ws.axis2.creation.ui/src/org/eclipse/jst/ws/internal/axis2/creation/ui/wsrt/Axis2WebService.java
@@ -13,12 +13,14 @@
  * 20070425   183046 sandakith@wso2.com - Lahiru Sandakith
  * 20070815   187840 sandakith@wso2.com - Lahiru Sandakith
  * 20080129   209411 kathy@ca.ibm.com - Kathy Chan
+ * 20080620   192527 samindaw@wso2.com - Saminda Wijeratne, Update the model information with the axis2 preference settings
  *******************************************************************************/
 package org.eclipse.jst.ws.internal.axis2.creation.ui.wsrt;
 
 import java.util.Vector;
 
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jst.ws.axis2.core.context.PersistentAxis2EmitterContext;
 import org.eclipse.jst.ws.axis2.creation.core.command.Axis2BUCommand;
 import org.eclipse.jst.ws.axis2.creation.core.command.Axis2BUServiceCreationCommand;
 import org.eclipse.jst.ws.axis2.creation.core.command.Axis2BuildProjectCommand;
@@ -69,7 +71,7 @@
 		//EclipseEnvironment environment = (EclipseEnvironment)env;
 
 		model.setWebProjectName(project);
-
+		setupDataModelDefaultPreferenceValues(model);
 		if (ctx.getScenario().getValue() == WebServiceScenario.BOTTOMUP)	{ 
 			commands.add(new Axis2DefaultingCommand( model,this, ctx.getScenario().getValue() ) );
 			commands.add(new Axis2BUCommand( model ) );
@@ -102,6 +104,12 @@
 		return new SimpleCommandFactory(commands);
 	}
 
+	public void setupDataModelDefaultPreferenceValues(DataModel model){
+		PersistentAxis2EmitterContext axis2Pref = PersistentAxis2EmitterContext.getInstance();
+		model.setGenerateServerSideInterface(axis2Pref.isServiceInterfaceSkeleton());
+		model.setGenerateAllCheck(axis2Pref.isServiceGenerateAll());
+	}
+	
 	public ICommandFactory install(IEnvironment env, IContext ctx, ISelection sel,
 			String project, String earProject)
 	{