axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r508370 [2/3] - in /webservices/axis2/trunk/java: etc/ modules/addressing/ modules/kernel/src/org/apache/axis2/dataRetrieval/ modules/kernel/src/org/apache/axis2/dataRetrieval/client/ modules/kernel/src/org/apache/axis2/deployment/ modules/...
Date Fri, 16 Feb 2007 11:24:56 GMT
Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MetadataExchangeModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MetadataExchangeModule.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MetadataExchangeModule.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MetadataExchangeModule.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,60 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.modules.Module;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * Metadata Exchange Module to support WS-MEX specification
+ * 
+ */
+public class MetadataExchangeModule implements Module {
+
+	private static final Log log = LogFactory.getLog(MetadataExchangeModule.class);
+
+	public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+	 log.info("metadataExchange module has been engaged to Service." );	
+	}
+
+	public void init(ConfigurationContext configContext, AxisModule module)
+			throws AxisFault {
+	
+	}
+
+	public void shutdown(ConfigurationContext configurationContext)
+			throws AxisFault {
+	
+
+	}
+
+	public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+			
+	}
+
+	public boolean canSupportAssertion(Assertion assertion) {
+		return false;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexConstants.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexConstants.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexConstants.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,66 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex;
+
+/**
+ * Contains all the MetadataExchange constants for WS-Mex.
+ * 
+ */
+
+public interface MexConstants {
+	public interface SPEC_VERSIONS {
+		String v1_0 = "Spec_2004_09";
+	}
+    public interface Spec_2004_09 {
+		
+		String NS_URI = "http://schemas.xmlsoap.org/ws/2004/09/mex";
+
+	    public interface Actions {
+			String GET_METADATA_REQUEST = "http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request";
+			String GET_METADATA_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Response";
+			
+	    }
+    }
+    
+  
+    public interface SOAPVersion {
+     		int v1_1 = 1;
+
+    		int v1_2 = 2;
+    
+	}
+    
+    
+    public interface SPEC {
+		String NS_PREFIX = "mex";
+		String GET_METADATA = "GetMetadata";
+		String DIALECT = "Dialect";
+		String IDENTIFIER = "Identifier";
+		String METADATA = "Metadata";
+		String METADATA_SECTION = "MetadataSection";
+		String METADATA_REFERENCE = "MetadataReference";
+		String LOCATION = "Location";
+		String TYPE = "type";
+		
+		String DIALECT_TYPE_WSDL = "http://schemas.xmlsoap.org/wsdl/";
+		String DIALECT_TYPE_POLICY = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+		String DIALECT_TYPE_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+		String DIALECT_TYPE_MEX = "http://schemas.xmlsoap.org/ws/2004/09/mex";
+		
+	}
+  
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexException.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexException.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexException.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,44 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex;
+
+import org.apache.axis2.AxisFault;
+
+/**
+ * Base Exception to report problem from implementation classes of 
+ * WS-MetadataExchange.
+ *
+ */
+public class MexException extends AxisFault {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public MexException(String message) {
+		super(message);
+	}
+
+	public MexException(Throwable e) {
+		super(e);
+	}
+
+    public MexException(String message, Throwable e) {
+		super(message, e);
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexMessageReceiver.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexMessageReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/MexMessageReceiver.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,287 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.dataRetrieval.Data;
+import org.apache.axis2.dataRetrieval.DataRetrievalException;
+import org.apache.axis2.dataRetrieval.DataRetrievalRequest;
+import org.apache.axis2.dataRetrieval.OutputForm;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.mex.OM.Location;
+import org.apache.axis2.mex.OM.Metadata;
+import org.apache.axis2.mex.OM.MetadataReference;
+import org.apache.axis2.mex.OM.MetadataSection;
+import org.apache.axis2.mex.OM.MexOMException;
+import org.apache.axis2.mex.util.MexUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Message Receiver for processing WS-MEX GetMetadata request. 
+ *
+ */
+public class MexMessageReceiver extends AbstractInOutSyncMessageReceiver {
+	private static final Log log = LogFactory.getLog(MexMessageReceiver.class);
+
+	String mexNamespaceValue = null;
+
+	/**
+	 * 
+     */
+	public void invokeBusinessLogic(MessageContext msgContext,
+			MessageContext newmsgContext) throws AxisFault {
+	
+		try {
+			Metadata metadata = handleRequest(msgContext);
+			AxisService theService = msgContext.getAxisService();
+
+			theService.setEndpointURL(msgContext.getTo().getAddress());
+
+			if (metadata != null) {
+				SOAPEnvelope envelope = newmsgContext.getEnvelope();
+				if (envelope == null) {
+					SOAPFactory fac = getSOAPFactory(msgContext);
+					envelope = fac.getDefaultEnvelope();
+				}
+           
+				OMElement result = metadata.toOM();
+				if (result != null) {
+					AxisService service = msgContext.getAxisService();
+					result.declareNamespace(service.getTargetNamespace(),
+							service.getTargetNamespacePrefix());
+					envelope.getBody().addChild(result);
+				}
+
+				newmsgContext.setEnvelope(envelope);
+			}
+			// AxisService service = msgContext.getAxisService();
+
+		} catch (Exception e) {
+			log.info(e);
+			if (e instanceof MexException) {
+				throw (MexException) e;
+			}
+			throw new MexException(e);
+		}
+
+	}
+
+
+	/*
+	 * Handle GetMetadata Request 
+	 * Interprete GetMetadata request and process request.
+	 * @returns Metadata object
+	 */
+	private Metadata handleRequest(MessageContext msgContext) throws AxisFault {
+		Metadata metadata = null;
+		SOAPEnvelope envelope = msgContext.getEnvelope();
+
+		SOAPBody body = envelope.getBody();
+		OMElement aReq = body.getFirstChildWithName(new QName(
+				MexConstants.SPEC.GET_METADATA));
+		List metadata_request_list;
+		if (aReq != null) {
+			metadata_request_list = determineMetadataTypes(aReq);
+
+		} else {
+			throw new MexException("Invalid Metadata request");
+		}
+
+		metadata = processRequest(metadata_request_list, msgContext, aReq);
+
+		return metadata;
+	}
+
+	/*
+	 * Process the requests
+	 * 
+	 * @param metadata_request_list list of mex Dialect for requesting data
+	 * @msgContext MessageContext
+	 * @aReq GetMetadata request 
+     */
+	
+	public Metadata processRequest(List metadata_request_list,
+			MessageContext msgContext, OMElement aReq) throws MexException {
+			
+		String identifier_value = null;
+		
+		DataRetrievalRequest requestOptions = new DataRetrievalRequest();
+		// Check if Identifier element included in request
+		OMElement identifier = aReq.getFirstChildWithName(new QName(
+				MexConstants.SPEC.IDENTIFIER));
+		if (identifier != null) {
+			identifier_value = identifier.getText();
+			if (identifier_value != null && identifier_value.length() > 0) {
+				requestOptions.putIdentifier(identifier_value);
+			}
+		}
+
+		// Instantiate Metadata instance to build the WS-Mex Metadata element
+		SOAPEnvelope envelope = msgContext.getEnvelope();
+		String soapNamespaceURI = envelope.getNamespace().getNamespaceURI();
+		SOAPFactory factory = MexUtil.getSOAPFactory(soapNamespaceURI);
+		mexNamespaceValue = MexConstants.Spec_2004_09.NS_URI;
+		Metadata metadata = new Metadata(factory, mexNamespaceValue);
+
+		// Process the request and append MetadataSection to Metadata
+		// Loop through the metadata_request_list for Dialect(s)), and setup requestOptions.
+		// Basically, one requestOptions is setup for each supported outputForm for the Dialect
+		// and Identifier specified in the GetMetadata request.
+		int len = metadata_request_list.size();
+		OutputForm[] outputforms;
+		
+		for (int i = 0; i < len; i++) { // metadata request
+			String dialect = "";
+			try {
+				dialect = (String) metadata_request_list.get(i);
+
+				requestOptions.putDialect(dialect);
+
+				outputforms = MexUtil.allSupportedOutputForms();
+				// Loop to call AxisService::getData API to retrieve data
+				// for the Dialect and Identifier(if specified) in the request
+				// for each
+				// supported output form.
+				
+				for (int j = 0; j < outputforms.length; j++) { // output form
+					requestOptions.putOutputForm(outputforms[j]);
+
+					Data[] result =  msgContext.getAxisService().getData(requestOptions,
+							msgContext);
+
+					ArrayList sections = processData(result, outputforms[j], dialect,
+							   identifier_value, factory);
+					metadata.addMetadatSections(sections);
+				}
+
+			} catch (DataRetrievalException e) {
+				log.error("Data Retrieval exception detected for dialect, " + dialect, e);
+				
+				throw new MexException(e);
+			} catch (Throwable e) {
+				
+				log.error("Throwable detected for dialect, " + dialect , e);
+
+				throw new MexException(e);
+			}
+
+		}
+		return metadata;
+	}
+
+	/*
+	 * Create MetadataSection for each Data element, and add the
+	 * MetadataSections to Metadata.
+	 */
+	private ArrayList processData(Data[] data, OutputForm outputForm,
+			String dialect, String identifier_value, SOAPFactory factory) throws MexException {
+		MetadataSection section=null;
+		ArrayList sections = new ArrayList();
+		if (data == null || data.length == 0) {
+			if (log.isDebugEnabled())
+				log
+						.debug("No result was returned from getData request for dialect,"
+								+ dialect
+								+ " Form: "
+								+ outputForm.getType()
+								+ ". No MetadataSection will be added!");
+
+		} else {
+			for (int k = 0; k < data.length; k++) {
+
+				section = createMetadataSection(outputForm, data[k].getData(),
+						factory, mexNamespaceValue);
+
+				section.setDialet(dialect);
+				identifier_value = data[k].getIdentifier();
+
+				if (identifier_value != null) {
+					section.setIdentifier(identifier_value);
+				}
+				sections.add(section);
+
+			}
+		}
+		return sections;
+	}
+
+	private MetadataSection createMetadataSection(OutputForm outputForm,
+			Object result, SOAPFactory factory, String mexNamespaceValue)
+			throws MexOMException {
+		MetadataSection section = new MetadataSection(factory,
+				mexNamespaceValue);
+
+		if (outputForm == OutputForm.INLINE_FORM)
+			section.setinlineData(result);
+		else if (outputForm == OutputForm.LOCATION_FORM)
+			section.setLocation(new Location(factory, mexNamespaceValue,
+					(String) result));
+		else if (outputForm == OutputForm.REFERENCE_FORM) {
+			MetadataReference ref = new MetadataReference(factory,
+					mexNamespaceValue);
+			ref.setEPRElement((OMElement) result);
+			section.setMetadataReference(ref);
+		} else {
+
+			section.setinlineData((OMElement) result);
+		}
+
+		return section;
+	}
+
+	/*
+	 * Traverse and interprete the GetMetadata OMElement for Dialect element
+	 * that specified in the request. @returns a List with Dialect(s) of
+	 * metadata requested.
+	 * 
+	 */
+	private List determineMetadataTypes(OMElement aReq) {
+		List metadata_request_list = new ArrayList();
+
+		boolean allTypes = false;
+
+		OMElement dialect = aReq.getFirstChildWithName(new QName(
+				MexConstants.SPEC.DIALECT));
+		if (dialect != null) {
+			String dialectText = dialect.getText();
+			if (dialectText != null && dialectText.length() > 0) {
+				metadata_request_list.add(dialectText.trim());
+			} else
+				allTypes = true;
+		} else
+			allTypes = true;
+
+		if (allTypes) { // retrieve all metadata
+			metadata_request_list.add(MexConstants.SPEC.DIALECT_TYPE_POLICY);
+			metadata_request_list.add(MexConstants.SPEC.DIALECT_TYPE_SCHEMA);
+			metadata_request_list.add(MexConstants.SPEC.DIALECT_TYPE_WSDL);
+		}
+		return metadata_request_list;
+	}
+
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/AnyURIType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/AnyURIType.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/AnyURIType.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/AnyURIType.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,67 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Base Class implemented for element(s) that of type='xs:anyURI' defined in 
+ * the WS-MEX spec.
+ *
+ */
+
+public abstract class AnyURIType extends MexOM implements IMexOM {
+    private String uri = null;
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public AnyURIType(OMFactory defaultFactory, String namespaceValue, String uri) throws MexOMException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new MexOMException ("Unsupported namespace");
+		
+		this.defaultFactory = defaultFactory;
+		this.namespaceValue = namespaceValue;
+		this.uri = uri;
+	}
+	
+
+	/**
+	 * Convert object content to the OMElement representation.
+	 * @return OMElement representation of sub-class of AnyURIType.
+	 * @throws MexOMException
+	 */
+	
+	public OMElement toOM() throws MexOMException {
+		if (uri == null || uri == "") {
+			throw new MexOMException("Expected URI type is not set .. ");
+		}
+			
+		OMNamespace mexNamespace = defaultFactory.createOMNamespace(namespaceValue,MexConstants.SPEC.NS_PREFIX);
+		OMElement  element = defaultFactory.createOMElement(getElementName(), mexNamespace);	
+		element.setText(uri);
+		return element;
+	}
+	
+	/*
+	 * Child class must implement to answer the element name.
+	 */
+  protected abstract String getElementName();
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Dialet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Dialet.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Dialet.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Dialet.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,59 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Class implemented for Dialect element defined in 
+ * the WS-MEX spec.
+ *
+ */
+
+public class Dialet extends AnyURIType {
+
+	/**
+	 * Constructor
+	 * @param defaultFactory
+	 * @param namespaceValue namespace info
+	 * @param dialect Dialect in URI representation
+	 * @throws MexOMException
+	 */
+	public Dialet(OMFactory defaultFactory, String namespaceValue, String dialect) throws MexOMException {
+		super(defaultFactory, namespaceValue, dialect);
+	}
+	
+	/**
+	 * Constructor with default namespace
+	 * @param defaultFactory
+	 * @param dialect  Dialect in URI representation
+	 * @throws MexOMException
+	 */
+	public Dialet(OMFactory defaultFactory, String dialect) throws MexOMException {
+		super(defaultFactory, MexConstants.Spec_2004_09.NS_URI, dialect );
+	}
+
+	/*
+	 * Return name of this element
+	 * (non-Javadoc)
+	 * @see org.apache.axis2.Mex.OM.AnyURIType#getElementName()
+	 */
+	protected String getElementName(){
+		return MexConstants.SPEC.DIALECT;
+	}
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/IMexOM.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/IMexOM.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/IMexOM.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/IMexOM.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,32 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Base interface for objects implemented for elements defined in 
+ * the WS-MEX spec.
+ */
+public interface IMexOM {
+    public OMElement toOM() throws MexOMException;
+   
+    public String getNamespaceValue();
+
+    public boolean isNamespaceSupported (String namespaceName);
+}
+

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Identifier.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Identifier.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Identifier.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Identifier.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,45 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Class implemented for Identifier element defined in 
+ * the WS-MEX spec.
+ *
+ */
+
+public class Identifier extends AnyURIType {
+
+	public Identifier(OMFactory defaultFactory, String namespaceValue, String uri) throws MexOMException {
+		super(defaultFactory, namespaceValue, uri);
+	}
+	public Identifier(OMFactory defaultFactory, String uri) throws MexOMException {
+		super(defaultFactory, MexConstants.Spec_2004_09.NS_URI, uri );
+	}
+
+	/*
+	 * Return name of this element
+	 * (non-Javadoc)
+	 * @see org.apache.axis2.Mex.OM.AnyURIType#getElementName()
+	 */
+	protected String getElementName(){
+		return MexConstants.SPEC.IDENTIFIER;
+	}
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Location.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Location.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Location.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Location.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,45 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Class implemented for Location element defined in 
+ * the WS-MEX spec.
+ *
+ */
+
+public class Location extends AnyURIType {
+
+	public Location(OMFactory defaultFactory, String namespaceValue, String uri) throws MexOMException {
+		super(defaultFactory, namespaceValue, uri);
+	}
+	public Location(OMFactory defaultFactory, String uri) throws MexOMException {
+		super(defaultFactory, MexConstants.Spec_2004_09.NS_URI, uri );
+	}
+	
+	/*
+	 * Return name of this element
+	 * (non-Javadoc)
+	 * @see org.apache.axis2.Mex.OM.AnyURIType#getElementName()
+	 */
+	protected String getElementName(){
+		return MexConstants.SPEC.LOCATION;
+	}
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Metadata.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Metadata.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Metadata.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/Metadata.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,93 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * 
+ * Class implementing  mex:Metadata element 
+ *
+ */
+
+public class Metadata extends MexOM implements IMexOM {
+	private String namespaceValue = null;
+	private OMFactory factory;
+	private List  metadataSections = new ArrayList(); 
+	private OMAttribute attribute = null;
+	
+	/**
+	 * 
+	 * @param defaultFactory
+	 * @param namespaceValue
+	 * @throws MexOMException
+	 */
+
+	public Metadata(OMFactory defaultFactory, String namespaceValue) throws MexOMException  {
+		this.factory = defaultFactory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	
+	public OMElement toOM() throws MexOMException
+	{
+		OMNamespace mexNamespace = factory.createOMNamespace(namespaceValue,MexConstants.SPEC.NS_PREFIX);
+		OMElement metadata = factory.createOMElement(MexConstants.SPEC.METADATA, mexNamespace);
+
+		Iterator sections = metadataSections.iterator();
+		while (sections.hasNext()) {
+			MetadataSection aSection = (MetadataSection) sections.next();
+			metadata.addChild(aSection.toOM());
+		}
+		if (attribute != null){
+			metadata.addAttribute(attribute); //???
+		}
+		return metadata;
+	}
+	
+	public void setMetadatSections(List in_metadataSections) {
+		metadataSections = in_metadataSections;
+	}
+	
+	public void addMetadatSections(List in_metadataSections) {
+		Iterator sections = in_metadataSections.iterator();
+		while (sections.hasNext()) {
+			addMetadatSection((MetadataSection) sections.next());
+		}
+	}
+
+	public void addMetadatSection(MetadataSection section) {
+		metadataSections.add(section);
+	}
+	
+	public MetadataSection[] getMetadatSections() {
+		return (MetadataSection[])metadataSections.toArray(new MetadataSection[0]);
+	}
+	
+	public void setAttribute(OMAttribute in_attribute) {
+		attribute = in_attribute;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataReference.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataReference.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataReference.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,95 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.AxisFault;
+//import org.apache.axis2.addressing.EndpointReference;
+//import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Class implemented for MetadataReference element defined in 
+ * the WS-MetadataExchange spec.
+ *
+ */
+
+public class MetadataReference extends MexOM implements IMexOM {
+
+	private OMFactory factory;
+	private OMElement eprElement = null; 
+
+	private String namespaceValue = null;
+
+	/**
+	 * Constructor
+	 * @param defaultFactory
+	 * @param namespaceValue
+	 * @throws MexOMException
+	 */
+
+	public MetadataReference(OMFactory defaultFactory, String namespaceValue)
+	 throws MexOMException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new MexOMException("Unsupported namespace");
+
+		this.factory = defaultFactory;
+		this.namespaceValue = namespaceValue;
+		}
+
+	/**
+	 * Convert MetadatReference object content to the OMElement representation.
+	 * @return OMElement representation of MetadatReference.
+	 * @throws MexOMException
+	 */
+	public OMElement toOM() throws MexOMException {
+		if (eprElement == null) {
+			throw new MexOMException(
+					"Must have EndpointReference element in MetadataReference");
+		}
+
+		OMElement metadataRef = null;
+		/*if (eprElement.getLocalName() == "EndpointReference") {
+			EndpointReference epr;
+			try {
+				epr = EndpointReferenceHelper.fromOM(eprElement);
+				metadataRef = EndpointReferenceHelper.toOM(factory, epr,
+						new QName(namespaceValue,
+								MexConstants.SPEC.METADATA_REFERENCE,
+								MexConstants.SPEC.NS_PREFIX), eprElement
+								.getNamespace().getNamespaceURI());
+
+			} catch (AxisFault e) {
+				throw new MexOMException(e);
+			}
+		} */
+
+		return metadataRef;
+	}
+	
+	/**
+	 * Set EPR element
+	 * 
+	 * @param element
+	 */
+	public void setEPRElement(OMElement element) {
+		eprElement = element;
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataSection.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataSection.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataSection.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MetadataSection.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,151 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axis2.mex.MexConstants;
+
+
+/**
+ * Class implemented for MetadataSection element defined in 
+ * the WS-MEX spec.
+ *
+ */
+public  class MetadataSection extends MexOM implements IMexOM {
+	private String namespaceValue = null;
+	private OMFactory factory;
+	// Choices of content: inline metadata, MetadataReference, Location
+	private String anyAttribute = null;
+	private OMNode inlineData = null;
+	//private String inlineData = null;
+	private Location location = null;
+	private MetadataReference ref = null;
+	
+    // Attributes
+    private String dialet;
+    private String identifier;
+    
+    /**
+     * Constructor
+     * @param defaultFactory
+     * @param namespaceValue
+     * @throws MexOMException
+     */
+	public MetadataSection(OMFactory defaultFactory, String namespaceValue) throws MexOMException  {
+		this.factory = defaultFactory;
+		this.namespaceValue = namespaceValue;
+	}
+	
+		
+	/**
+	 * Convert MetadatSection content to the OMElement representation.
+	 * @return OMElement representation of MetadataSection.
+	 * @throws MexOMException
+	 */
+	public OMElement toOM() throws MexOMException {
+		OMNamespace mexNamespace = factory.createOMNamespace(namespaceValue,
+				MexConstants.SPEC.NS_PREFIX);
+		OMElement metadataSection = factory.createOMElement(
+				MexConstants.SPEC.METADATA_SECTION, mexNamespace);
+
+		// dialet is required
+		if (dialet == null) {
+			throw new MexOMException("Dialet was not set. Dialet must be set.");
+		}
+		OMAttribute dialetAttrib = factory.createOMAttribute(
+				MexConstants.SPEC.DIALECT, null, dialet);
+
+		metadataSection.addAttribute(dialetAttrib);
+
+		if (identifier != null && identifier.trim().length() > 0) {
+			OMAttribute identifierAttrib = factory.createOMAttribute(
+					MexConstants.SPEC.IDENTIFIER, null, identifier);
+
+			metadataSection.addAttribute(identifierAttrib);
+		}
+		if (anyAttribute != null) {
+			OMAttribute anyAttrib = factory.createOMAttribute("AnyAttribute",
+					null, anyAttribute);
+
+			metadataSection.addAttribute(anyAttrib);
+		}
+
+		if (inlineData != null) {
+			metadataSection.addChild(inlineData);
+			
+		}
+
+		if (location != null) {
+			metadataSection.addChild(location.toOM());
+		}
+
+		if (ref != null) {
+			metadataSection.addChild(ref.toOM());
+		}
+		return metadataSection;
+
+	}
+	
+	public String getDialet() {
+		return dialet;
+	}
+	
+	public String getIdentifier() {
+		return identifier;
+	}
+	
+	public String getanyAttribute() {
+		return anyAttribute;
+	}
+	public Location getLocation() {
+		return location;
+	}
+	
+	public OMNode getInlineData() {
+		return inlineData;
+	}
+	
+	public MetadataReference getMetadataReference() {
+		return ref;
+	}
+	
+	public void setIdentifier(String in_identifier) {
+		identifier =in_identifier;
+	}
+	
+	public void setDialet(String in_dialet) {
+		dialet = in_dialet;
+	}
+	
+	
+	public void setLocation(Location in_location) {
+		location = in_location;
+	}
+	
+	public void setinlineData(Object in_inlineData) {
+		inlineData = (OMNode)in_inlineData;
+	}
+	
+	public void setMetadataReference(MetadataReference in_ref) {
+		ref = in_ref;
+	}
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOM.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOM.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOM.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOM.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,43 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.mex.MexConstants;
+
+/**
+ * Base class for objects implemented for elements defined in 
+ * the WS-MEX spec.
+ */
+
+public abstract class MexOM implements IMexOM {
+
+	
+	public OMElement toOM() throws MexOMException {
+		return null;
+	}
+	
+	public String getNamespaceValue(){
+		return MexConstants.Spec_2004_09.NS_URI;
+	}
+
+	public boolean isNamespaceSupported (String namespaceName) {
+		boolean supported = false;
+		supported = MexConstants.Spec_2004_09.NS_URI.equals(namespaceName);
+		return supported;
+	}
+}

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOMException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOMException.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOMException.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/OM/MexOMException.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,42 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.OM;
+
+import org.apache.axis2.mex.MexException;
+
+/**
+ * An Exception to report problem from implementation classes for the 
+ * WS-MetadataExchange data elements.
+ *
+ */
+public class MexOMException extends MexException {
+
+	private static final long serialVersionUID = 1L;
+
+	protected MexOMException(String message) {
+		super(message);
+	}
+
+	protected MexOMException(Exception e) {
+		super(e);
+	}
+
+	protected MexOMException(String message, Exception e) {
+		super(message, e);
+	}
+
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/util/MexUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/util/MexUtil.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/util/MexUtil.java (added)
+++ webservices/axis2/trunk/java/modules/mex/src/org/apache/axis2/mex/util/MexUtil.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,111 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.mex.util;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.OMNamespaceImpl;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.mex.MexException;
+import org.apache.axis2.mex.MexConstants;
+import org.apache.axis2.dataRetrieval.OutputForm;
+
+public class MexUtil {
+	
+	/**
+	 * Answer SOAPVersion for specified envelope
+	 * @param envelope SOAP Envelope
+	 * @return version of SOAP
+	 * @throws MexException
+	 */
+	public static int getSOAPVersion(SOAPEnvelope envelope) throws MexException {
+		String namespaceName = envelope.getNamespace().getNamespaceURI();
+		if (namespaceName.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI))
+			return MexConstants.SOAPVersion.v1_1;
+		else if (namespaceName.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
+			return MexConstants.SOAPVersion.v1_2;
+		else
+			throw new MexException("Unknown SOAP version");
+	}
+
+	/**
+	 * Answer SOAPFactory corresponding to specified SOAP namespace URI
+	 * @param soapNameSpaceURI soap namespace uri
+	 * @return
+	 * @throws MexException
+	 */
+	public static SOAPFactory getSOAPFactory(String soapNameSpaceURI) throws MexException {
+			if (soapNameSpaceURI.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI))
+			return  OMAbstractFactory.getSOAP11Factory();
+		else if (soapNameSpaceURI.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
+			return OMAbstractFactory.getSOAP12Factory();
+		else
+			throw new MexException("Unknown SOAP soapNameSpaceURI");
+	}
+
+	/**
+	 * Answers SOAPFactory corresponding to specified SOAP Version
+	 * @param SOAPVersion SOAP version
+	 * @return SOAPFactory
+	 */
+	public static SOAPFactory getSOAPFactory(int SOAPVersion) {
+
+		if (SOAPVersion == MexConstants.SOAPVersion.v1_1)
+			return OMAbstractFactory.getSOAP11Factory();
+		else
+			return OMAbstractFactory.getSOAP12Factory();
+
+	}
+	
+	
+	// Return all supported output forms
+	public static OutputForm[] allSupportedOutputForms(){
+		OutputForm[]outputforms = new OutputForm[] {
+		OutputForm.INLINE_FORM,
+		OutputForm.LOCATION_FORM, 
+		OutputForm.REFERENCE_FORM};
+		return outputforms;
+	}
+	
+	/**
+	 * Answers WS-Addressing namespace
+	 * @param toAddress To Address element
+	 * @return OMNamespaceImpl WS-Addressing namespace
+	 * @throws AxisFault
+	 */
+	
+	 public static OMNamespaceImpl getAddressingNameSpace(OMElement toAddress)
+			throws MexException {
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		OMNamespaceImpl wsa = null;
+		try {
+			String prefix = toAddress.getNamespace().getPrefix();
+			String nsURI = toAddress.getNamespace().getNamespaceURI();
+			wsa = (OMNamespaceImpl) factory.createOMNamespace(nsURI, prefix);
+		} catch (Exception e) {
+		    throw new MexException(e);
+		}
+		return wsa;
+
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/README.txt?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/README.txt (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/README.txt Fri Feb 16 03:24:46 2007
@@ -0,0 +1,70 @@
+Sample: mex (Metadata Exchange)
+====================================
+
+Introduction
+============
+
+The examples provided demostrates data retrieval for WS-MetadataExchange GetMetadata request
+handled by different level of data locators below: 
+  1. Default Axis2 data locator
+  2. Plug-in service level data locator
+  3. Plug-in service sevel WSDL-specific data locator
+
+Note: Example 2 and 3 are only for the sole purpose of demostrating plug-in data locator support. The
+      data retrieval logic for the plug-in data locators are not implemented.
+
+Details for the examples are documented in the Apache Metadata Exchange User's Guide.
+
+Prerequisites  
+=============
+
+To build the sample service you must have ant-1.6.x installed in your system. 
+
+To set AXIS2_HOME in Unix/Linux type:
+$export AXIS2_HOME=<path to axis2 distribution>
+
+metadataExchange module must be deployed and engaged. 
+Please refer to Apache Metadata Exchange User's Guide for how to deploy and engage 
+the metadataExchange module.
+
+
+Building the Service
+====================
+
+To build the sample service, type: $ant generate.service or just ant
+
+This will build the DefaultAxis2DataLocatorDemoService.aar, ServiceLevelDataLocatorDemoService.aar,
+and WSDLDataLocatorDemoService.aar service archive files in the build directory and copy them to the
+<AXIS2_HOME>/repository/services directory.
+
+You can start the Axis2 server by running either axis2server.bat (on Windows) or axis2server.sh
+(on Linux)that are located in <AXIS2_HOME>/bin directory.
+
+The WSDL for this service should be viewable at:
+
+http://<yourhost>:<yourport>/axis2/services/DefaultAxis2DataLocatorDemoService?wsdl 
+(e.g. http://localhost:8080/axis2/services/DefaultAxis2DataLocatorDemoService?wsdl)
+
+The clients to send GetMetadata requests are available in samples/mex/src/userguide/mex/clients directory.
+
+
+Running the Client
+==================
+
+To compile and run Default Axis2 data locator scenario, type
+$ant run.client.default
+
+To compile and run Plug-in service level Axis2 data locator scenario, type
+$ant run.client.service
+
+To compile and run PLug-in WSDL-specific level Axis2 data locator scenario, type
+$ant run.client.wsdl
+
+
+Help
+====
+Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.
+
+
+
+

Added: webservices/axis2/trunk/java/modules/samples/mex/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/build.xml?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/build.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/build.xml Fri Feb 16 03:24:46 2007
@@ -0,0 +1,119 @@
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<project name="samples" default="generate.service">
+    <property name="mainDir" value="../.."/>
+    <property name="classes.dir" value="build/classes"/>
+    <path id="axis.classpath">
+        <fileset dir="../../lib">
+            <include name="*.jar"/>
+        </fileset>
+        <pathelement location="build/userguideMex.jar"/>
+    </path>
+
+    <target name="run.client.all"
+            depends="run.client.default,run.client.service,run.client.wsdl">
+    </target>
+    
+    <target name="compile">
+    		<mkdir dir="${classes.dir}" />
+		<javac srcdir="src" destdir="${classes.dir}">
+			<classpath refid="axis.classpath" />
+		</javac>
+		<jar destfile="build/userguideMex.jar">
+            		<fileset dir="${classes.dir}">
+                		<include name="userguide/**"/>
+            		</fileset>
+       		</jar>
+    </target>
+    
+    <target name="generate.service" depends="compile">
+            <jar destfile="build/DefaultAxis2DataLocatorDemoService.aar">
+            <fileset dir="src/userguide/mex/services/example1/">
+                <include name="META-INF/**"/>
+            </fileset>
+            <fileset dir="${classes.dir}">
+                <include name="userguide/mex/services/example1/**/*.class"/>
+            </fileset>
+        </jar>
+        <copy file="build/DefaultAxis2DataLocatorDemoService.aar" tofile="../../repository/services/DefaultAxis2DataLocatorDemoService.aar" overwrite="true"/>
+        <jar destfile="build/ServiceLevelDataLocatorDemoService.aar" >
+            <fileset dir="src/userguide/mex/services/example2/">
+                <include name="META-INF/**"/>
+            </fileset>
+            <fileset dir="${classes.dir}">
+                <include name="userguide/mex/services/example2/**/*.class"/>
+            </fileset>
+        </jar>
+        <copy file="build/ServiceLevelDataLocatorDemoService.aar" tofile="../../repository/services/ServiceLevelDataLocatorDemoService.aar" overwrite="true"/>
+        <jar destfile="build/WSDLDataLocatorDemoService.aar">
+            <fileset dir="src/userguide/mex/services/example3/">
+                <include name="META-INF/**"/>
+            </fileset>
+            <fileset dir="${classes.dir}">
+                <include name="userguide/mex/services/example3/**/*.class"/>
+            </fileset>
+        </jar>
+        <copy file="build/WSDLDataLocatorDemoService.aar" tofile="../../repository/services/WSDLDataLocatorDemoService.aar" overwrite="true"/>
+    </target>
+    
+     <target name="run.client.default" depends="compile">
+        <java classname="userguide.mex.clients.DemoDefaultDataLocator"
+              classpathref="axis.classpath" fork="true">
+            <jvmarg value="-Daxis2.repo=${mainDir}/repository"/>
+        </java>
+    </target>
+    <target name="run.client.service" depends="compile">
+        <java classname="userguide.mex.clients.DemoServiceLevelDataLocator"
+              classpathref="axis.classpath" fork="true">
+            <jvmarg value="-Daxis2.repo=${mainDir}/repository"/>
+        </java>
+    </target>
+    
+    <target name="run.client.wsdl" depends="compile">
+        <java classname="userguide.mex.clients.DemoWSDLServiceDataLocator"
+              classpathref="axis.classpath" fork="true">
+            <jvmarg value="-Daxis2.repo=${mainDir}/repository"/>
+        </java>
+    </target>
+    
+  
+    <target name="run.datalocators.service" depends="compile">
+        <java classname="userguide.mex.datalocators.ServiceLevelDataLocator"
+              classpathref="axis.classpath" fork="true">
+            <jvmarg value="-Daxis2.repo=${mainDir}/repository"/>
+        </java>
+    </target>
+
+    <target name="run.datalocators.wsdl" depends="compile">
+        <java classname="userguide.mex.datalocators.WSDLDataLocator"
+              classpathref="axis.classpath" fork="true">
+            <jvmarg value="-Daxis2.repo=${mainDir}/repository"/>
+        </java>
+    </target>
+    
+    <target name="run.client">
+	<echo message="Please use the following ant targets to run the clients" />
+	<echo message="run.client.default" />
+	<echo message="run.client.service" />
+	<echo message="run.client.wsdl" />
+	<echo message="run.client.all  -  run all clients" />
+    </target>
+    <target name="clean">
+	<delete dir="build" />
+    </target>
+</project>

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoDefaultDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoDefaultDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoDefaultDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoDefaultDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,85 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package userguide.mex.clients;
+
+import java.io.StringWriter;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.dataRetrieval.DRConstants;
+import org.apache.axis2.dataRetrieval.client.MexClient;
+
+/**
+ * Sample to demostrate  using Defautl Axis 2 Data Locator to perform data retrieval 
+ * for the WS-MEX GetMetadata request.
+ * 
+ * In the example, no Data Locator is configured in the Axis2.xml nor the services.xml.
+ * 
+ * Before running the sample, you must first deploy the Axis 2 sample DefaultAxisDataLocatorDemoService service i.e.
+ * DefaultAxisDataLocatorDemoService.aar file.  
+ * 
+ */
+
+public class DemoDefaultDataLocator {
+
+   private static EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/DefaultAxisDataLocatorDemoService");
+
+    public static void main(String[] args) {
+        try {
+            System.out.println("Test getMetadata for " + targetEPR.getAddress());
+         
+            MexClient serviceClient =  new MexClient();
+            Options options = new Options();
+            serviceClient.setOptions(options);
+            
+            options.setTo(targetEPR);
+            options.setAction(DRConstants.SPEC.Actions.GET_METADATA_REQUEST);
+            
+            System.out.println ("No DataLocator configured! Used AxisDataLocator");
+            
+            OMElement method = serviceClient.setupGetMetadataRequest(null, null);
+              
+            OMElement result = serviceClient.sendReceive(method);
+            System.out.println(result);
+            StringWriter writer = new StringWriter();
+            try {
+				result.serialize(XMLOutputFactory.newInstance()
+				      .createXMLStreamWriter(writer));
+			} catch (XMLStreamException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} catch (FactoryConfigurationError e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+            writer.flush();
+            System.out.println(writer.toString());
+
+                     
+       
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+          }
+        }
+
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoServiceLevelDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoServiceLevelDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoServiceLevelDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoServiceLevelDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,64 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package userguide.mex.clients;
+
+import java.util.Calendar;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.dataRetrieval.DRConstants;
+import org.apache.axis2.dataRetrieval.client.MexClient;
+
+/**
+ * Sample to demostrate  using User-defined Service level Data Locator to perform data retrieval 
+ * for the WS-MEX GetMetadata request.
+ * 
+ * In the example, dataLocator element was added in the services.xml of the target Service.
+ * 
+ * Before running the sample, you must first deploy the Axis 2 sample ServiceLevelDataLocatorDemoService service i.e.
+ * ServiceLevelDataLocatorDemoService.aar file.  
+ * 
+ */
+
+public class DemoServiceLevelDataLocator {
+	private static EndpointReference targetEPR = new EndpointReference(
+			"http://127.0.0.1:8080/axis2/services/ServiceLevelDataLocatorDemoService");
+
+	public static void main(String[] args) {
+		try {
+			System.out
+					.println(Calendar.getInstance().getTime() + " Test getMetadata for " + targetEPR.getAddress());
+			MexClient serviceClient = new MexClient();
+			Options options = new Options();
+			serviceClient.setOptions(options);
+	        options.setTo(targetEPR);
+	        options.setAction(DRConstants.SPEC.Actions.GET_METADATA_REQUEST);
+	        
+	        String identifier = null;    
+		    OMElement method = serviceClient.setupGetMetadataRequest(DRConstants.SPEC.DIALECT_TYPE_WSDL, identifier);
+            
+            OMElement result = serviceClient.sendReceive(method);
+     
+			System.out.println(result);
+
+		} catch (AxisFault axisFault) {
+			axisFault.printStackTrace();
+		}
+	}
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoWSDLServiceDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoWSDLServiceDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoWSDLServiceDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/clients/DemoWSDLServiceDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,64 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package userguide.mex.clients;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.dataRetrieval.DRConstants;
+import org.apache.axis2.dataRetrieval.client.MexClient;
+
+/**
+ * Sample to demostrate  using User-defined Service level WSDL dialect specific 
+ * Data Locator to perform data retrievalfor the WS-MEX GetMetadata request.
+ * 
+ * In the example, dialectLocator for dialect="http://schemas.xmlsoap.org/wsdl/"
+ * element was added in the services.xml of the target Service.
+ * 
+ * Before running the sample, you must first deploy the Axis 2 sample "WSDLDataLocatorDemoService" service i.e.
+ * WSDLDataLocatorDemoService.aar file.  
+ * 
+ */
+public class DemoWSDLServiceDataLocator {
+	private static EndpointReference targetEPR = new EndpointReference(
+	"http://127.0.0.1:8080/axis2/services/WSDLDataLocatorDemoService");
+public static void main(String[] args) {
+try {
+	System.out
+			.println("Test getMetadata for " + targetEPR.getAddress());
+	System.out
+	.println("Service WSDL specific DataLocator was configured");
+
+	MexClient serviceClient = new MexClient();
+	Options options = new Options();
+	options.setAction(DRConstants.SPEC.Actions.GET_METADATA_REQUEST);
+    options.setTo(targetEPR);
+    
+	serviceClient.setOptions(options);
+    String identifier =  null;   
+    OMElement method = serviceClient.setupGetMetadataRequest(DRConstants.SPEC.DIALECT_TYPE_WSDL, identifier);
+    
+    OMElement result = serviceClient.sendReceive(method);
+
+	System.out.println(result);
+
+} catch (AxisFault axisFault) {
+	axisFault.printStackTrace();
+}
+}
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/GlobalDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/GlobalDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/GlobalDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/GlobalDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,53 @@
+package userguide.mex.datalocators;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.dataRetrieval.AxisDataLocator;
+import org.apache.axis2.dataRetrieval.DRConstants;
+import org.apache.axis2.dataRetrieval.Data;
+import org.apache.axis2.dataRetrieval.DataRetrievalException;
+import org.apache.axis2.dataRetrieval.DataRetrievalRequest;
+import org.apache.axis2.dataRetrieval.OutputForm;
+
+/*
+ * Sample user-defined Global Level Locator, GlobalDataLocator
+ * 
+ * The sample Data Locator implemented supports data retrieval for the Policy and Schema
+ * dialects. For dialects that it does not understand, it delegates the request
+ * to the available Data Locators in the hierachy by returning Result with
+ * useDataLocatorHierachy indicator set.
+ * 
+ * See  {@link DemoServiceLevelDataLocator} for steps to invoke getData API
+ * of this Data Locator.   
+ * 
+ */
+public class GlobalDataLocator implements AxisDataLocator {
+
+	public Data[] getData(DataRetrievalRequest request,
+			MessageContext msgContext) throws DataRetrievalException {
+		Data[] output = null;
+        String dialect = request.getDialect();
+        OutputForm form = request.getOutputForm();
+        if (form == OutputForm.REFERENCE_FORM){
+        	
+        }
+        if (dialect.equals(DRConstants.SPEC.DIALECT_TYPE_POLICY) || dialect.equals(DRConstants.SPEC.DIALECT_TYPE_SCHEMA)){
+       	 System.out.print("ServiceLevelDataLocator has not implemented data retrieval for dialect " + dialect);
+        	 System.out.println("");
+       	 System.out.println("!!!! get Axis2 default Data Locator to retrieve data for " + dialect);
+
+       	// result = new Result();
+        	// result.setUseDataLocatorHierachy(true);
+  
+        }
+        else {
+       	 System.out.println("!!!! ServiceLevelDataLocator does not support dialect " + dialect);
+       	 System.out.println("");
+       	 System.out.println("!!!! get Axis2 default Data Locator to retrieve data for " + dialect);
+        	// result = new Result();
+        	// result.setUseDataLocatorHierachy(true);
+          }
+        return output;
+		
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/ServiceLevelDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/ServiceLevelDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/ServiceLevelDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/ServiceLevelDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,81 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package userguide.mex.datalocators;
+
+import java.util.Calendar;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.dataRetrieval.*;
+
+/*
+ * Sample Service Level Locator
+ * ServiceLevelDataLocator is configured as a Service level Data Locator 
+ * for the Sample ServiceLevelDataLocatorDemoService service.
+ * 
+ * The sample Data Locator is only for the purpose of demostrating an implementation of
+ * user-defined Service Level Data Locator, the actual data retrieval code is not implemented.
+ * In the example, a empty Data array is returned for Policy and Schema data retrieval
+ * request, and a null Data array is returned for WSDL data retrieval. 
+ * 
+ * Note: Empty Data array means Data Locator understood the request, however data
+ * is not available for the Dialect; a null data array means Data Locator does not understand
+ * the request.
+ * 
+ * Run  {@link DemoServiceLevelDataLocator} client code to invoke this sample data locator. 
+ *    
+ */
+
+public class ServiceLevelDataLocator implements AxisDataLocator {
+
+	public Data[] getData(DataRetrievalRequest request,
+			MessageContext msgContext) throws DataRetrievalException {
+		System.out
+				.println(Calendar.getInstance().getTime()
+						+ " !!!! userguide.mex.datalocators.ServiceLevelDataLocator performing getData !!!!");
+
+		System.out
+				.print(" !!! SERVICE LEVEL Data Locator supports Policy and Schema dialects only !!!");
+		Data[] result = null;
+
+		String dialect = request.getDialect();
+		if (dialect.equals(DRConstants.SPEC.DIALECT_TYPE_POLICY)
+				|| dialect.equals(DRConstants.SPEC.DIALECT_TYPE_SCHEMA)) {
+			// You may implement logic to retrieve Policy and Schema metadata here!!
+			//
+			System.out
+					.print("ServiceLevelDataLocator has not implemented data retrieval for dialect "
+							+ dialect);
+			System.out.println("");
+			System.out
+					.println("!!!! Return empty Data means the Data Locator understood the request for Dialect, but no data is available for the dialect");
+			result = new Data[0];
+
+		} else {
+			System.out
+					.println("!!!! ServiceLevelDataLocator does not support dialect "
+							+ dialect);
+			System.out.println("");
+			System.out
+					.println("!!!! Return Null Data means escalate to the Axis2 default Data Locator to retrieve data for "
+							+ dialect);
+		}
+		return result;
+	}
+		
+		
+	
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/WSDLDataLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/WSDLDataLocator.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/WSDLDataLocator.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/datalocators/WSDLDataLocator.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,55 @@
+/*
+* Copyright 2007 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package userguide.mex.datalocators;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.dataRetrieval.*;
+import org.apache.axis2.description.AxisService;
+
+/*
+ * Sample user-defined WSDL Data Locator, WSDLDataLocator is configured as a Service level 
+ * WSDL specific Data Locator for the Sample WSDLDataServiceMyService service.
+ * 
+ * The sample Data Locator is only for the purpose of demostrating an implementation of
+ * user-defined Service Level Dialect Data Locator, the actual data retrieval code is not implemented.
+ * In the example, a empty Data array is returned for WSDL data retrieval
+ * request.
+ * 
+ * Note: Empty Data array means Data Locator understood the request.
+ * 
+ * Run  {@link DemoServiceWSDLServiceLocator} client code to invoke this sample data locator. 
+ * 
+ */
+public class WSDLDataLocator implements AxisDataLocator {
+	AxisService theService = null;
+
+	String serviceName = "WSDLDataLocatorDemoService";
+
+	public Data[] getData(DataRetrievalRequest request,
+			MessageContext msgContext) throws DataRetrievalException {
+		Data[] result = new Data[0];
+		System.out.print(serviceName
+				+ " User-defined WSDL Data Locator has been invoked!!!");
+		// You may implement logic to retrieve WSDL metadata here!!
+		
+		System.out.print("WSDLDataLocator has not implemented data retrieval.");
+ 
+		return result;
+	}
+
+}
+

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.wsdl?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.wsdl (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.wsdl Fri Feb 16 03:24:46 2007
@@ -0,0 +1,35 @@
+<!--
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<wsdl:definitions xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns0="http://example1.services.mex.userguide/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://example1.services.mex.userguide" targetNamespace="http://example1.services.mex.userguide"><wsdl:documentation>
+     Sample web service to demostrate use of Default Axis2 Data Locator to handle ws-mex GetMetadata request.       
+     </wsdl:documentation><wsdl:types><xs:schema xmlns:ns="http://example1.services.mex.userguide/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example1.services.mex.userguide/xsd">
+<xs:element name="getVersionFault">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="getVersionFault" type="xs:anyType" />
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="getVersionResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="return" nillable="true" type="xs:string" />
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+</xs:schema></wsdl:types><wsdl:message name="getVersionMessage" /><wsdl:message name="getVersionResponse"><wsdl:part name="part1" element="ns0:getVersionResponse" /></wsdl:message><wsdl:message name="getVersionFault"><wsdl:part name="part1" element="ns0:getVersionFault" /></wsdl:message><wsdl:portType name="DefaultAxisDataLocatorDemoServicePortType"><wsdl:operation name="getVersion"><wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:getVersionMessage" wsaw:Action="urn:getVersion" /><wsdl:output message="axis2:getVersionResponse" /><wsdl:fault message="axis2:getVersionFault" name="getVersionFault" /></wsdl:operation></wsdl:portType><wsdl:binding name="DefaultAxisDataLocatorDemoServiceSOAP11Binding" type="axis2:DefaultAxisDataLocatorDemoServicePortType"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /><wsdl:operation name="getVersion"><soap:operation soapAction="urn:getVersion" style="document" /><wsdl:input><soap
 :body use="literal" /></wsdl:input><wsdl:output><soap:body use="literal" /></wsdl:output><wsdl:fault name="getVersionFault"><soap:body use="literal" /></wsdl:fault></wsdl:operation></wsdl:binding><wsdl:binding name="DefaultAxisDataLocatorDemoServiceSOAP12Binding" type="axis2:DefaultAxisDataLocatorDemoServicePortType"><soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /><wsdl:operation name="getVersion"><soap12:operation soapAction="urn:getVersion" style="document" /><wsdl:input><soap12:body use="literal" /></wsdl:input><wsdl:output><soap12:body use="literal" /></wsdl:output><wsdl:fault name="getVersionFault"><soap12:fault use="literal" name="getVersionFault" /></wsdl:fault></wsdl:operation></wsdl:binding><wsdl:binding name="DefaultAxisDataLocatorDemoServiceHttpBinding" type="axis2:DefaultAxisDataLocatorDemoServicePortType"><http:binding verb="POST" /><wsdl:operation name="getVersion"><http:operation location="getVersion" /><wsdl:input><mime:con
 tent type="text/xml" /></wsdl:input><wsdl:output><mime:content type="text/xml" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="DefaultAxisDataLocatorDemoService"><wsdl:port name="DefaultAxisDataLocatorDemoServiceSOAP11port_http" binding="axis2:DefaultAxisDataLocatorDemoServiceSOAP11Binding"><soap:address location="http://192.168.0.107:8080/axis2/services/DefaultAxisDataLocatorDemoService" /></wsdl:port><wsdl:port name="DefaultAxisDataLocatorDemoServiceSOAP12port_http" binding="axis2:DefaultAxisDataLocatorDemoServiceSOAP12Binding"><soap12:address location="http://192.168.0.107:8080/axis2/services/DefaultAxisDataLocatorDemoService" /></wsdl:port><wsdl:port name="DefaultAxisDataLocatorDemoServiceHttpport1" binding="axis2:DefaultAxisDataLocatorDemoServiceHttpBinding"><http:address location="http://192.168.0.107:8080/axis2/rest/DefaultAxisDataLocatorDemoService" /></wsdl:port></wsdl:service></wsdl:definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.xsd?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.xsd (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/DefaultAxis2DataLocatorDemoService.xsd Fri Feb 16 03:24:46 2007
@@ -0,0 +1,38 @@
+<!--
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+xmlns:ns0="http://services.example.org/mex/interop/ServiceA/" 
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/ServiceA/" 
+xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" attributeFormDefault="qualified" 
+elementFormDefault="qualified" 
+targetNamespace="http://example1.services.mex.userguide/xsd">
+ <xsd:element name="getVersionFault"> <xsd:complexType>
+ <xsd:sequence>
+<xsd:element name="getVersionFault" type="xsd:anyType"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:element>
+<xsd:element name="getVersionResponse">
+ <xsd:complexType><xsd:sequence>
+<xsd:element name="return" nillable="true" type="xsd:string"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:element>  
+</xsd:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/ServiceData.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/ServiceData.xml?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/ServiceData.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/ServiceData.xml Fri Feb 16 03:24:46 2007
@@ -0,0 +1,27 @@
+<!--
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<?xml version="1.0" encoding="UTF-8"?>
+<ServiceData>
+<Data dialect="http://schemas.xmlsoap.org/wsdl" file="META-INF/DefaultAxis2DataLocatorDemoService.wsdl">
+ <URL>http://127/0/0/1:8080/axis2/services/DefaultAxis2DataLocatorDemoService?wsdl </URL>
+</Data>
+<Data dialect="http://www.w3.org/2001/XMLSchema" file="META-INF/DefaultAxis2DataLocatorDemoService.xsd">
+ <URL>http://localhost:8080/axis2/services/DefaultAxis2DataLocatorDemoService?xsd </URL>
+ </Data>
+</ServiceData>
+ 

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/services.xml?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/services.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/META-INF/services.xml Fri Feb 16 03:24:46 2007
@@ -0,0 +1,26 @@
+<!--
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<service name="DefaultAxisDataLocatorDemoService">
+    <description>
+     Sample web service to demostrate use of Default Axis2 Data Locator to handle ws-mex GetMetadata request.       
+     </description>
+    <parameter name="ServiceClass" locked="false">userguide.mex.services.example1.Version</parameter>
+    <operation name="getVersion">
+    <messageReceiver  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
+    </operation>
+</service>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/Version.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/Version.java?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/Version.java (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example1/Version.java Fri Feb 16 03:24:46 2007
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package userguide.mex.services.example1;
+
+public class Version {
+    public String getVersion() throws Exception {
+        return "Hello I am Axis2 version service ," +
+                " My version is " + org.apache.axis2.Version.getVersionText();
+    }
+}

Added: webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example2/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example2/META-INF/services.xml?view=auto&rev=508370
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example2/META-INF/services.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/mex/src/userguide/mex/services/example2/META-INF/services.xml Fri Feb 16 03:24:46 2007
@@ -0,0 +1,29 @@
+<!--
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+ <service name="ServiceLevelDataLocatorDemoService">
+    <description>
+      Sample web service to demostrate use of  defined Service Level Data Locator to handle ws-mex GetMetadata request.       
+       </description>
+    <parameter name="ServiceClass" locked="false">userguide.mex.services.example2.Version</parameter>
+    <operation name="getVersion">
+    <messageReceiver  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
+    </operation>
+   <dataLocator class="userguide.mex.datalocators.ServiceLevelDataLocator">
+   </dataLocator>
+
+</service>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message