ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sag...@apache.org
Subject svn commit: r809824 [3/6] - in /webservices/woden/trunk/java/woden-ant: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/woden/ src/main/java/org/apache/woden/ant/ src/main/resources/ src/main/resou...
Date Tue, 01 Sep 2009 05:35:04 GMT
Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/CmWriter.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/CmWriter.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/CmWriter.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/CmWriter.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,784 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.InterfaceFault;
+import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.TypeDefinition;
+import org.apache.woden.wsdl20.extensions.WSDLExtensionConstants;
+import org.apache.woden.wsdl20.extensions.InterfaceOperationExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPConstants;
+import org.apache.woden.wsdl20.extensions.http.HTTPEndpointExtensions;
+import org.apache.woden.wsdl20.extensions.rpc.RPCConstants;
+import org.apache.woden.wsdl20.extensions.rpc.RPCInterfaceOperationExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPConstants;
+import org.apache.woden.wsdl20.extensions.soap.SOAPEndpointExtensions;
+
+/**
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public class CmWriter extends NamespaceWriter {
+
+    public static String NS = "http://www.w3.org/2002/ws/desc/wsdl/component";
+
+    public static String PREFIX = "";
+
+    /** XML Schema namespace */
+    private static String XSD_NS = "http://www.w3.org/2001/XMLSchema";
+
+    /** build-in simple types */
+    private static String[] XSD_TYPES = { "string", "boolean", "decimal",
+            "float", "double", "duration", "dateTime", "time", "date",
+            "gYearMonth", "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
+            "base64Binary", "anyURI", "QName", "NOTATION", "normalizedString",
+            "token", "language", "NMTOKEN", "NMTOKENS", "Name", "NCName", "ID",
+            "IDREF", "IDREFS", "ENTITY", "ENTITIES", "integer",
+            "nonPositiveInteger", "negativeInteger", "long", "int", "short",
+            "byte", "nonNegativeInteger", "unsignedLong", "unsignedInt",
+            "unsignedShort", "unsignedByte", "positiveInteger" };
+
+    {
+        Arrays.sort(XSD_TYPES);
+    }
+
+    private CmBaseWriter cmbase;
+
+    private CmExtensionsWriter cmextensions;
+
+    private CmRpcWriter cmrpc;
+
+    private CmHttpWriter cmhttp;
+
+    private CmSoapWriter cmsoap;
+
+    public CmWriter(XMLWriter out) {
+
+        super(out, NS, PREFIX);
+
+        cmbase = (CmBaseWriter) out.lookup(CmBaseWriter.NS);
+        cmextensions = (CmExtensionsWriter) out.lookup(CmExtensionsWriter.NS);
+        cmrpc = (CmRpcWriter) out.lookup(CmRpcWriter.NS);
+        cmhttp = (CmHttpWriter) out.lookup(CmHttpWriter.NS);
+        cmsoap = (CmSoapWriter) out.lookup(CmSoapWriter.NS);
+    }
+
+    /**
+     * Writes the component model.
+     * 
+     * @param component the root Description component
+     */
+    public void write(Description component) {
+
+        out.xmlDeclaration("UTF-8");
+
+        String attributes = "xmlns='" + NS + "'\n";
+        attributes += " xmlns:" + CmExtensionsWriter.PREFIX + "='"
+                + CmExtensionsWriter.NS + "'\n";
+        attributes += " xmlns:" + CmBaseWriter.PREFIX + "='" + CmBaseWriter.NS
+                + "'\n";
+        attributes += " xmlns:" + CmHttpWriter.PREFIX + "='" + CmHttpWriter.NS
+                + "'\n";
+        attributes += " xmlns:" + CmRpcWriter.PREFIX + "='" + CmRpcWriter.NS
+                + "'\n";
+        attributes += " xmlns:" + CmSoapWriter.PREFIX + "='" + CmSoapWriter.NS
+                + "'\n";
+        attributes += cmbase.idAttribute(component);
+        out.beginElement("descriptionComponent", attributes);
+
+        URI[] extensions = { WSDLExtensionConstants.NS_URI_WSDL_EXTENSIONS,
+                HTTPConstants.NS_URI_HTTP,
+                RPCConstants.NS_URI_RPC, SOAPConstants.NS_URI_SOAP };
+
+        cmbase.writeUris("extensions", extensions);
+        write("interfaces", component.getInterfaces());
+        write("bindings", component.getBindings());
+        write("services", component.getServices());
+        write("elementDeclarations", component.getElementDeclarations());
+        write("typeDefinitions", component.getTypeDefinitions());
+
+        out.endElement();
+    }
+
+    private void writeRefs(String tag, Interface[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((Interface) o1).getName();
+                QName x2 = ((Interface) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++) {
+            cmbase.writeRef("interface", components[i]);
+        }
+
+        out.endElement();
+
+    }
+
+    private void write(String tag, Interface[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((Interface) o1).getName();
+                QName x2 = ((Interface) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("interfaceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, Interface component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        writeRefs("extendedInterfaces", component.getExtendedInterfaces());
+        write("interfaceFaults", component.getInterfaceFaults());
+        write("interfaceOperations", component.getInterfaceOperations());
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceFault[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((InterfaceFault) o1).getName();
+                QName x2 = ((InterfaceFault) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("interfaceFaultComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceFault component) {
+
+        out.beginElement("interfaceFaultComponent", cmbase
+                .idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        out.write("messageContentModel", component.getMessageContentModel());
+        cmbase.writeOptionalRef("elementDeclaration", component
+                .getElementDeclaration());
+        cmbase.parent(component.getParent());
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceOperation[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((InterfaceOperation) o1).getName();
+                QName x2 = ((InterfaceOperation) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("interfaceOperationComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceOperation component) {
+
+        out.beginElement("interfaceOperationComponent", cmbase
+                .idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        write("messageExchangePattern", component.getMessageExchangePattern());
+        write("interfaceMessageReferences", component
+                .getInterfaceMessageReferences());
+        write("interfaceFaultReferences", component
+                .getInterfaceFaultReferences());
+        cmbase.writeUris("style", component.getStyle());
+        cmbase.parent(component.getParent());
+
+        InterfaceOperationExtensions extensions = (InterfaceOperationExtensions) component
+                .getComponentExtensionContext(WSDLExtensionConstants.NS_URI_WSDL_EXTENSIONS);
+        cmextensions.wsdlInterfaceOperationExtension(extensions);
+
+        RPCInterfaceOperationExtensions rpcExtensions = (RPCInterfaceOperationExtensions) component
+                .getComponentExtensionContext(RPCConstants.NS_URI_RPC);
+        cmrpc.rpcInterfaceOperationExtension(rpcExtensions);
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceMessageReference[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                String x1 = ((InterfaceMessageReference) o1).getMessageLabel()
+                        .toString();
+                String x2 = ((InterfaceMessageReference) o2).getMessageLabel()
+                        .toString();
+                return x1.compareTo(x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("interfaceMessageReferenceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceMessageReference component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        out.write("messageLabel", component.getMessageLabel().toString());
+        out.write("direction", component.getDirection().toString());
+        out.write("messageContentModel", component.getMessageContentModel());
+        cmbase.writeOptionalRef("elementDeclaration", component
+                .getElementDeclaration());
+        cmbase.parent(component.getParent());
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceFaultReference[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+
+                InterfaceFaultReference i1 = (InterfaceFaultReference) o1;
+                InterfaceFaultReference i2 = (InterfaceFaultReference) o2;
+
+                InterfaceFault if1 = i1.getInterfaceFault();
+                InterfaceFault if2 = i2.getInterfaceFault();
+
+                if (if1 == if2)
+                    return 0;
+                if (if1 == null)
+                    return -1;
+                if (if2 == null)
+                    return 1;
+
+                QName q1 = if1.getName();
+                QName q2 = if2.getName();
+
+                int result = CmBaseWriter.compareQName(q1, q2);
+                if (result != 0)
+                    return result;
+
+                String x1 = i1.getMessageLabel().toString();
+                String x2 = i2.getMessageLabel().toString();
+                return x1.compareTo(x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("interfaceFaultReferenceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, InterfaceFaultReference component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.writeRef("interfaceFault", component.getInterfaceFault());
+        out.write("messageLabel", component.getMessageLabel().toString());
+        out.write("direction", component.getDirection().toString());
+        cmbase.parent(component.getParent());
+
+        out.endElement();
+    }
+
+    private void write(String tag, Binding[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((Binding) o1).getName();
+                QName x2 = ((Binding) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("bindingComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, Binding component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        cmbase.writeOptionalRef("interface", component.getInterface());
+        write("type", component.getType());
+        write("bindingFaults", component.getBindingFaults());
+        write("bindingOperations", component.getBindingOperations());
+
+        HTTPBindingExtensions http = (HTTPBindingExtensions) component
+                .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP);
+        cmhttp.httpBindingExtension(http);
+
+        SOAPBindingExtensions soap = (SOAPBindingExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapBindingExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingFault[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+
+                InterfaceFault if1 = ((BindingFault) o1).getInterfaceFault();
+                InterfaceFault if2 = ((BindingFault) o2).getInterfaceFault();
+
+                if (if1 == if2)
+                    return 0;
+                if (if1 == null)
+                    return -1;
+                if (if2 == null)
+                    return 1;
+
+                QName x1 = if1.getName();
+                QName x2 = if2.getName();
+
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("bindingFaultComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingFault component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.writeRef("interfaceFault", component.getInterfaceFault());
+        cmbase.parent(component.getParent());
+
+        HTTPBindingFaultExtensions http = (HTTPBindingFaultExtensions) component
+                .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP);
+        cmhttp.httpBindingFaultExtension(http);
+
+        SOAPBindingFaultExtensions soap = (SOAPBindingFaultExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapBindingFaultExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingOperation[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((BindingOperation) o1).getInterfaceOperation()
+                        .getName();
+                QName x2 = ((BindingOperation) o1).getInterfaceOperation()
+                        .getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("bindingOperationComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingOperation component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase
+                .writeRef("interfaceOperation", component
+                        .getInterfaceOperation());
+        write("bindingMessageReferences", component
+                .getBindingMessageReferences());
+        write("bindingFaultReferences", component.getBindingFaultReferences());
+        cmbase.parent(component.getParent());
+
+        HTTPBindingOperationExtensions http = (HTTPBindingOperationExtensions) component
+                .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP);
+        cmhttp.httpBindingOperationExtension(http);
+
+        SOAPBindingOperationExtensions soap = (SOAPBindingOperationExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapBindingOperationExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingMessageReference[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+
+                InterfaceMessageReference i1 = ((BindingMessageReference) o1)
+                        .getInterfaceMessageReference();
+                InterfaceMessageReference i2 = ((BindingMessageReference) o2)
+                        .getInterfaceMessageReference();
+
+                String x1 = i1.getMessageLabel().toString();
+                String x2 = i2.getMessageLabel().toString();
+                return x1.compareTo(x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("bindingMessageReferenceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingMessageReference component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.writeRef("interfaceMessageReference", component
+                .getInterfaceMessageReference());
+
+        cmbase.parent(component.getParent());
+
+        HTTPBindingMessageReferenceExtensions http = (HTTPBindingMessageReferenceExtensions) component
+                .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP);
+        cmhttp.httpBindingMessageReferenceExtension(http);
+
+        SOAPBindingMessageReferenceExtensions soap = (SOAPBindingMessageReferenceExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapBindingMessageReferenceExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingFaultReference[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+
+                InterfaceFaultReference i1 = ((BindingFaultReference) o1)
+                        .getInterfaceFaultReference();
+                InterfaceFaultReference i2 = ((BindingFaultReference) o2)
+                        .getInterfaceFaultReference();
+
+                QName q1 = i1.getInterfaceFault().getName();
+                QName q2 = i2.getInterfaceFault().getName();
+
+                int result = CmBaseWriter.compareQName(q1, q2);
+                if (result != 0)
+                    return result;
+
+                String x1 = i1.getMessageLabel().toString();
+                String x2 = i2.getMessageLabel().toString();
+                return x1.compareTo(x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("bindingFaultReferenceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, BindingFaultReference component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.writeRef("interfaceFaultReference", component
+                .getInterfaceFaultReference());
+        cmbase.parent(component.getParent());
+
+        SOAPBindingFaultReferenceExtensions soap = (SOAPBindingFaultReferenceExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapBindingFaultReferenceExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, Service[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((Service) o1).getName();
+                QName x2 = ((Service) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("serviceComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, Service component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        cmbase.writeRef("interface", component.getInterface());
+        write("endpoints", component.getEndpoints());
+
+        out.endElement();
+    }
+
+    private void write(String tag, Endpoint[] components) {
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                String x1 = ((Endpoint) o1).getName().toString();
+                String x2 = ((Endpoint) o2).getName().toString();
+                return x1.compareTo(x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++) {
+            write("endpointComponent", components[i]);
+        }
+
+        out.endElement();
+
+    }
+
+    private void write(String tag, Endpoint component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        out.write("name", component.getName());
+        cmbase.writeRef("binding", component.getBinding());
+        cmbase.write("address", component.getAddress());
+        cmbase.parent(component.getParent());
+
+        HTTPEndpointExtensions http = (HTTPEndpointExtensions) component
+                .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP);
+        cmhttp.httpEndpointExtension(http);
+
+        SOAPEndpointExtensions soap = (SOAPEndpointExtensions) component
+                .getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+        cmsoap.soapEndpointExtension(soap);
+
+        out.endElement();
+    }
+
+    private void write(String tag, ElementDeclaration[] components) {
+
+        // filter out the XSD elements until Woden fixes the bug
+        Vector filteredElements = new Vector();
+        for (int i = 0; i < components.length; i++) {
+            if (!XSD_NS.equals(components[i].getName().getNamespaceURI()))
+                filteredElements.addElement(components[i]);
+        }
+        components = new ElementDeclaration[filteredElements.size()];
+        filteredElements.copyInto(components);
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((ElementDeclaration) o1).getName();
+                QName x2 = ((ElementDeclaration) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("elementDeclarationComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, ElementDeclaration component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        write("system", component.getSystem());
+
+        out.endElement();
+    }
+
+    private void write(String tag, TypeDefinition[] components) {
+
+        // filter out the XSD non-built-in types until Woden fixes the bug
+        Vector filteredTypes = new Vector();
+        for (int i = 0; i < components.length; i++) {
+            if (!XSD_NS.equals(components[i].getName().getNamespaceURI())) {
+                filteredTypes.addElement(components[i]);
+            } else {
+                if (Arrays.binarySearch(XSD_TYPES, components[i].getName()
+                        .getLocalPart()) >= 0)
+                    filteredTypes.addElement(components[i]);
+            }
+        }
+        components = new TypeDefinition[filteredTypes.size()];
+        filteredTypes.copyInto(components);
+
+        if (components.length == 0)
+            return;
+
+        Arrays.sort(components, new Comparator() {
+
+            public int compare(Object o1, Object o2) {
+                QName x1 = ((TypeDefinition) o1).getName();
+                QName x2 = ((TypeDefinition) o2).getName();
+                return CmBaseWriter.compareQName(x1, x2);
+            }
+        });
+
+        out.beginElement(tag);
+
+        for (int i = 0; i < components.length; i++)
+            write("typeDefinitionComponent", components[i]);
+
+        out.endElement();
+    }
+
+    private void write(String tag, TypeDefinition component) {
+
+        out.beginElement(tag, cmbase.idAttribute(component));
+
+        cmbase.write("name", component.getName());
+        write("system", component.getSystem());
+
+        out.endElement();
+    }
+
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/NamespaceWriter.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/NamespaceWriter.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/NamespaceWriter.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/NamespaceWriter.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.net.URI;
+
+/**
+ * This is the abstract base class for classes that write elements and types from an XML namespace;
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public abstract class NamespaceWriter {
+    
+    protected XMLWriter out;
+    
+    private String namespace;
+    
+    private String prefix;
+    
+    public NamespaceWriter(XMLWriter out, String namespace, String prefix) {
+        
+        this.out = out;
+        this.namespace = namespace;
+        this.prefix = prefix;
+        
+        out.register(this);
+    }
+    
+    public String getNamespace() {
+        
+        return namespace;
+    }
+    
+    public String getPrefix() {
+        
+        return prefix;
+    }
+    
+    public void write(String tag, URI uri) {
+
+        if (uri == null)
+            return;
+
+        out.element(tag, uri.toString());
+    }
+
+    public void writeAny(String tag, Object o) {
+
+        if (o == null)
+            return;
+
+        // TODO: write element content correctly
+        out.element(tag, o.toString());
+    }
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ObjectIdTable.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ObjectIdTable.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ObjectIdTable.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ObjectIdTable.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.util.HashMap;
+
+/**
+ * Provides a completely safe way to generate unique ids for equivalence classes of objects.
+ * Equivalent objects are assigned the same ids.
+ * Inequivalent objects are assigned different ids.
+ * Here equivalance is defined by the equals() method which is used by HashMap.
+ * Experience has shown that hashCode() occasionally produces the same hash for different objects.
+ * Note that the objects are permanently stored, so only use this class when serializing
+ * objects in an XML file.
+ * 
+ * A count is kept and assigned to each object equivalence class as it is added.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+
+public class ObjectIdTable {
+
+    private HashMap components = new HashMap();
+
+    private int nextId = 1;
+
+    /**
+     * Returns a unique integer for the equivalence class of the object.
+     * 
+     * @param o An object.
+     * @return A unique id for the object.
+     */
+    public int id(Object o) {
+
+        Integer id = (Integer) components.get(o);
+        if (id == null) {
+
+            id = new Integer(nextId++);
+            components.put(o, id);
+        }
+
+        return id.intValue();
+    }
+
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/Report.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/Report.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/Report.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/Report.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,233 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.Vector;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.ErrorInfo;
+import org.apache.woden.ErrorLocator;
+
+/**
+ * The <code>Report</code> class writes an XML file that reports the results of validating a set of WSDL files.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public class Report extends XMLWriter implements ErrorHandler {
+    
+    private final String NS = "http://www.w3.org/2006/06/wsdl/ValidationReport";
+
+    private final String REPORT = "report";
+
+    private final String WSDL = "wsdl";
+
+    private final String URI = "uri";
+    
+    private final String SUCCESS = "success";
+
+    // ErrorHandler elements
+
+    private final String WARNING = "warning";
+
+    private final String ERROR = "error";
+
+    private final String FATAL_ERROR = "fatalError";
+
+    // ErrorInfo elements
+
+    private final String ERROR_LOCATOR = "errorLocator";
+
+    private final String KEY = "key";
+
+    private final String MESSAGE = "message";
+
+    private final String EXCEPTION = "exception";
+
+    // ErrorLocator elements
+
+    private final String DOCUMENT_BASE_URI = "documentBaseUri";
+
+    private final String LOCATION_URI = "locationUri";
+
+    private final String LINE_NUMBER = "lineNumber";
+
+    private final String COLUMN_NUMBER = "columnNumber";
+
+    // Exception element
+
+    private final String DETAIL_MESSAGE = "detailMessage";
+    
+    
+    // error handler data
+    private boolean success = true;
+    private Vector errorInfos = null;
+    private Vector severities = null;
+
+    /**
+     * Creates a report writer and writes the document root.
+     * 
+     * @param report the reort file
+     * @return the report writer
+     */
+    public static Report openReport(File report) {
+
+        if (report == null) {
+
+            return new Report(null);
+        }
+
+        FileOutputStream fos;
+        try {
+            fos = new FileOutputStream(report);
+        } catch (FileNotFoundException e) {
+
+            e.printStackTrace();
+
+            return new Report(null);
+        }
+
+        PrintWriter reportOut = new PrintWriter(fos);
+        Report reportWriter = new Report(reportOut);
+        reportWriter.xmlDeclaration("UTF-8");
+        reportWriter.beginReport();
+
+        return reportWriter;
+    }
+
+    /**
+     * Ends the report and closes the output writer.
+     */
+    public void closeReport() {
+
+        endReport();
+        close();
+    }
+
+    /**
+     * Constructs a <code>Report</code> writer.
+     * 
+     * @param out the output writer or null
+     */
+    public Report(PrintWriter out) {
+        super(out);
+    }
+
+    public void beginReport() {
+        beginElement(REPORT, "xmlns='" + NS + "'");
+    }
+
+    public void endReport() {
+        endAllElements();
+    }
+
+    public void beginWsdl(String uri) {
+        
+        success = true;
+        errorInfos = new Vector();
+        severities = new Vector();
+        
+        beginElement(WSDL);
+
+        element(URI, uri);
+    }
+
+    public void endWsdl() {
+        
+        write(SUCCESS, success);
+        
+        for(int i = 0; i < errorInfos.size(); i ++) {
+            
+            ErrorInfo errorInfo = (ErrorInfo) errorInfos.elementAt(i);
+            String severity = (String) severities.elementAt(i);
+            
+            write(severity, errorInfo);
+        }
+        
+        endElement();
+        
+        success = true;
+        errorInfos = null;
+        severities = null;
+    }
+
+    public void warning(ErrorInfo errorInfo) {
+        
+        errorInfos.add(errorInfo);
+        severities.add(WARNING);
+    }
+
+    public void error(ErrorInfo errorInfo) {
+
+        success = false;
+        errorInfos.add(errorInfo);
+        severities.add(ERROR);
+    }
+
+    public void fatalError(ErrorInfo errorInfo) {
+
+        success = false;
+        errorInfos.add(errorInfo);
+        severities.add(FATAL_ERROR);
+    }
+
+    public void write(String tag, ErrorInfo errorInfo) {
+
+        if (errorInfo == null)
+            return;
+
+        beginElement(tag);
+
+        write(ERROR_LOCATOR, errorInfo.getErrorLocator());
+        element(KEY, errorInfo.getKey());
+        element(MESSAGE, errorInfo.getMessage());
+        write(EXCEPTION, errorInfo.getException());
+
+        endElement();
+    }
+
+    public void write(String tag, ErrorLocator errorLocator) {
+
+        if (errorLocator == null)
+            return;
+
+        beginElement(tag);
+
+        write(DOCUMENT_BASE_URI, errorLocator.getDocumentBaseURI());
+        write(LOCATION_URI, errorLocator.getLocationURI());
+        write(LINE_NUMBER, errorLocator.getLineNumber());
+        write(COLUMN_NUMBER, errorLocator.getColumnNumber());
+
+        endElement();
+    }
+
+    public void write(String tag, Exception e) {
+
+        if (e == null)
+            return;
+
+        beginElement(tag);
+
+        write(DETAIL_MESSAGE, e.getMessage());
+
+        endElement();
+    }
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ValidateWSDL20.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ValidateWSDL20.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ValidateWSDL20.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/ValidateWSDL20.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,483 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.TypeDefinition;
+
+/**
+ * This is an Ant task to validate WSDL 2.0 files.
+ * 
+ * Parameters: The <code>dir</code> attribute is a file directory for the
+ * fileset of WSDL 2.0 files to validate. You specify files in include and
+ * exclude using the usual Ant attributes and elements.
+ * 
+ * The <code>failonerror</code> attribute is a boolean flag with the usual
+ * meaning.
+ * 
+ * The <code>verbose</code> attribute is a boolean flag that enables verbose
+ * output.
+ * 
+ * The <code>cm</code> attribute is a boolean flag that enables Component
+ * Model interchange format output</code>. The default is false.
+ * 
+ * The <code>cmdir</code> attribute is a file directory for the Component
+ * Model interchange format output files. This is ignored if <code>cm</code>
+ * is false. The default is to use the input directory as specified by the
+ * <code>dir</code> attribute.
+ * 
+ * The <code>cmext</code> attribute is the file extension to use for the
+ * Component Model interchange format output files. This is ignored if <code>cm</code>
+ * is false. The default is <code>.wsdlcm</code>.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com)
+ * 
+ * TODO: add support writing out failed assertions in XML
+ * 
+ */
+
+public class ValidateWSDL20 extends MatchingTask {
+
+    // directory for fileset
+    private File dir;
+
+    // flag to enable failonerror
+    private boolean failOnError = false;
+
+    // flag to enable verbose output
+    private boolean verbose = false;
+
+    // flag to enable Component Model interchange format output
+    private boolean cm = false;
+
+    // directory for Component Model interchange format output
+    private File cmdir;
+
+    // extension for Component Model interchange format output
+    private String cmext;
+
+    // report output file 
+    private File report;
+
+    // report writer
+    private Report reportWriter;
+
+    // resolver catalog location
+    private String catalog;
+    
+    // base URI for the catalog
+    private String baseURI;
+
+    // implementation name.
+    private String implName;
+    
+    // default extension for Component Model interchange format output
+    private static final String CMEXT_DEFAULT = ".wsdlcm";
+
+    /**
+     * Gets the input WSDL fileset directory.
+     * 
+     * @return the directory
+     */
+    public File getDir() {
+        return this.dir;
+    }
+
+    /**
+     * Sets the input WSDL fileset directory.
+     * 
+     * @param dir the directory
+     */
+    public void setDir(File dir) {
+        this.dir = dir;
+    }
+
+    /**
+     * Enables fail on error behavior.
+     * 
+     * @param failOnError the flag
+     */
+    public void setFailOnError(boolean failOnError) {
+        this.failOnError = failOnError;
+    }
+
+    /**
+     * Tests for fail on error behavior.
+     * 
+     * @return the flag
+     */
+    public boolean isFailOnError() {
+        return failOnError;
+    }
+
+    /**
+     * Enables verbose console output.
+     * 
+     * @param verbose the flag
+     */
+    public void setVerbose(boolean verbose) {
+        this.verbose = verbose;
+    }
+
+    /**
+     * Tests for verbose console output.
+     * 
+     * @return the flag
+     */
+    public boolean isVerbose() {
+        return verbose;
+    }
+
+    /**
+     * Enables component model interchange format output.
+     * 
+     * @param cm the flag
+     */
+    public void setCm(boolean cm) {
+        this.cm = cm;
+    }
+
+    /**
+     * Tests for component model interchange formal output.
+     * 
+     * @return the flag
+     */
+    public boolean isCm() {
+        return cm;
+    }
+
+    /**
+     * Sets the directory for component model interchange formal output.
+     *  
+     * @param cmdir the directory
+     */
+    public void setCmdir(File cmdir) {
+        this.cmdir = cmdir;
+    }
+
+    /**
+     * Gets the directory for component model interchange formal output.
+     * 
+     * @return the directory
+     */
+    public File getCmdir() {
+        return cmdir;
+    }
+
+    /**
+     * Sets the component model interchange format file extension.
+     * 
+     * @param cmext the extension
+     */
+    public void setCmext(String cmext) {
+        this.cmext = cmext;
+    }
+
+    /**
+     * Gets the component model interchange format file extension.
+     * 
+     * @return the extension
+     */
+    public String getCmext() {
+        return cmext;
+    }
+
+    /**
+     * Gets the output report file.
+     * 
+     * @return the file
+     */
+    public File getReport() {
+        return this.report;
+    }
+
+    /**
+     * Sets the output report file.
+     * 
+     * @param report the file
+     */
+    public void setReport(File report) {
+        this.report = report;
+    }
+
+    
+    /**
+     * Sets the implementation name to test against.
+     * 
+     * @param implName The name of the implementation.
+     */
+    public void setImplName(String implName) {
+       this.implName = implName;
+    }
+    
+
+    public void execute() throws BuildException {
+
+        // check the cm input attributes and set defaults if necessary
+        if (isCm()) {
+            File cmdir = getCmdir();
+            if (cmdir == null) {
+
+                // default cmdir to dir
+                cmdir = getDir();
+                setCmdir(cmdir);
+            }
+
+            if (!cmdir.isDirectory()) {
+
+                // cmdir MUST be a directory
+                System.out.println("Invalid cm output directory: "
+                        + cmdir.toString());
+
+                // disable cm output
+                setCm(false);
+            }
+
+            String cmext = getCmext();
+            if (cmext == null) {
+
+                // default cmext
+                setCmext(CMEXT_DEFAULT);
+            }
+        }
+
+        WSDLReader reader = null;
+
+        // create a reader (with specified implementation if given).
+        try {
+           //If an implementation name is given use that to test against, else use the default one.
+           if (implName != null && !implName.equals("")) {
+               System.out.println("Using woden with implementation from " + implName);
+               WSDLFactory factory = WSDLFactory.newInstance(implName);
+               reader = factory.newWSDLReader();
+           } else {
+               System.out.println("Using default woden implementation.");
+               WSDLFactory factory = WSDLFactory.newInstance();
+               reader = factory.newWSDLReader();
+           }
+
+        } catch (WSDLException e) {
+
+            // fail if unable to create a reader
+            throw new BuildException(e);
+        }
+
+        // set the features but continue even if they are not supported yet
+        try {
+            // always enable WSDL 2.0 validation since this is a validation task
+            reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
+
+            // enable verbose output
+            reader.setFeature(WSDLReader.FEATURE_VERBOSE, isVerbose());
+
+            // enable continue on error (opposite of fail on error)
+            reader.setFeature(WSDLReader.FEATURE_CONTINUE_ON_ERROR,
+                    !isFailOnError());
+        } catch (IllegalArgumentException e) {
+            System.out.println("warning: " + e.getMessage());
+        }
+
+        if (isVerbose()) {
+            System.out.println("File dir = " + dir.getAbsolutePath());
+
+            Project project = getProject();
+            File baseDir = project.getBaseDir();
+            System.out.println("File baseDir = " + baseDir.getAbsolutePath());
+        }
+
+        DirectoryScanner directoryScanner = getDirectoryScanner(dir);
+        String[] files = directoryScanner.getIncludedFiles();
+
+        reportWriter = Report.openReport(report);
+        reader.getErrorReporter().setErrorHandler(reportWriter);
+        
+        // use the same reader for all the WSDL files
+        for (int i = 0; i < files.length; i++) {
+
+            File file = new File(dir, files[i]);
+
+            // make a URL for the file
+            String wsdlLoc = file.toURI().toString();
+            System.out.println("validating " + wsdlLoc);
+
+            reportWriter.beginWsdl(wsdlLoc);
+            try {
+                // <-- the Description component
+                Description descComp = reader.readWSDL(wsdlLoc);
+
+                if (isCm()) {
+                    // write the Component Model interchange format output file
+                    writeCm(descComp, files[i]);
+                }
+
+                if (isVerbose()) {
+
+                    writeVerbose(descComp);
+                }
+
+            } catch (Exception e) {
+               //The test may still pass if there is an exception here.
+                if (isFailOnError()) {
+
+                    reportWriter.endWsdl();
+                    reportWriter.closeReport();
+                    throw new BuildException(e);
+                }
+            }
+            reportWriter.endWsdl();
+        }
+        reportWriter.closeReport();
+    }
+
+    private void writeVerbose(Description descComp) {
+        ElementDeclaration elementDeclarations[] = descComp
+                .getElementDeclarations();
+        System.out.println("There are " + elementDeclarations.length
+                + " ElementDeclaration components.");
+
+        for (int j = 0; j < elementDeclarations.length; j++) {
+
+            ElementDeclaration elementDeclaration = elementDeclarations[j];
+
+            QName name = elementDeclaration.getName();
+            System.out
+                    .println("ElementDeclaration[" + j + "] : name = " + name);
+        }
+
+        TypeDefinition typeDefinitions[] = descComp.getTypeDefinitions();
+        System.out.println("There are " + typeDefinitions.length
+                + " TypeDefinition components.");
+
+        for (int j = 0; j < typeDefinitions.length; j++) {
+            TypeDefinition typeDefinition = typeDefinitions[j];
+
+            QName name = typeDefinition.getName();
+            System.out.println("TypeDefinition[" + j + "] : name = " + name);
+        }
+
+        Interface interfaces[] = descComp.getInterfaces();
+        System.out.println("There are " + interfaces.length
+                + " Interface components.");
+
+        for (int j = 0; j < interfaces.length; j++) {
+
+            System.out.println("Interface[" + j + "] : name = "
+                    + interfaces[j].getName());
+        }
+
+        Binding bindings[] = descComp.getBindings();
+        System.out.println("There are " + bindings.length
+                + " Binding components.");
+
+        for (int j = 0; j < bindings.length; j++) {
+
+            System.out.println("Binding[" + j + "] : name = "
+                    + bindings[j].getName());
+        }
+
+        Service services[] = descComp.getServices();
+        System.out.println("There are " + services.length
+                + " Service components.");
+
+        for (int j = 0; j < services.length; j++) {
+
+            System.out.println("Service[" + j + "] : name = "
+                    + services[j].getName());
+        }
+    }
+
+    private void writeCm(Description descComp, String file) throws IOException {
+
+        // replace the file extension
+
+        int dot = file.lastIndexOf('.');
+        String base = dot == -1 ? file : file.substring(0, dot);
+        String ext = getCmext();
+        String cmfilename = base + ext;
+        File cmfile = new File(cmdir, cmfilename);
+        File parent = cmfile.getParentFile();
+        if (parent != null) {
+            if (!parent.exists()) {
+                boolean created = parent.mkdirs();
+                if (!created) {
+                    System.out.println("Unable to create directory: "
+                            + parent.toString());
+                }
+            }
+        }
+
+        FileOutputStream fos = new FileOutputStream(cmfile);
+        PrintWriter out = new PrintWriter(fos);
+        WsdlCm wsdlCm = new WsdlCm(out);
+        wsdlCm.write(descComp);
+        out.close();
+        fos.close();
+    }
+    
+    /**
+     * Sets the resolver catalog file.
+     * 
+     * @param catalog resolver catalog file URI
+     */
+    public void setCatalog(String catalog) {
+        this.catalog = getURLFilePath(catalog);
+        System.setProperty("org.apache.woden.resolver.simpleresolver.catalog", this.catalog);
+    }
+    
+    /**
+     * Sets the resolver base URI path.
+     * 
+     * @param baseURI base URI path
+     */
+    public void setBaseURI(String baseURI) {
+        this.baseURI = getURLFilePath(baseURI);
+        System.setProperty("org.apache.woden.resolver.simpleresolver.baseURIs", this.baseURI);
+    }
+    
+    private String getURLFilePath(String localPath) {
+        File localFile = new File(localPath);
+        if (localFile.exists()) {
+            try {
+                return localFile.toURI().toURL().toString();
+            } catch (MalformedURLException mue) {
+                System.err.println("Got MalformedURLException trying to create a URL from " + localPath);
+                return localPath;
+            }
+        } else {
+            return localPath;
+        }
+    }
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/WsdlCm.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/WsdlCm.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/WsdlCm.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/WsdlCm.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+/**
+ * This class writes a Woden WSDL 2.0 component model instance in the W3C
+ * interchange format which is an XML vocabulary for serializing component model
+ * instances in a canonical way so that different implementations can be easily
+ * compared for interoperability.
+ * 
+ * The latest schema for this format is available at the following URL:
+ * 
+ * http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/interchange/wsdlcm.xsd?content-type=text/xml
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur-ryman@gmail.com)
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.wsdl20.Description;
+
+/**
+ * The <code>WsdlCm</code> class writes the component model in the W3C interchange format.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur-ryman@gmail.com)
+ *
+ */
+public class WsdlCm extends XMLWriter {
+
+    private CmWriter cm;
+
+    /**
+     * Constructs a component model writer.
+     * 
+     * @param out the output writer for the component model
+     */
+    public WsdlCm(PrintWriter out) {
+        super(out);
+
+        // create the writes for each namespace
+        new CmBaseWriter(this);
+        new CmExtensionsWriter(this);
+        new CmRpcWriter(this);
+        new CmHttpWriter(this);
+        new CmSoapWriter(this);
+        cm = new CmWriter(this);
+    }
+
+    /**
+     * Writes the Description component in the component model interchange format.
+     * 
+     * @param descComp the Description component
+     */
+    public void write(Description descComp) {
+
+        cm.write(descComp);
+    }
+
+    /**
+     * Tests the component model interchange format writer.
+     * 
+     * TODO Move this method into a tests package.
+     * 
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+
+        // simple program to read a WSDL 2.0 file and then poke at the component
+        // model.
+
+        String wsdlLoc = "file:///D:/workspaces/WSD2/woden/ant-test/test.wsdl";
+        String wsdlCmLoc = "D:\\workspaces\\WSD2\\woden\\ant-test\\test.xml";
+        String reportLoc = "D:\\workspaces\\WSD2\\woden\\ant-test\\report.xml";
+
+        if (args.length > 0) {
+            wsdlLoc = args[0];
+        }
+
+        if (args.length > 1) {
+            wsdlCmLoc = args[1];
+        }
+
+        if (args.length > 2) {
+            reportLoc = args[2];
+        }
+
+        System.out.println("Starting: " + wsdlLoc);
+
+        Report reportWriter = Report.openReport(new File(reportLoc));
+        reportWriter.beginWsdl(wsdlLoc);
+
+        try {
+
+            WSDLFactory factory = WSDLFactory.newInstance();
+            WSDLReader reader = factory.newWSDLReader();
+
+            // <-- enable WSDL 2.0 validation (optional)
+            reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
+            
+            //Add errorHandler
+            reader.getErrorReporter().setErrorHandler(reportWriter);
+            
+            // <-- the Description component
+            Description descComp = reader.readWSDL(wsdlLoc);
+
+            File xml = new File(wsdlCmLoc);
+            FileOutputStream fos = new FileOutputStream(xml);
+            PrintWriter out = new PrintWriter(fos);
+            WsdlCm wsdlCm = new WsdlCm(out);
+
+            wsdlCm.write(descComp);
+
+            out.flush();
+
+        } catch (WSDLException e) {
+
+            e.printStackTrace();
+        } catch (FileNotFoundException e) {
+
+            e.printStackTrace();
+        } catch (RuntimeException e) {
+            
+            e.printStackTrace();
+        }
+
+        reportWriter.endWsdl();
+        reportWriter.closeReport();
+
+        System.out.println("Finished.");
+    }
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/XMLWriter.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/XMLWriter.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/XMLWriter.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/java/org/apache/woden/ant/XMLWriter.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,307 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Stack;
+
+import org.apache.woden.types.NCName;
+
+/**
+ * The <code>XMLWriter</code> class writes XML files.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public class XMLWriter {
+    
+    private HashMap registry = new HashMap();
+
+    private PrintWriter out;
+
+    private int indentation = 2;
+
+    private Stack tags = new Stack();
+
+    /**
+     * Constructs an XML writer.
+     * 
+     * @param out the output writer
+     */
+    public XMLWriter(PrintWriter out) {
+        this.out = out;
+    }
+
+    /**
+     * Closes the output writer.
+     */
+    public void close() {
+
+        if (out != null) {
+
+            out.close();
+        }
+    }
+
+    /**
+     * Writes the XML declaration.
+     * 
+     * @param encoding the character encoding or null
+     */
+    public void xmlDeclaration(String encoding) {
+
+        if (out == null)
+            return;
+
+        if (encoding == null) {
+            out.println("<?xml version='1.0'?>");
+        } else {
+            out.println("<?xml version='1.0' encoding='" + encoding + "'?>");
+        }
+    }
+
+    /**
+     * Writes the begin tag for an element.
+     * 
+     * @param tag the tag
+     */
+    public void beginElement(String tag) {
+
+        if (out == null)
+            return;
+
+        beginElement(tag, "");
+    }
+
+    /**
+     * Writes the begin tag for an element with attributes.
+     * 
+     * @param tag the tag
+     * @param attributes the attributes
+     */
+    public void beginElement(String tag, String attributes) {
+
+        if (out == null)
+            return;
+
+        indent();
+        if (attributes.length() == 0) {
+            out.println("<" + tag + ">");
+
+        } else {
+            out.println("<" + tag + " " + attributes + ">");
+        }
+        tags.push(tag);
+    }
+
+    /**
+     * Writes the end tag for the current element.
+     */
+    public void endElement() {
+
+        if (out == null)
+            return;
+
+        String tag = (String) tags.pop();
+        indent();
+        out.println("</" + tag + ">");
+    }
+
+    /**
+     * Write the end tag for all open elements. Call this to produce a well-formed document when execution ends prematurely.
+     */
+    public void endAllElements() {
+
+        while (!tags.empty()) {
+
+            endElement();
+        }
+    }
+
+    /**
+     * Writes an element with text content.
+     * 
+     * @param tag the tag
+     * @param content the content
+     */
+    public void element(String tag, String content) {
+
+        if (out == null)
+            return;
+
+        indent();
+        out.println("<" + tag + ">" + escape(content) + "</" + tag + ">");
+    }
+
+    /**
+     * Writes an empty element with attributes.
+     * 
+     * @param tag the tag
+     * @param attributes the attributes
+     */
+    public void emptyElement(String tag, String attributes) {
+
+        if (out == null)
+            return;
+
+        indent();
+        out.println("<" + tag + " " + attributes + "/>");
+    }
+
+    private void indent() {
+
+        if (out == null)
+            return;
+
+        for (int i = 0; i < tags.size(); i++) {
+            for (int j = 0; j < indentation; j++) {
+                out.write(' ');
+            }
+        }
+    }
+
+    /**
+     * Writes an NCName element if non-null.
+     * 
+     * @param tag the tag
+     * @param ncname the NCName object or null
+     */
+    public void write(String tag, NCName ncname) {
+
+        if (ncname == null)
+            return;
+
+        element(tag, ncname.toString());
+    }
+
+    /**
+     * Writes a String element if non-null.
+     * 
+     * @param tag the tag
+     * @param content the String object or null
+     */
+    public void write(String tag, String content) {
+
+        if (content == null)
+            return;
+
+        element(tag, content);
+    }
+
+    /**
+     * Writes a Boolean element if non-null.
+     * 
+     * @param tag the tag
+     * @param o the Boolean object or null
+     */
+    public void write(String tag, Boolean o) {
+
+        if (o == null)
+            return;
+
+        write(tag, o.booleanValue());
+    }
+
+    /**
+     * Writes a boolean element.
+     * 
+     * @param tag the tag
+     * @param value the boolean value
+     */
+    public void write(String tag, boolean value) {
+
+        element(tag, Boolean.toString(value));
+    }
+
+    /**
+     * Writes an int element.
+     * 
+     * @param tag the tag
+     * @param value the int value
+     */
+    public void write(String tag, int value) {
+
+        element(tag, Integer.toString(value));
+    }
+
+    /**
+     * Replaces the special XML characters a text string with their predefined entities.
+     * 
+     * @param x the text
+     * @return the escaped text
+     */
+    public static String escape(String x) {
+
+        if (x == null)
+            return null;
+
+        StringBuffer y = new StringBuffer();
+
+        for (int i = 0; i < x.length(); i++) {
+
+            char c = x.charAt(i);
+            switch (c) {
+            case '&':
+                y.append("&amp;");
+                break;
+
+            case '<':
+                y.append("&lt;");
+                break;
+
+            case '>':
+                y.append("&gt;");
+                break;
+
+            case '"':
+                y.append("&quot;");
+                break;
+
+            case '\'':
+                y.append("&apos;");
+                break;
+
+            default:
+                y.append(c);
+            }
+        }
+
+        return y.toString();
+    }
+    
+    /**
+     * Registers a namespace writer for this XML writer.
+     * 
+     * @param writer the namespace writer
+     */
+    public void register(NamespaceWriter writer) {
+        
+        registry.put(writer.getNamespace(), writer);
+    }
+    
+    /**
+     * Looks up a namespace writer for this XML writer.
+     * 
+     * @param namespace the namespace to look up
+     * @return the namespace writer
+     */
+    public NamespaceWriter lookup(String namespace) {
+        
+        return (NamespaceWriter) registry.get(namespace);
+    }
+}

Added: webservices/woden/trunk/java/woden-ant/src/main/resources/org/apache/woden/ant/about-this-package
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/main/resources/org/apache/woden/ant/about-this-package?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/main/resources/org/apache/woden/ant/about-this-package (added)
+++ webservices/woden/trunk/java/woden-ant/src/main/resources/org/apache/woden/ant/about-this-package Tue Sep  1 05:35:02 2009
@@ -0,0 +1 @@
+This package implements the validatewsdl20 Ant task for validating WSDL 2.0 files.
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-ant/src/test/java/org/apache/woden/ant/ObjectIdTableTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/src/test/java/org/apache/woden/ant/ObjectIdTableTest.java?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/src/test/java/org/apache/woden/ant/ObjectIdTableTest.java (added)
+++ webservices/woden/trunk/java/woden-ant/src/test/java/org/apache/woden/ant/ObjectIdTableTest.java Tue Sep  1 05:35:02 2009
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.ant;
+
+import org.apache.woden.ant.ObjectIdTable;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Tests ObjectIdTable.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public class ObjectIdTableTest extends TestCase {
+
+    /**
+     * Creates a test suite for this class.
+     * 
+     * @return the test suite
+     */
+    public static Test suite()
+    {
+        return new TestSuite(ObjectIdTableTest.class);
+    }
+    
+    /**
+     * Tests the id() method.
+     * Same objects have the same id.
+     * Different objects have different ids.
+     */
+    public void testId() {
+        
+        String s1 = "s1";
+        String s2 = "s2";
+        
+        ObjectIdTable oit = new ObjectIdTable();
+        
+        int id1 = oit.id(s1);
+        assertTrue("Same object, same id", id1 == oit.id(s1));
+        
+        int id2 = oit.id(s2);
+        assertTrue("Different object, different id", id1 != id2);
+        
+        assertTrue("Same object, same id, again", id2 == oit.id(s2));
+    }
+
+}

Added: webservices/woden/trunk/java/woden-ant/test-suite-results.zip
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/test-suite-results.zip?rev=809824&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/woden/trunk/java/woden-ant/test-suite-results.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/woden/trunk/java/woden-ant/test.wsdl
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-ant/test.wsdl?rev=809824&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-ant/test.wsdl (added)
+++ webservices/woden/trunk/java/woden-ant/test.wsdl Tue Sep  1 05:35:02 2009
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements.  See the NOTICE file distributed with
+ ! this work for additional information regarding copyright ownership.
+ ! The ASF licenses this file to You 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:description targetNamespace="http://example.org/name"
+	xmlns:name="http://example.org/name"
+	xmlns:wsdl="http://www.w3.org/2006/01/wsdl"
+	xmlns:wsoap="http://www.w3.org/2006/01/wsdl/soap"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.w3.org/2006/01/wsdl http://www.w3.org/2006/01/wsdl/wsdl20.xsd http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
+
+	<wsdl:documentation>
+		This test shows a valid use of an XML schema import.
+	</wsdl:documentation>
+
+	<wsdl:types>
+		<schema xmlns="http://www.w3.org/2001/XMLSchema"
+			targetNamespace="http://example.org/name"
+			xmlns:tns="http://example.org/name">
+
+			<element name="Name">
+				<complexType>
+					<sequence>
+						<element name="FirstName" type="string"></element>
+						<element name="LastName" type="string"></element>
+					</sequence>
+				</complexType>
+			</element>
+			<element name="SIN" type="string" />
+
+		</schema>
+	</wsdl:types>
+
+	<wsdl:interface name="NameInterface">
+		<wsdl:operation name="getNameFromSIN"
+			pattern="http://www.w3.org/2006/01/wsdl/in-out">
+			<wsdl:input element="name:SIN" />
+			<wsdl:output element="name:Name" />
+		</wsdl:operation>
+	</wsdl:interface>
+
+	<wsdl:binding name="NameBinding" interface="name:NameInterface"
+		type="http://www.w3.org/2006/01/wsdl/soap"
+		wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP">
+		<wsdl:operation ref="name:getNameFromSIN"
+			wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
+	</wsdl:binding>
+
+	<wsdl:service name="NameService" interface="name:NameInterface">
+		<wsdl:endpoint name="NameSOAPHTTPEndpoint"
+			binding="name:NameBinding" />
+	</wsdl:service>
+
+</wsdl:description>



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


Mime
View raw message