You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2007/04/11 18:09:46 UTC
Please review WSDL introspection code, Re: svn commit: r527397
Could somebody familiar with the Databinding framework and the DataType
support in particular review how I ported the WSDLIntrospector and
WSDLOperation to the new SPIs?
I had to remove some usage of generics since Operation<DataType> has
changed to Operation.
Also I am not sure if I am setting the inputType and outputType
correctly on the operation, in particular if the WSDL is a
doc-literal-wrapped style WSDL, do we need to unwrap the wrapper like I
did or not?
And finally how is the DataBinding field on an inputType used? is
DataBinding == "idl:input" correct?
Thanks...
jsdelfino@apache.org wrote:
> Author: jsdelfino
> Date: Tue Apr 10 23:26:26 2007
> New Revision: 527397
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=527397
> Log:
> Ported WSDL interface introspector to the latest SPIs and integrated it with the WSDLInterfaceProcessor.
>
> Added:
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java (with props)
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java (with props)
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java (with props)
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java (with props)
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java (with props)
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java (with props)
> Modified:
> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
> incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml
> incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,69 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +import javax.wsdl.PortType;
> +
> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
> +import org.apache.tuscany.interfacedef.Operation;
> +import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
> +import org.apache.tuscany.interfacedef.wsdl.impl.WSDLInterfaceImpl;
> +
> +/**
> + * Introspector for creating WSDLInterface definitions from WSDL PortTypes.
> + */
> +public class DefaultWSDLInterfaceIntrospector implements WSDLInterfaceIntrospector {
> +
> + private XMLSchemaRegistry schemaRegistry;
> +
> + public DefaultWSDLInterfaceIntrospector(XMLSchemaRegistry schemaRegistry) {
> + super();
> + this.schemaRegistry = schemaRegistry;
> + }
> +
> + // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS spec?
> + protected List<Operation> introspectOperations(PortType portType) throws InvalidInterfaceException {
> + List<Operation> operations = new ArrayList<Operation>();
> + for (Object op : portType.getOperations()) {
> + javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)op;
> + operations.add(introspectOperation(wsdlOp));
> + }
> + return operations;
> + }
> +
> + protected Operation introspectOperation(javax.wsdl.Operation wsdlOp) throws InvalidInterfaceException {
> +
> + WSDLOperation op = new WSDLOperation(wsdlOp, null, schemaRegistry);
> + return op.getOperation();
> + }
> +
> + public WSDLInterface introspect(PortType portType) throws InvalidInterfaceException {
> + WSDLInterface wsdlInterface = new WSDLInterfaceImpl();
> + wsdlInterface.setPortType(portType);
> + wsdlInterface.getOperations().addAll(introspectOperations(portType));
> + // FIXME: set to Non-conversational for now
> + wsdlInterface.setConversational(false);
> + return wsdlInterface;
> + }
> +
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,127 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import java.io.IOException;
> +import java.io.InputStream;
> +import java.io.InputStreamReader;
> +import java.net.URI;
> +import java.net.URISyntaxException;
> +import java.net.URL;
> +import java.util.ArrayList;
> +import java.util.Collections;
> +import java.util.List;
> +
> +import javax.wsdl.Definition;
> +import javax.wsdl.Types;
> +import javax.wsdl.extensions.schema.Schema;
> +import javax.xml.namespace.QName;
> +
> +import org.apache.ws.commons.schema.XmlSchema;
> +import org.apache.ws.commons.schema.XmlSchemaCollection;
> +import org.apache.ws.commons.schema.XmlSchemaElement;
> +import org.apache.ws.commons.schema.XmlSchemaException;
> +import org.apache.ws.commons.schema.XmlSchemaType;
> +import org.w3c.dom.Element;
> +
> +/**
> + * Default implementation of XMLSchemaRegistry
> + */
> +public class DefaultXMLSchemaRegistry implements XMLSchemaRegistry {
> + private final XmlSchemaCollection collection;
> +
> + /**
> + * @param collection
> + */
> + public DefaultXMLSchemaRegistry(XmlSchemaCollection collection) {
> + super();
> + this.collection = collection;
> + }
> +
> + public DefaultXMLSchemaRegistry() {
> + super();
> + this.collection = new XmlSchemaCollection();
> + }
> +
> + public XmlSchemaElement getElement(QName name) {
> + return collection.getElementByQName(name);
> + }
> +
> + public XmlSchemaType getType(QName name) {
> + return collection.getTypeByQName(name);
> + }
> +
> + public List<XmlSchema> loadSchemas(Definition definition) {
> + Types types = definition.getTypes();
> + if (types == null) {
> + return Collections.emptyList();
> + }
> + List<XmlSchema> schemas = new ArrayList<XmlSchema>();
> + for (Object ext : types.getExtensibilityElements()) {
> + if (ext instanceof Schema) {
> + Element element = ((Schema) ext).getElement();
> + XmlSchema s = collection.read(element, element.getBaseURI());
> + schemas.add(s);
> + }
> + }
> + return schemas;
> + }
> +
> + public XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException {
> + XmlSchema schema;
> + XmlSchema[] schemaList = collection.getXmlSchema(location.toExternalForm());
> + if (schemaList != null && schemaList.length > 0) {
> + schema = schemaList[0];
> + } else {
> + InputStream is = location.openStream();
> + schema = collection.read(new InputStreamReader(is), null);
> + is.close();
> + }
> + if (namespace != null && schema != null && !namespace.equals(schema.getTargetNamespace())) {
> + throw new XmlSchemaException(namespace + " != " + schema.getTargetNamespace());
> + }
> + return schema;
> + }
> +
> + public XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException {
> + int index = schemaLocation.indexOf(' ');
> + if (index == -1) {
> + throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
> + }
> + String namespace = schemaLocation.substring(0, index).trim();
> + URL url;
> + URI uri;
> + try {
> + uri = new URI(schemaLocation.substring(index + 1).trim());
> + } catch (URISyntaxException e) {
> + throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
> + }
> + if (uri.isAbsolute()) {
> + url = uri.toURL();
> + } else {
> + url = classLoader.getResource(uri.toString());
> + if (url == null) {
> + throw new XmlSchemaException("Resource cannot be resolved: schemaLocation: " + schemaLocation);
> + }
> + }
> + return loadSchema(namespace, url);
> + }
> +
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,35 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
> +
> +/**
> + * An exception to indicate the WSDL definition is invalid
> + *
> + * @version $Rev$ $Date$
> + */
> +public class InvalidWSDLException extends InvalidInterfaceException {
> + private static final long serialVersionUID = 3742887584293256519L;
> +
> + public InvalidWSDLException(String message) {
> + super(message);
> + }
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,41 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import javax.wsdl.PortType;
> +
> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
> +import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
> +
> +/**
> + * Introspector for creating WSDLInterface definitions from WSDL PortTypes.
> + *
> + * @version $Rev$ $Date$
> + */
> +public interface WSDLInterfaceIntrospector {
> +
> + /**
> + * Introspect a WSDL portType and return a WSDL interface definition.
> + *
> + * @param type the portType to inspect
> + * @return a WSDLInterface corresponding to the WSDL portType
> + */
> + WSDLInterface introspect(PortType portType) throws InvalidInterfaceException;
> +
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,517 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import java.util.ArrayList;
> +import java.util.Collection;
> +import java.util.Collections;
> +import java.util.List;
> +
> +import javax.wsdl.Fault;
> +import javax.wsdl.Input;
> +import javax.wsdl.Message;
> +import javax.wsdl.Output;
> +import javax.wsdl.Part;
> +import javax.xml.namespace.QName;
> +
> +import org.apache.tuscany.interfacedef.DataType;
> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
> +import org.apache.tuscany.interfacedef.Operation;
> +import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
> +import org.apache.tuscany.interfacedef.impl.OperationImpl;
> +import org.apache.tuscany.interfacedef.util.ElementInfo;
> +import org.apache.tuscany.interfacedef.util.FaultException;
> +import org.apache.tuscany.interfacedef.util.TypeInfo;
> +import org.apache.tuscany.interfacedef.util.WrapperInfo;
> +import org.apache.tuscany.interfacedef.util.XMLType;
> +import org.apache.ws.commons.schema.XmlSchemaComplexType;
> +import org.apache.ws.commons.schema.XmlSchemaElement;
> +import org.apache.ws.commons.schema.XmlSchemaObject;
> +import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
> +import org.apache.ws.commons.schema.XmlSchemaParticle;
> +import org.apache.ws.commons.schema.XmlSchemaSequence;
> +import org.apache.ws.commons.schema.XmlSchemaSimpleType;
> +import org.apache.ws.commons.schema.XmlSchemaType;
> +
> +/**
> + * Metadata for a WSDL operation
> + *
> + * @version $Rev$ $Date$
> + */
> +public class WSDLOperation {
> + protected XMLSchemaRegistry schemaRegistry;
> + protected javax.wsdl.Operation operation;
> + protected Operation operationModel;
> + protected DataType<List<DataType>> inputType;
> + protected DataType<XMLType> outputType;
> + protected List<DataType<XMLType>> faultTypes;
> + private String dataBinding;
> +
> + /**
> + * @param operation The WSDL4J operation
> + * @param dataBinding The default databinding
> + * @param schemaRegistry The XML Schema registry
> + */
> + public WSDLOperation(javax.wsdl.Operation operation, String dataBinding, XMLSchemaRegistry schemaRegistry) {
> + super();
> + this.operation = operation;
> + this.dataBinding = dataBinding;
> + this.schemaRegistry = schemaRegistry;
> + this.wrapper = new Wrapper();
> + }
> +
> + private Wrapper wrapper;
> +
> + private Boolean wrapperStyle;
> +
> + /**
> + * Test if the operation qualifies wrapper style as defined by the JAX-WS
> + * 2.0 spec
> + *
> + * @return true if the operation qualifies wrapper style, otherwise false
> + */
> + public boolean isWrapperStyle() throws InvalidWSDLException {
> + if (wrapperStyle == null) {
> + wrapperStyle =
> + wrapper.getInputChildElements() != null && (operation.getOutput() == null || wrapper
> + .getOutputChildElements() != null);
> + }
> + return wrapperStyle;
> + }
> +
> + public Wrapper getWrapper() throws InvalidInterfaceException {
> + if (!isWrapperStyle()) {
> + throw new IllegalStateException("The operation is not wrapper style.");
> + } else {
> + return wrapper;
> + }
> + }
> +
> + /**
> + * @return
> + * @throws InvalidServiceContractException
> + */
> + public DataType<List<DataType>> getInputType() throws InvalidWSDLException {
> + if (inputType == null) {
> + Input input = operation.getInput();
> + Message message = (input == null) ? null : input.getMessage();
> + inputType = getMessageType(message);
> + inputType.setDataBinding("idl:input");
> + }
> + return inputType;
> + }
> +
> + /**
> + * @return
> + * @throws NotSupportedWSDLException
> + */
> + public DataType<XMLType> getOutputType() throws InvalidWSDLException {
> + if (outputType == null) {
> + Output output = operation.getOutput();
> + Message outputMsg = (output == null) ? null : output.getMessage();
> +
> + List outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null);
> + if (outputParts != null && outputParts.size() > 0) {
> + if (outputParts.size() > 1) {
> + // We don't support output with multiple parts
> + throw new InvalidWSDLException("Multi-part output is not supported");
> + }
> + Part part = (Part)outputParts.get(0);
> + outputType = new WSDLPart(part, Object.class).getDataType();
> + // outputType.setMetadata(WSDLOperation.class.getName(), this);
> + }
> + }
> + return outputType;
> + }
> +
> + /**
> + * @return
> + * @throws NotSupportedWSDLException
> + */
> + public List<DataType<XMLType>> getFaultTypes() throws InvalidWSDLException {
> + if (faultTypes == null) {
> + Collection faults = operation.getFaults().values();
> + faultTypes = new ArrayList<DataType<XMLType>>();
> + for (Object f : faults) {
> + Fault fault = (Fault)f;
> + Message faultMsg = fault.getMessage();
> + List faultParts = faultMsg.getOrderedParts(null);
> + if (faultParts.size() != 1) {
> + throw new InvalidWSDLException("The fault message MUST have a single part");
> + }
> + Part part = (Part)faultParts.get(0);
> + WSDLPart wsdlPart = new WSDLPart(part, FaultException.class);
> + faultTypes.add(wsdlPart.getDataType());
> + }
> + }
> + return faultTypes;
> + }
> +
> + private DataType<List<DataType>> getMessageType(Message message) throws InvalidWSDLException {
> + List<DataType> partTypes = new ArrayList<DataType>();
> + if (message != null) {
> + Collection parts = message.getOrderedParts(null);
> + for (Object p : parts) {
> + WSDLPart part = new WSDLPart((Part)p, Object.class);
> + DataType<XMLType> partType = part.getDataType();
> + partTypes.add(partType);
> + }
> + }
> + return new DataTypeImpl<List<DataType>>(dataBinding, Object[].class, partTypes);
> + }
> +
> + /**
> + * @return
> + * @throws NotSupportedWSDLException
> + */
> + public Operation getOperation() throws InvalidInterfaceException {
> + if (operationModel == null) {
> + boolean oneway = (operation.getOutput() == null);
> + operationModel = new OperationImpl();
> + operationModel.setName(operation.getName());
> + operationModel.getFaultTypes().addAll(getFaultTypes());
> + operationModel.setNonBlocking(oneway);
> + operationModel.setConversationSequence(Operation.ConversationSequence.NO_CONVERSATION);
> + if (isWrapperStyle()) {
> + WrapperInfo wrapperInfo = getWrapper().getWrapperInfo();
> + operationModel.setInputType(wrapperInfo.getUnwrappedInputType());
> + operationModel.setOutputType(wrapperInfo.getUnwrappedOutputType());
> + } else {
> + List<DataType> inputTypes = new ArrayList<DataType>();
> + inputTypes.add(getInputType());
> + DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class,
> + inputTypes);
> + operationModel.setInputType(inputType);
> + operationModel.setOutputType(getOutputType());
> + }
> + }
> + return operationModel;
> + }
> +
> + /**
> + * Metadata for a WSDL part
> + */
> + public class WSDLPart {
> + private Part part;
> +
> + private XmlSchemaElement element;
> +
> + private DataType<XMLType> dataType;
> +
> + public WSDLPart(Part part, Class javaType) throws InvalidWSDLException {
> + this.part = part;
> + QName elementName = part.getElementName();
> + if (elementName != null) {
> + element = schemaRegistry.getElement(elementName);
> + if (element == null) {
> + throw new InvalidWSDLException("Element cannot be resolved: " + elementName.toString());
> + }
> + } else {
> + // Create an faked XSD element to host the metadata
> + element = new XmlSchemaElement();
> + element.setName(part.getName());
> + element.setQName(new QName(null, part.getName()));
> + QName typeName = part.getTypeName();
> + if (typeName != null) {
> + XmlSchemaType type = schemaRegistry.getType(typeName);
> + if (type == null) {
> + throw new InvalidWSDLException("Type cannot be resolved: " + typeName.toString());
> + }
> + element.setSchemaType(type);
> + element.setSchemaTypeName(type.getQName());
> + }
> + }
> + dataType = new DataTypeImpl<XMLType>(dataBinding, javaType, new XMLType(getElementInfo(element)));
> + // dataType.setMetadata(WSDLPart.class.getName(), this);
> + // dataType.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
> + }
> +
> + /**
> + * @return the element
> + */
> + public XmlSchemaElement getElement() {
> + return element;
> + }
> +
> + /**
> + * @return the part
> + */
> + public Part getPart() {
> + return part;
> + }
> +
> + /**
> + * @return the dataType
> + */
> + public DataType<XMLType> getDataType() {
> + return dataType;
> + }
> + }
> +
> + /**
> + * The "Wrapper Style" WSDL operation is defined by The Java API for
> + * XML-Based Web Services (JAX-WS) 2.0 specification, section 2.3.1.2
> + * Wrapper Style. <p/> A WSDL operation qualifies for wrapper style mapping
> + * only if the following criteria are met:
> + * <ul>
> + * <li>(i) The operation�s input and output messages (if present) each
> + * contain only a single part
> + * <li>(ii) The input message part refers to a global element declaration
> + * whose localname is equal to the operation name
> + * <li>(iii) The output message part refers to a global element declaration
> + * <li>(iv) The elements referred to by the input and output message parts
> + * (henceforth referred to as wrapper elements) are both complex types
> + * defined using the xsd:sequence compositor
> + * <li>(v) The wrapper elements only contain child elements, they must not
> + * contain other structures such as wildcards (element or attribute),
> + * xsd:choice, substitution groups (element references are not permitted) or
> + * attributes; furthermore, they must not be nillable.
> + * </ul>
> + */
> + public class Wrapper {
> + private XmlSchemaElement inputWrapperElement;
> +
> + private XmlSchemaElement outputWrapperElement;
> +
> + private List<XmlSchemaElement> inputElements;
> +
> + private List<XmlSchemaElement> outputElements;
> +
> + private DataType<List<DataType<XMLType>>> unwrappedInputType;
> +
> + private DataType<XMLType> unwrappedOutputType;
> +
> + private transient WrapperInfo wrapperInfo;
> +
> + private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) throws InvalidWSDLException {
> + if (element == null) {
> + return null;
> + }
> + if (element.isNillable()) {
> + // Wrapper element cannot be nillable
> + return null;
> + }
> + XmlSchemaType type = element.getSchemaType();
> + if (type == null) {
> + String qName = element.getQName().toString();
> + throw new InvalidWSDLException("The XML schema element does not have a type: " + qName);
> + }
> + if (!(type instanceof XmlSchemaComplexType)) {
> + // Has to be a complexType
> + return null;
> + }
> + XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
> + if (complexType.getAttributes().getCount() != 0 || complexType.getAnyAttribute() != null) {
> + // No attributes
> + return null;
> + }
> + XmlSchemaParticle particle = complexType.getParticle();
> + if (particle == null) {
> + // No particle
> + return Collections.emptyList();
> + }
> + if (!(particle instanceof XmlSchemaSequence)) {
> + return null;
> + }
> + XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle();
> + XmlSchemaObjectCollection items = sequence.getItems();
> + List<XmlSchemaElement> childElements = new ArrayList<XmlSchemaElement>();
> + for (int i = 0; i < items.getCount(); i++) {
> + XmlSchemaObject schemaObject = items.getItem(i);
> + if (!(schemaObject instanceof XmlSchemaElement)) {
> + return null;
> + }
> + XmlSchemaElement childElement = (XmlSchemaElement)schemaObject;
> + if (childElement.getName() == null || childElement.getRefName() != null) {
> + return null;
> + }
> + // TODO: Do we support maxOccurs >1 ?
> + if (childElement.getMaxOccurs() > 1) {
> + return null;
> + }
> + childElements.add(childElement);
> + }
> + return childElements;
> + }
> +
> + /**
> + * Return a list of child XSD elements under the wrapped request element
> + *
> + * @return a list of child XSD elements or null if if the request
> + * element is not wrapped
> + */
> + public List<XmlSchemaElement> getInputChildElements() throws InvalidWSDLException {
> + if (inputElements != null) {
> + return inputElements;
> + }
> + Input input = operation.getInput();
> + if (input != null) {
> + Message inputMsg = input.getMessage();
> + Collection parts = inputMsg.getParts().values();
> + if (parts.size() != 1) {
> + return null;
> + }
> + Part part = (Part)parts.iterator().next();
> + QName elementName = part.getElementName();
> + if (elementName == null) {
> + return null;
> + }
> + if (!operation.getName().equals(elementName.getLocalPart())) {
> + return null;
> + }
> + inputWrapperElement = schemaRegistry.getElement(elementName);
> + if (inputWrapperElement == null) {
> + throw new InvalidWSDLException("The element is not declared in a XML schema: " + elementName
> + .toString());
> + }
> + inputElements = getChildElements(inputWrapperElement);
> + return inputElements;
> + } else {
> + return null;
> + }
> + }
> +
> + /**
> + * Return a list of child XSD elements under the wrapped response
> + * element
> + *
> + * @return a list of child XSD elements or null if if the response
> + * element is not wrapped
> + */
> + public List<XmlSchemaElement> getOutputChildElements() throws InvalidWSDLException {
> + if (outputElements != null) {
> + return outputElements;
> + }
> + Output output = operation.getOutput();
> + if (output != null) {
> + Message outputMsg = output.getMessage();
> + Collection parts = outputMsg.getParts().values();
> + if (parts.size() != 1) {
> + return null;
> + }
> + Part part = (Part)parts.iterator().next();
> + QName elementName = part.getElementName();
> + if (elementName == null) {
> + throw new InvalidWSDLException("The element is not declared in the XML schema: " + part.getName());
> + }
> + outputWrapperElement = schemaRegistry.getElement(elementName);
> + if (outputWrapperElement == null) {
> + return null;
> + }
> + outputElements = getChildElements(outputWrapperElement);
> + // FIXME: Do we support multiple child elements for the
> + // response?
> + return outputElements;
> + } else {
> + return null;
> + }
> + }
> +
> + /**
> + * @return the inputWrapperElement
> + */
> + public XmlSchemaElement getInputWrapperElement() {
> + return inputWrapperElement;
> + }
> +
> + /**
> + * @return the outputWrapperElement
> + */
> + public XmlSchemaElement getOutputWrapperElement() {
> + return outputWrapperElement;
> + }
> +
> + /*
> + public DataType<List<DataType<XMLType>>> getUnwrappedInputType() throws InvalidWSDLException {
> + if (unwrappedInputType == null) {
> + List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>();
> + for (XmlSchemaElement element : getInputChildElements()) {
> + DataType<XMLType> type =
> + new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element)));
> + // type.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
> + childTypes.add(type);
> + }
> + unwrappedInputType =
> + new DataType<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class, childTypes);
> + }
> + return unwrappedInputType;
> + }
> +
> + public DataType<XMLType> getUnwrappedOutputType() throws InvalidServiceContractException {
> + if (unwrappedOutputType == null) {
> + List<XmlSchemaElement> elements = getOutputChildElements();
> + if (elements != null && elements.size() > 0) {
> + if (elements.size() > 1) {
> + // We don't support output with multiple parts
> + throw new NotSupportedWSDLException("Multi-part output is not supported");
> + }
> + XmlSchemaElement element = elements.get(0);
> + unwrappedOutputType =
> + new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element)));
> + // unwrappedOutputType.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
> + }
> + }
> + return unwrappedOutputType;
> + }
> + */
> +
> + public WrapperInfo getWrapperInfo() throws InvalidWSDLException {
> + if (wrapperInfo == null) {
> + ElementInfo in = getElementInfo(getInputWrapperElement());
> + ElementInfo out = getElementInfo(getOutputWrapperElement());
> + List<ElementInfo> inChildren = new ArrayList<ElementInfo>();
> + for (XmlSchemaElement e : getInputChildElements()) {
> + inChildren.add(getElementInfo(e));
> + }
> + List<ElementInfo> outChildren = new ArrayList<ElementInfo>();
> + if (out != null) {
> + for (XmlSchemaElement e : getOutputChildElements()) {
> + outChildren.add(getElementInfo(e));
> + }
> + }
> + wrapperInfo =
> + new WrapperInfo(dataBinding, in, out, inChildren, outChildren);
> + }
> + return wrapperInfo;
> + }
> + }
> +
> + private static ElementInfo getElementInfo(XmlSchemaElement element) {
> + if (element == null) {
> + return null;
> + }
> + return new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
> + }
> +
> + private static TypeInfo getTypeInfo(XmlSchemaType type) {
> + if (type == null) {
> + return null;
> + }
> + XmlSchemaType baseType = (XmlSchemaType)type.getBaseSchemaType();
> + QName name = type.getQName();
> + boolean simple = (type instanceof XmlSchemaSimpleType);
> + if (baseType == null) {
> + return new TypeInfo(name, simple, null);
> + } else {
> + return new TypeInfo(name, simple, getTypeInfo(baseType));
> + }
> + }
> +
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java?view=auto&rev=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java (added)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java Tue Apr 10 23:26:26 2007
> @@ -0,0 +1,87 @@
> +/*
> + * 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.tuscany.interfacedef.wsdl.introspect;
> +
> +import java.io.IOException;
> +import java.net.URL;
> +import java.util.List;
> +
> +import javax.wsdl.Definition;
> +import javax.xml.namespace.QName;
> +
> +import org.apache.ws.commons.schema.XmlSchema;
> +import org.apache.ws.commons.schema.XmlSchemaElement;
> +import org.apache.ws.commons.schema.XmlSchemaException;
> +import org.apache.ws.commons.schema.XmlSchemaType;
> +
> +/**
> + * A service for caching XML Schemas
> + *
> + * @version $Rev$ $Date$
> + */
> +public interface XMLSchemaRegistry {
> + /**
> + * Load all inline schemas from the WSDL definition
> + *
> + * @param definition The WSDL defintion whose types element contains a list of schemas
> + * @return A list of inline schemas
> + */
> + List<XmlSchema> loadSchemas(Definition definition);
> +
> + /**
> + * Loads and registers a XML schema.
> + *
> + * @param namespace the expected namespace, or null if any namespace should be allowed
> + * @param location the location to load the schema from
> + * @return the loaded Definition
> + * @throws IOException if there was a problem reading the document
> + * @throws XmlSchemaException if there was a problem parsing the schema
> + */
> + XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException;
> +
> + /**
> + * Load and register a XML schema as specified in a XSD schemaLocation attribute.
> + *
> + * @param schemaLocation the value of the schemaLocation attribute
> + * @param classLoader application classloader used to support relative locations
> + * @return the loaded schema
> + * @throws IOException if there was a problem reading the document
> + * @throws XmlSchemaException if there was a problem parsing the schema
> + */
> + XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException;
> +
> + /**
> + * Returns the XSD Element with the supplied qualified name, or null if no such element has been defined.
> + *
> + * @param name the qualified name of the XSD element
> + * @return the XSD element for the supplied name, or null if none has been defined
> + */
> + XmlSchemaElement getElement(QName name);
> +
> + /**
> + * Returns the XmlSchemaType with the supplied qualified name, or null if no such type has been defined.
> + *
> + * @param name the qualified name of the XSD type
> + * @return the XSD type for the supplied name, or null if none has been defined
> + */
> + XmlSchemaType getType(QName name);
> +
> +
> +
> +}
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
> ------------------------------------------------------------------------------
> svn:keywords = Rev Date
>
> Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?view=diff&rev=527397&r1=527396&r2=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java (original)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java Tue Apr 10 23:26:26 2007
> @@ -28,11 +28,15 @@
> import javax.xml.stream.XMLStreamWriter;
>
> import org.apache.tuscany.assembly.xml.Constants;
> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
> import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
> import org.apache.tuscany.interfacedef.wsdl.WSDLFactory;
> import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
> import org.apache.tuscany.interfacedef.wsdl.WSDLInterfaceContract;
> import org.apache.tuscany.interfacedef.wsdl.impl.DefaultWSDLFactory;
> +import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultWSDLInterfaceIntrospector;
> +import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultXMLSchemaRegistry;
> +import org.apache.tuscany.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector;
> import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
> import org.apache.tuscany.services.spi.contribution.ContributionReadException;
> import org.apache.tuscany.services.spi.contribution.ContributionResolveException;
> @@ -43,13 +47,15 @@
> public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants {
>
> private WSDLFactory wsdlFactory;
> + private WSDLInterfaceIntrospector wsdlIntrospector;
>
> - public WSDLInterfaceProcessor(WSDLFactory wsdlFactory) {
> + public WSDLInterfaceProcessor(WSDLFactory wsdlFactory, WSDLInterfaceIntrospector wsdlIntrospector) {
> this.wsdlFactory = wsdlFactory;
> + this.wsdlIntrospector = wsdlIntrospector;
> }
>
> public WSDLInterfaceProcessor() {
> - this(new DefaultWSDLFactory());
> + this(new DefaultWSDLFactory(), new DefaultWSDLInterfaceIntrospector(new DefaultXMLSchemaRegistry()));
> }
>
> /**
> @@ -143,7 +149,7 @@
> }
> }
>
> - private WSDLInterface resolveWSDLInterface(WSDLInterface wsdlInterface, ArtifactResolver resolver) {
> + private WSDLInterface resolveWSDLInterface(WSDLInterface wsdlInterface, ArtifactResolver resolver) throws ContributionResolveException {
>
> if (wsdlInterface != null && wsdlInterface.isUnresolved()) {
>
> @@ -160,15 +166,13 @@
> PortType portType = wsdlDefinition.getDefinition().getPortType(wsdlInterface.getName());
> if (portType != null) {
>
> - // Add the resolved WSDL interface to the resolver
> - // so that it's found next time
> - wsdlInterface.setPortType(portType);
> -
> - // Introspect the WSDL portType and populate the interface and
> - // operations
> - //FIXME
> -
> - wsdlInterface.setUnresolved(false);
> + // Introspect the WSDL portType and add the resulting
> + // WSDLInterface to the resolver
> + try {
> + wsdlInterface = wsdlIntrospector.introspect(portType);
> + } catch (InvalidInterfaceException e) {
> + throw new ContributionResolveException(e);
> + }
> resolver.add(wsdlInterface);
> }
> }
>
> Modified: incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml?view=diff&rev=527397&r1=527396&r2=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml (original)
> +++ incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml Tue Apr 10 23:26:26 2007
> @@ -34,6 +34,12 @@
> <artifactId>tuscany-interface</artifactId>
> <version>1.0-incubating-SNAPSHOT</version>
> </dependency>
> +
> + <dependency>
> + <groupId>org.apache.ws.commons.schema</groupId>
> + <artifactId>XmlSchema</artifactId>
> + <version>1.2</version>
> + </dependency>
>
> <dependency>
> <groupId>wsdl4j</groupId>
>
> Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java?view=diff&rev=527397&r1=527396&r2=527397
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java (original)
> +++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java Tue Apr 10 23:26:26 2007
> @@ -56,7 +56,7 @@
>
> private List<ElementInfo> outputChildElements;
>
> - private DataType<List<DataType<XMLType>>> unwrappedInputType;
> + private DataType<List<DataType>> unwrappedInputType;
>
> private DataType<XMLType> unwrappedOutputType;
>
> @@ -106,14 +106,14 @@
> /**
> * @return the unwrappedInputType
> */
> - public DataType<List<DataType<XMLType>>> getUnwrappedInputType() {
> + public DataType<List<DataType>> getUnwrappedInputType() {
> if (unwrappedInputType == null) {
> - List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>();
> + List<DataType> childTypes = new ArrayList<DataType>();
> for (ElementInfo element : getInputChildElements()) {
> DataType<XMLType> type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
> childTypes.add(type);
> }
> - unwrappedInputType = new DataTypeImpl<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class,
> + unwrappedInputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class,
> childTypes);
> }
> return unwrappedInputType;
> @@ -122,7 +122,7 @@
> /**
> * @return the unwrappedOutputType
> */
> - public DataType<XMLType> getUnwrappedOutputType() {
> + public DataType getUnwrappedOutputType() {
> if (unwrappedOutputType == null) {
> List<ElementInfo> elements = getOutputChildElements();
> if (elements != null && elements.size() > 0) {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-commits-help@ws.apache.org
>
>
>
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org
Re: Please review WSDL introspection code, Re: svn commit: r527397
Posted by Raymond Feng <en...@gmail.com>.
Hi,
Please see my comments inline.
Thanks,
Raymond
----- Original Message -----
From: "Jean-Sebastien Delfino" <js...@apache.org>
To: <tu...@ws.apache.org>
Sent: Wednesday, April 11, 2007 9:09 AM
Subject: Please review WSDL introspection code, Re: svn commit: r527397
> Could somebody familiar with the Databinding framework and the DataType
> support in particular review how I ported the WSDLIntrospector and
> WSDLOperation to the new SPIs?
>
> I had to remove some usage of generics since Operation<DataType> has
> changed to Operation.
>
Yes.
> Also I am not sure if I am setting the inputType and outputType correctly
> on the operation, in particular if the WSDL is a doc-literal-wrapped style
> WSDL, do we need to unwrap the wrapper like I did or not?
>
We don't need to unwrap the wrapper for the operation model. The signature
of the operation should be the same as defined by the IDL. I'll fix it.
> And finally how is the DataBinding field on an inputType used? is
> DataBinding == "idl:input" correct?
>
Yes.
> Thanks...
>
> jsdelfino@apache.org wrote:
>> Author: jsdelfino
>> Date: Tue Apr 10 23:26:26 2007
>> New Revision: 527397
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=527397
>> Log:
>> Ported WSDL interface introspector to the latest SPIs and integrated it
>> with the WSDLInterfaceProcessor.
>>
>> Added:
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> (with props)
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> (with props)
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> (with props)
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> (with props)
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> (with props)
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> (with props)
>> Modified:
>>
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
>> incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml
>>
>> incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,69 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import java.util.ArrayList;
>> +import java.util.List;
>> +
>> +import javax.wsdl.PortType;
>> +
>> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
>> +import org.apache.tuscany.interfacedef.Operation;
>> +import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
>> +import org.apache.tuscany.interfacedef.wsdl.impl.WSDLInterfaceImpl;
>> +
>> +/**
>> + * Introspector for creating WSDLInterface definitions from WSDL
>> PortTypes.
>> + */
>> +public class DefaultWSDLInterfaceIntrospector implements
>> WSDLInterfaceIntrospector {
>> + + private XMLSchemaRegistry schemaRegistry;
>> +
>> + public DefaultWSDLInterfaceIntrospector(XMLSchemaRegistry
>> schemaRegistry) {
>> + super();
>> + this.schemaRegistry = schemaRegistry;
>> + }
>> +
>> + // FIXME: Do we want to deal with document-literal wrapped style
>> based on the JAX-WS spec?
>> + protected List<Operation> introspectOperations(PortType portType)
>> throws InvalidInterfaceException {
>> + List<Operation> operations = new ArrayList<Operation>();
>> + for (Object op : portType.getOperations()) {
>> + javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)op;
>> + operations.add(introspectOperation(wsdlOp));
>> + }
>> + return operations;
>> + }
>> +
>> + protected Operation introspectOperation(javax.wsdl.Operation wsdlOp)
>> throws InvalidInterfaceException {
>> +
>> + WSDLOperation op = new WSDLOperation(wsdlOp, null,
>> schemaRegistry);
>> + return op.getOperation();
>> + }
>> +
>> + public WSDLInterface introspect(PortType portType) throws
>> InvalidInterfaceException {
>> + WSDLInterface wsdlInterface = new WSDLInterfaceImpl();
>> + wsdlInterface.setPortType(portType);
>> +
>> wsdlInterface.getOperations().addAll(introspectOperations(portType));
>> + // FIXME: set to Non-conversational for now
>> + wsdlInterface.setConversational(false);
>> + return wsdlInterface;
>> + }
>> +
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,127 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import java.io.IOException;
>> +import java.io.InputStream;
>> +import java.io.InputStreamReader;
>> +import java.net.URI;
>> +import java.net.URISyntaxException;
>> +import java.net.URL;
>> +import java.util.ArrayList;
>> +import java.util.Collections;
>> +import java.util.List;
>> +
>> +import javax.wsdl.Definition;
>> +import javax.wsdl.Types;
>> +import javax.wsdl.extensions.schema.Schema;
>> +import javax.xml.namespace.QName;
>> +
>> +import org.apache.ws.commons.schema.XmlSchema;
>> +import org.apache.ws.commons.schema.XmlSchemaCollection;
>> +import org.apache.ws.commons.schema.XmlSchemaElement;
>> +import org.apache.ws.commons.schema.XmlSchemaException;
>> +import org.apache.ws.commons.schema.XmlSchemaType;
>> +import org.w3c.dom.Element;
>> +
>> +/**
>> + * Default implementation of XMLSchemaRegistry
>> + */
>> +public class DefaultXMLSchemaRegistry implements XMLSchemaRegistry {
>> + private final XmlSchemaCollection collection;
>> +
>> + /**
>> + * @param collection
>> + */
>> + public DefaultXMLSchemaRegistry(XmlSchemaCollection collection) {
>> + super();
>> + this.collection = collection;
>> + }
>> +
>> + public DefaultXMLSchemaRegistry() {
>> + super();
>> + this.collection = new XmlSchemaCollection();
>> + }
>> +
>> + public XmlSchemaElement getElement(QName name) {
>> + return collection.getElementByQName(name);
>> + }
>> +
>> + public XmlSchemaType getType(QName name) {
>> + return collection.getTypeByQName(name);
>> + }
>> +
>> + public List<XmlSchema> loadSchemas(Definition definition) {
>> + Types types = definition.getTypes();
>> + if (types == null) {
>> + return Collections.emptyList();
>> + }
>> + List<XmlSchema> schemas = new ArrayList<XmlSchema>();
>> + for (Object ext : types.getExtensibilityElements()) {
>> + if (ext instanceof Schema) {
>> + Element element = ((Schema) ext).getElement();
>> + XmlSchema s = collection.read(element,
>> element.getBaseURI());
>> + schemas.add(s);
>> + }
>> + }
>> + return schemas;
>> + }
>> +
>> + public XmlSchema loadSchema(String namespace, URL location) throws
>> IOException, XmlSchemaException {
>> + XmlSchema schema;
>> + XmlSchema[] schemaList =
>> collection.getXmlSchema(location.toExternalForm());
>> + if (schemaList != null && schemaList.length > 0) {
>> + schema = schemaList[0];
>> + } else {
>> + InputStream is = location.openStream();
>> + schema = collection.read(new InputStreamReader(is), null);
>> + is.close();
>> + }
>> + if (namespace != null && schema != null &&
>> !namespace.equals(schema.getTargetNamespace())) {
>> + throw new XmlSchemaException(namespace + " != " +
>> schema.getTargetNamespace());
>> + }
>> + return schema;
>> + }
>> +
>> + public XmlSchema loadSchema(String schemaLocation, ClassLoader
>> classLoader) throws IOException, XmlSchemaException {
>> + int index = schemaLocation.indexOf(' ');
>> + if (index == -1) {
>> + throw new XmlSchemaException("Invalid schemaLocation: " +
>> schemaLocation);
>> + }
>> + String namespace = schemaLocation.substring(0, index).trim();
>> + URL url;
>> + URI uri;
>> + try {
>> + uri = new URI(schemaLocation.substring(index + 1).trim());
>> + } catch (URISyntaxException e) {
>> + throw new XmlSchemaException("Invalid schemaLocation: " +
>> schemaLocation);
>> + }
>> + if (uri.isAbsolute()) {
>> + url = uri.toURL();
>> + } else {
>> + url = classLoader.getResource(uri.toString());
>> + if (url == null) {
>> + throw new XmlSchemaException("Resource cannot be
>> resolved: schemaLocation: " + schemaLocation);
>> + }
>> + }
>> + return loadSchema(namespace, url);
>> + }
>> +
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/DefaultXMLSchemaRegistry.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,35 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
>> +
>> +/**
>> + * An exception to indicate the WSDL definition is invalid
>> + *
>> + * @version $Rev$ $Date$
>> + */
>> +public class InvalidWSDLException extends InvalidInterfaceException {
>> + private static final long serialVersionUID = 3742887584293256519L;
>> +
>> + public InvalidWSDLException(String message) {
>> + super(message);
>> + }
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/InvalidWSDLException.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,41 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import javax.wsdl.PortType;
>> +
>> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
>> +import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
>> +
>> +/**
>> + * Introspector for creating WSDLInterface definitions from WSDL
>> PortTypes.
>> + *
>> + * @version $Rev$ $Date$
>> + */
>> +public interface WSDLInterfaceIntrospector {
>> +
>> + /**
>> + * Introspect a WSDL portType and return a WSDL interface
>> definition.
>> + *
>> + * @param type the portType to inspect
>> + * @return a WSDLInterface corresponding to the WSDL portType
>> + */
>> + WSDLInterface introspect(PortType portType) throws
>> InvalidInterfaceException;
>> +
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,517 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import java.util.ArrayList;
>> +import java.util.Collection;
>> +import java.util.Collections;
>> +import java.util.List;
>> +
>> +import javax.wsdl.Fault;
>> +import javax.wsdl.Input;
>> +import javax.wsdl.Message;
>> +import javax.wsdl.Output;
>> +import javax.wsdl.Part;
>> +import javax.xml.namespace.QName;
>> +
>> +import org.apache.tuscany.interfacedef.DataType;
>> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
>> +import org.apache.tuscany.interfacedef.Operation;
>> +import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
>> +import org.apache.tuscany.interfacedef.impl.OperationImpl;
>> +import org.apache.tuscany.interfacedef.util.ElementInfo;
>> +import org.apache.tuscany.interfacedef.util.FaultException;
>> +import org.apache.tuscany.interfacedef.util.TypeInfo;
>> +import org.apache.tuscany.interfacedef.util.WrapperInfo;
>> +import org.apache.tuscany.interfacedef.util.XMLType;
>> +import org.apache.ws.commons.schema.XmlSchemaComplexType;
>> +import org.apache.ws.commons.schema.XmlSchemaElement;
>> +import org.apache.ws.commons.schema.XmlSchemaObject;
>> +import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
>> +import org.apache.ws.commons.schema.XmlSchemaParticle;
>> +import org.apache.ws.commons.schema.XmlSchemaSequence;
>> +import org.apache.ws.commons.schema.XmlSchemaSimpleType;
>> +import org.apache.ws.commons.schema.XmlSchemaType;
>> +
>> +/**
>> + * Metadata for a WSDL operation
>> + * + * @version $Rev$ $Date$
>> + */
>> +public class WSDLOperation {
>> + protected XMLSchemaRegistry schemaRegistry;
>> + protected javax.wsdl.Operation operation;
>> + protected Operation operationModel;
>> + protected DataType<List<DataType>> inputType;
>> + protected DataType<XMLType> outputType;
>> + protected List<DataType<XMLType>> faultTypes;
>> + private String dataBinding;
>> +
>> + /**
>> + * @param operation The WSDL4J operation
>> + * @param dataBinding The default databinding
>> + * @param schemaRegistry The XML Schema registry
>> + */
>> + public WSDLOperation(javax.wsdl.Operation operation, String
>> dataBinding, XMLSchemaRegistry schemaRegistry) {
>> + super();
>> + this.operation = operation;
>> + this.dataBinding = dataBinding;
>> + this.schemaRegistry = schemaRegistry;
>> + this.wrapper = new Wrapper();
>> + }
>> +
>> + private Wrapper wrapper;
>> +
>> + private Boolean wrapperStyle;
>> +
>> + /**
>> + * Test if the operation qualifies wrapper style as defined by the
>> JAX-WS
>> + * 2.0 spec
>> + * + * @return true if the operation qualifies wrapper style,
>> otherwise false
>> + */
>> + public boolean isWrapperStyle() throws InvalidWSDLException {
>> + if (wrapperStyle == null) {
>> + wrapperStyle =
>> + wrapper.getInputChildElements() != null &&
>> (operation.getOutput() == null || wrapper
>> + .getOutputChildElements() != null);
>> + }
>> + return wrapperStyle;
>> + }
>> +
>> + public Wrapper getWrapper() throws InvalidInterfaceException {
>> + if (!isWrapperStyle()) {
>> + throw new IllegalStateException("The operation is not
>> wrapper style.");
>> + } else {
>> + return wrapper;
>> + }
>> + }
>> +
>> + /**
>> + * @return
>> + * @throws InvalidServiceContractException
>> + */
>> + public DataType<List<DataType>> getInputType() throws
>> InvalidWSDLException {
>> + if (inputType == null) {
>> + Input input = operation.getInput();
>> + Message message = (input == null) ? null :
>> input.getMessage();
>> + inputType = getMessageType(message);
>> + inputType.setDataBinding("idl:input");
>> + }
>> + return inputType;
>> + }
>> +
>> + /**
>> + * @return
>> + * @throws NotSupportedWSDLException
>> + */
>> + public DataType<XMLType> getOutputType() throws InvalidWSDLException
>> {
>> + if (outputType == null) {
>> + Output output = operation.getOutput();
>> + Message outputMsg = (output == null) ? null :
>> output.getMessage();
>> +
>> + List outputParts = (outputMsg == null) ? null :
>> outputMsg.getOrderedParts(null);
>> + if (outputParts != null && outputParts.size() > 0) {
>> + if (outputParts.size() > 1) {
>> + // We don't support output with multiple parts
>> + throw new InvalidWSDLException("Multi-part output is
>> not supported");
>> + }
>> + Part part = (Part)outputParts.get(0);
>> + outputType = new WSDLPart(part,
>> Object.class).getDataType();
>> + // outputType.setMetadata(WSDLOperation.class.getName(),
>> this);
>> + }
>> + }
>> + return outputType;
>> + }
>> +
>> + /**
>> + * @return
>> + * @throws NotSupportedWSDLException
>> + */
>> + public List<DataType<XMLType>> getFaultTypes() throws
>> InvalidWSDLException {
>> + if (faultTypes == null) {
>> + Collection faults = operation.getFaults().values();
>> + faultTypes = new ArrayList<DataType<XMLType>>();
>> + for (Object f : faults) {
>> + Fault fault = (Fault)f;
>> + Message faultMsg = fault.getMessage();
>> + List faultParts = faultMsg.getOrderedParts(null);
>> + if (faultParts.size() != 1) {
>> + throw new InvalidWSDLException("The fault message
>> MUST have a single part");
>> + }
>> + Part part = (Part)faultParts.get(0);
>> + WSDLPart wsdlPart = new WSDLPart(part,
>> FaultException.class);
>> + faultTypes.add(wsdlPart.getDataType());
>> + }
>> + }
>> + return faultTypes;
>> + }
>> +
>> + private DataType<List<DataType>> getMessageType(Message message)
>> throws InvalidWSDLException {
>> + List<DataType> partTypes = new ArrayList<DataType>();
>> + if (message != null) {
>> + Collection parts = message.getOrderedParts(null);
>> + for (Object p : parts) {
>> + WSDLPart part = new WSDLPart((Part)p, Object.class);
>> + DataType<XMLType> partType = part.getDataType();
>> + partTypes.add(partType);
>> + }
>> + }
>> + return new DataTypeImpl<List<DataType>>(dataBinding,
>> Object[].class, partTypes);
>> + }
>> +
>> + /**
>> + * @return
>> + * @throws NotSupportedWSDLException
>> + */
>> + public Operation getOperation() throws InvalidInterfaceException {
>> + if (operationModel == null) {
>> + boolean oneway = (operation.getOutput() == null);
>> + operationModel = new OperationImpl();
>> + operationModel.setName(operation.getName());
>> + operationModel.getFaultTypes().addAll(getFaultTypes());
>> + operationModel.setNonBlocking(oneway);
>> +
>> operationModel.setConversationSequence(Operation.ConversationSequence.NO_CONVERSATION);
>> + if (isWrapperStyle()) {
>> + WrapperInfo wrapperInfo = getWrapper().getWrapperInfo();
>> +
>> operationModel.setInputType(wrapperInfo.getUnwrappedInputType());
>> +
>> operationModel.setOutputType(wrapperInfo.getUnwrappedOutputType());
>> + } else {
>> + List<DataType> inputTypes = new ArrayList<DataType>();
>> + inputTypes.add(getInputType());
>> + DataType<List<DataType>> inputType = new
>> DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class,
>> +
>> inputTypes);
>> + operationModel.setInputType(inputType);
>> + operationModel.setOutputType(getOutputType());
>> + }
>> + }
>> + return operationModel;
>> + }
>> +
>> + /**
>> + * Metadata for a WSDL part
>> + */
>> + public class WSDLPart {
>> + private Part part;
>> +
>> + private XmlSchemaElement element;
>> +
>> + private DataType<XMLType> dataType;
>> +
>> + public WSDLPart(Part part, Class javaType) throws
>> InvalidWSDLException {
>> + this.part = part;
>> + QName elementName = part.getElementName();
>> + if (elementName != null) {
>> + element = schemaRegistry.getElement(elementName);
>> + if (element == null) {
>> + throw new InvalidWSDLException("Element cannot be
>> resolved: " + elementName.toString());
>> + }
>> + } else {
>> + // Create an faked XSD element to host the metadata
>> + element = new XmlSchemaElement();
>> + element.setName(part.getName());
>> + element.setQName(new QName(null, part.getName()));
>> + QName typeName = part.getTypeName();
>> + if (typeName != null) {
>> + XmlSchemaType type =
>> schemaRegistry.getType(typeName);
>> + if (type == null) {
>> + throw new InvalidWSDLException("Type cannot be
>> resolved: " + typeName.toString());
>> + }
>> + element.setSchemaType(type);
>> + element.setSchemaTypeName(type.getQName());
>> + }
>> + }
>> + dataType = new DataTypeImpl<XMLType>(dataBinding, javaType,
>> new XMLType(getElementInfo(element)));
>> + // dataType.setMetadata(WSDLPart.class.getName(), this);
>> + // dataType.setMetadata(ElementInfo.class.getName(),
>> getElementInfo(element));
>> + }
>> +
>> + /**
>> + * @return the element
>> + */
>> + public XmlSchemaElement getElement() {
>> + return element;
>> + }
>> +
>> + /**
>> + * @return the part
>> + */
>> + public Part getPart() {
>> + return part;
>> + }
>> +
>> + /**
>> + * @return the dataType
>> + */
>> + public DataType<XMLType> getDataType() {
>> + return dataType;
>> + }
>> + }
>> +
>> + /**
>> + * The "Wrapper Style" WSDL operation is defined by The Java API for
>> + * XML-Based Web Services (JAX-WS) 2.0 specification, section
>> 2.3.1.2
>> + * Wrapper Style. <p/> A WSDL operation qualifies for wrapper style
>> mapping
>> + * only if the following criteria are met:
>> + * <ul>
>> + * <li>(i) The operation�s input and output messages (if present)
>> each
>> + * contain only a single part
>> + * <li>(ii) The input message part refers to a global element
>> declaration
>> + * whose localname is equal to the operation name
>> + * <li>(iii) The output message part refers to a global element
>> declaration
>> + * <li>(iv) The elements referred to by the input and output message
>> parts
>> + * (henceforth referred to as wrapper elements) are both complex
>> types
>> + * defined using the xsd:sequence compositor
>> + * <li>(v) The wrapper elements only contain child elements, they
>> must not
>> + * contain other structures such as wildcards (element or
>> attribute),
>> + * xsd:choice, substitution groups (element references are not
>> permitted) or
>> + * attributes; furthermore, they must not be nillable.
>> + * </ul>
>> + */
>> + public class Wrapper {
>> + private XmlSchemaElement inputWrapperElement;
>> +
>> + private XmlSchemaElement outputWrapperElement;
>> +
>> + private List<XmlSchemaElement> inputElements;
>> +
>> + private List<XmlSchemaElement> outputElements;
>> +
>> + private DataType<List<DataType<XMLType>>> unwrappedInputType;
>> +
>> + private DataType<XMLType> unwrappedOutputType;
>> +
>> + private transient WrapperInfo wrapperInfo;
>> +
>> + private List<XmlSchemaElement> getChildElements(XmlSchemaElement
>> element) throws InvalidWSDLException {
>> + if (element == null) {
>> + return null;
>> + }
>> + if (element.isNillable()) {
>> + // Wrapper element cannot be nillable
>> + return null;
>> + }
>> + XmlSchemaType type = element.getSchemaType();
>> + if (type == null) {
>> + String qName = element.getQName().toString();
>> + throw new InvalidWSDLException("The XML schema element
>> does not have a type: " + qName);
>> + }
>> + if (!(type instanceof XmlSchemaComplexType)) {
>> + // Has to be a complexType
>> + return null;
>> + }
>> + XmlSchemaComplexType complexType =
>> (XmlSchemaComplexType)type;
>> + if (complexType.getAttributes().getCount() != 0 ||
>> complexType.getAnyAttribute() != null) {
>> + // No attributes
>> + return null;
>> + }
>> + XmlSchemaParticle particle = complexType.getParticle();
>> + if (particle == null) {
>> + // No particle
>> + return Collections.emptyList();
>> + }
>> + if (!(particle instanceof XmlSchemaSequence)) {
>> + return null;
>> + }
>> + XmlSchemaSequence sequence =
>> (XmlSchemaSequence)complexType.getParticle();
>> + XmlSchemaObjectCollection items = sequence.getItems();
>> + List<XmlSchemaElement> childElements = new
>> ArrayList<XmlSchemaElement>();
>> + for (int i = 0; i < items.getCount(); i++) {
>> + XmlSchemaObject schemaObject = items.getItem(i);
>> + if (!(schemaObject instanceof XmlSchemaElement)) {
>> + return null;
>> + }
>> + XmlSchemaElement childElement =
>> (XmlSchemaElement)schemaObject;
>> + if (childElement.getName() == null ||
>> childElement.getRefName() != null) {
>> + return null;
>> + }
>> + // TODO: Do we support maxOccurs >1 ?
>> + if (childElement.getMaxOccurs() > 1) {
>> + return null;
>> + }
>> + childElements.add(childElement);
>> + }
>> + return childElements;
>> + }
>> +
>> + /**
>> + * Return a list of child XSD elements under the wrapped request
>> element
>> + * + * @return a list of child XSD elements or null if
>> if the request
>> + * element is not wrapped
>> + */
>> + public List<XmlSchemaElement> getInputChildElements() throws
>> InvalidWSDLException {
>> + if (inputElements != null) {
>> + return inputElements;
>> + }
>> + Input input = operation.getInput();
>> + if (input != null) {
>> + Message inputMsg = input.getMessage();
>> + Collection parts = inputMsg.getParts().values();
>> + if (parts.size() != 1) {
>> + return null;
>> + }
>> + Part part = (Part)parts.iterator().next();
>> + QName elementName = part.getElementName();
>> + if (elementName == null) {
>> + return null;
>> + }
>> + if
>> (!operation.getName().equals(elementName.getLocalPart())) {
>> + return null;
>> + }
>> + inputWrapperElement =
>> schemaRegistry.getElement(elementName);
>> + if (inputWrapperElement == null) {
>> + throw new InvalidWSDLException("The element is not
>> declared in a XML schema: " + elementName
>> + .toString());
>> + }
>> + inputElements = getChildElements(inputWrapperElement);
>> + return inputElements;
>> + } else {
>> + return null;
>> + }
>> + }
>> +
>> + /**
>> + * Return a list of child XSD elements under the wrapped
>> response
>> + * element
>> + * + * @return a list of child XSD elements or null if
>> if the response
>> + * element is not wrapped
>> + */
>> + public List<XmlSchemaElement> getOutputChildElements() throws
>> InvalidWSDLException {
>> + if (outputElements != null) {
>> + return outputElements;
>> + }
>> + Output output = operation.getOutput();
>> + if (output != null) {
>> + Message outputMsg = output.getMessage();
>> + Collection parts = outputMsg.getParts().values();
>> + if (parts.size() != 1) {
>> + return null;
>> + }
>> + Part part = (Part)parts.iterator().next();
>> + QName elementName = part.getElementName();
>> + if (elementName == null) {
>> + throw new InvalidWSDLException("The element is not
>> declared in the XML schema: " + part.getName());
>> + }
>> + outputWrapperElement =
>> schemaRegistry.getElement(elementName);
>> + if (outputWrapperElement == null) {
>> + return null;
>> + }
>> + outputElements = getChildElements(outputWrapperElement);
>> + // FIXME: Do we support multiple child elements for the
>> + // response?
>> + return outputElements;
>> + } else {
>> + return null;
>> + }
>> + }
>> +
>> + /**
>> + * @return the inputWrapperElement
>> + */
>> + public XmlSchemaElement getInputWrapperElement() {
>> + return inputWrapperElement;
>> + }
>> +
>> + /**
>> + * @return the outputWrapperElement
>> + */
>> + public XmlSchemaElement getOutputWrapperElement() {
>> + return outputWrapperElement;
>> + }
>> +
>> + /*
>> + public DataType<List<DataType<XMLType>>> getUnwrappedInputType()
>> throws InvalidWSDLException {
>> + if (unwrappedInputType == null) {
>> + List<DataType<XMLType>> childTypes = new
>> ArrayList<DataType<XMLType>>();
>> + for (XmlSchemaElement element : getInputChildElements())
>> {
>> + DataType<XMLType> type =
>> + new DataType<XMLType>(dataBinding, Object.class,
>> new XMLType(getElementInfo(element)));
>> + // type.setMetadata(ElementInfo.class.getName(),
>> getElementInfo(element));
>> + childTypes.add(type);
>> + }
>> + unwrappedInputType =
>> + new
>> DataType<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class,
>> childTypes);
>> + }
>> + return unwrappedInputType;
>> + }
>> +
>> + public DataType<XMLType> getUnwrappedOutputType() throws
>> InvalidServiceContractException {
>> + if (unwrappedOutputType == null) {
>> + List<XmlSchemaElement> elements =
>> getOutputChildElements();
>> + if (elements != null && elements.size() > 0) {
>> + if (elements.size() > 1) {
>> + // We don't support output with multiple parts
>> + throw new NotSupportedWSDLException("Multi-part
>> output is not supported");
>> + }
>> + XmlSchemaElement element = elements.get(0);
>> + unwrappedOutputType =
>> + new DataType<XMLType>(dataBinding, Object.class,
>> new XMLType(getElementInfo(element)));
>> + //
>> unwrappedOutputType.setMetadata(ElementInfo.class.getName(),
>> getElementInfo(element));
>> + }
>> + }
>> + return unwrappedOutputType;
>> + }
>> + */
>> +
>> + public WrapperInfo getWrapperInfo() throws InvalidWSDLException
>> {
>> + if (wrapperInfo == null) {
>> + ElementInfo in =
>> getElementInfo(getInputWrapperElement());
>> + ElementInfo out =
>> getElementInfo(getOutputWrapperElement());
>> + List<ElementInfo> inChildren = new
>> ArrayList<ElementInfo>();
>> + for (XmlSchemaElement e : getInputChildElements()) {
>> + inChildren.add(getElementInfo(e));
>> + }
>> + List<ElementInfo> outChildren = new
>> ArrayList<ElementInfo>();
>> + if (out != null) {
>> + for (XmlSchemaElement e : getOutputChildElements())
>> {
>> + outChildren.add(getElementInfo(e));
>> + }
>> + }
>> + wrapperInfo =
>> + new WrapperInfo(dataBinding, in, out, inChildren,
>> outChildren);
>> + }
>> + return wrapperInfo;
>> + }
>> + }
>> +
>> + private static ElementInfo getElementInfo(XmlSchemaElement element)
>> {
>> + if (element == null) {
>> + return null;
>> + }
>> + return new ElementInfo(element.getQName(),
>> getTypeInfo(element.getSchemaType()));
>> + }
>> +
>> + private static TypeInfo getTypeInfo(XmlSchemaType type) {
>> + if (type == null) {
>> + return null;
>> + }
>> + XmlSchemaType baseType =
>> (XmlSchemaType)type.getBaseSchemaType();
>> + QName name = type.getQName();
>> + boolean simple = (type instanceof XmlSchemaSimpleType);
>> + if (baseType == null) {
>> + return new TypeInfo(name, simple, null);
>> + } else {
>> + return new TypeInfo(name, simple, getTypeInfo(baseType));
>> + }
>> + }
>> +
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/WSDLOperation.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Added:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java?view=auto&rev=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> (added)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> Tue Apr 10 23:26:26 2007
>> @@ -0,0 +1,87 @@
>> +/*
>> + * 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.tuscany.interfacedef.wsdl.introspect;
>> +
>> +import java.io.IOException;
>> +import java.net.URL;
>> +import java.util.List;
>> +
>> +import javax.wsdl.Definition;
>> +import javax.xml.namespace.QName;
>> +
>> +import org.apache.ws.commons.schema.XmlSchema;
>> +import org.apache.ws.commons.schema.XmlSchemaElement;
>> +import org.apache.ws.commons.schema.XmlSchemaException;
>> +import org.apache.ws.commons.schema.XmlSchemaType;
>> +
>> +/**
>> + * A service for caching XML Schemas
>> + *
>> + * @version $Rev$ $Date$
>> + */
>> +public interface XMLSchemaRegistry {
>> + /**
>> + * Load all inline schemas from the WSDL definition
>> + * + * @param definition The WSDL defintion whose types element
>> contains a list of schemas
>> + * @return A list of inline schemas
>> + */
>> + List<XmlSchema> loadSchemas(Definition definition);
>> + + /**
>> + * Loads and registers a XML schema.
>> + *
>> + * @param namespace the expected namespace, or null if any namespace
>> should be allowed
>> + * @param location the location to load the schema from
>> + * @return the loaded Definition
>> + * @throws IOException if there was a problem reading the document
>> + * @throws XmlSchemaException if there was a problem parsing the
>> schema
>> + */
>> + XmlSchema loadSchema(String namespace, URL location) throws
>> IOException, XmlSchemaException;
>> +
>> + /**
>> + * Load and register a XML schema as specified in a XSD
>> schemaLocation attribute.
>> + *
>> + * @param schemaLocation the value of the schemaLocation attribute
>> + * @param classLoader application classloader used to support
>> relative locations
>> + * @return the loaded schema
>> + * @throws IOException if there was a problem reading the document
>> + * @throws XmlSchemaException if there was a problem parsing the
>> schema
>> + */
>> + XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader)
>> throws IOException, XmlSchemaException;
>> +
>> + /**
>> + * Returns the XSD Element with the supplied qualified name, or null
>> if no such element has been defined.
>> + *
>> + * @param name the qualified name of the XSD element
>> + * @return the XSD element for the supplied name, or null if none
>> has been defined
>> + */
>> + XmlSchemaElement getElement(QName name);
>> +
>> + /**
>> + * Returns the XmlSchemaType with the supplied qualified name, or
>> null if no such type has been defined.
>> + *
>> + * @param name the qualified name of the XSD type
>> + * @return the XSD type for the supplied name, or null if none has
>> been defined
>> + */
>> + XmlSchemaType getType(QName name);
>> +
>> +
>> +
>> +}
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> ------------------------------------------------------------------------------
>> svn:eol-style = native
>>
>> Propchange:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/introspect/XMLSchemaRegistry.java
>> ------------------------------------------------------------------------------
>> svn:keywords = Rev Date
>>
>> Modified:
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?view=diff&rev=527397&r1=527396&r2=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
>> (original)
>> +++
>> incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
>> Tue Apr 10 23:26:26 2007
>> @@ -28,11 +28,15 @@
>> import javax.xml.stream.XMLStreamWriter;
>> import org.apache.tuscany.assembly.xml.Constants;
>> +import org.apache.tuscany.interfacedef.InvalidInterfaceException;
>> import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
>> import org.apache.tuscany.interfacedef.wsdl.WSDLFactory;
>> import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
>> import org.apache.tuscany.interfacedef.wsdl.WSDLInterfaceContract;
>> import org.apache.tuscany.interfacedef.wsdl.impl.DefaultWSDLFactory;
>> +import
>> org.apache.tuscany.interfacedef.wsdl.introspect.DefaultWSDLInterfaceIntrospector;
>> +import
>> org.apache.tuscany.interfacedef.wsdl.introspect.DefaultXMLSchemaRegistry;
>> +import
>> org.apache.tuscany.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector;
>> import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
>> import
>> org.apache.tuscany.services.spi.contribution.ContributionReadException;
>> import
>> org.apache.tuscany.services.spi.contribution.ContributionResolveException;
>> @@ -43,13 +47,15 @@
>> public class WSDLInterfaceProcessor implements
>> StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants {
>> private WSDLFactory wsdlFactory;
>> + private WSDLInterfaceIntrospector wsdlIntrospector;
>> - public WSDLInterfaceProcessor(WSDLFactory wsdlFactory) {
>> + public WSDLInterfaceProcessor(WSDLFactory wsdlFactory,
>> WSDLInterfaceIntrospector wsdlIntrospector) {
>> this.wsdlFactory = wsdlFactory;
>> + this.wsdlIntrospector = wsdlIntrospector;
>> }
>> public WSDLInterfaceProcessor() {
>> - this(new DefaultWSDLFactory());
>> + this(new DefaultWSDLFactory(), new
>> DefaultWSDLInterfaceIntrospector(new DefaultXMLSchemaRegistry()));
>> }
>> /**
>> @@ -143,7 +149,7 @@
>> }
>> }
>> - private WSDLInterface resolveWSDLInterface(WSDLInterface
>> wsdlInterface, ArtifactResolver resolver) {
>> + private WSDLInterface resolveWSDLInterface(WSDLInterface
>> wsdlInterface, ArtifactResolver resolver) throws
>> ContributionResolveException {
>> if (wsdlInterface != null && wsdlInterface.isUnresolved()) {
>> @@ -160,15 +166,13 @@
>> PortType portType =
>> wsdlDefinition.getDefinition().getPortType(wsdlInterface.getName());
>> if (portType != null) {
>> - // Add the resolved
>> WSDL interface to the resolver
>> - // so that it's found next time
>> - wsdlInterface.setPortType(portType);
>> - - // Introspect the WSDL
>> portType and populate the interface and
>> - // operations
>> - //FIXME
>> - -
>> wsdlInterface.setUnresolved(false);
>> + // Introspect the WSDL portType and add the
>> resulting
>> + // WSDLInterface to the resolver
>> + try {
>> + wsdlInterface =
>> wsdlIntrospector.introspect(portType);
>> + } catch (InvalidInterfaceException e) {
>> + throw new ContributionResolveException(e);
>> + }
>> resolver.add(wsdlInterface);
>> }
>> }
>>
>> Modified: incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml?view=diff&rev=527397&r1=527396&r2=527397
>> ==============================================================================
>> --- incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml (original)
>> +++ incubator/tuscany/java/sca/modules/interface-wsdl/pom.xml Tue Apr 10
>> 23:26:26 2007
>> @@ -34,6 +34,12 @@
>> <artifactId>tuscany-interface</artifactId>
>> <version>1.0-incubating-SNAPSHOT</version>
>> </dependency>
>> + + <dependency>
>> + <groupId>org.apache.ws.commons.schema</groupId>
>> + <artifactId>XmlSchema</artifactId>
>> + <version>1.2</version>
>> + </dependency>
>> <dependency>
>> <groupId>wsdl4j</groupId>
>>
>> Modified:
>> incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java?view=diff&rev=527397&r1=527396&r2=527397
>> ==============================================================================
>> ---
>> incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
>> (original)
>> +++
>> incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/interfacedef/util/WrapperInfo.java
>> Tue Apr 10 23:26:26 2007
>> @@ -56,7 +56,7 @@
>> private List<ElementInfo> outputChildElements;
>> - private DataType<List<DataType<XMLType>>> unwrappedInputType;
>> + private DataType<List<DataType>> unwrappedInputType;
>> private DataType<XMLType> unwrappedOutputType;
>> @@ -106,14 +106,14 @@
>> /**
>> * @return the unwrappedInputType
>> */
>> - public DataType<List<DataType<XMLType>>> getUnwrappedInputType() {
>> + public DataType<List<DataType>> getUnwrappedInputType() {
>> if (unwrappedInputType == null) {
>> - List<DataType<XMLType>> childTypes = new
>> ArrayList<DataType<XMLType>>();
>> + List<DataType> childTypes = new ArrayList<DataType>();
>> for (ElementInfo element : getInputChildElements()) {
>> DataType<XMLType> type = new
>> DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
>> childTypes.add(type);
>> }
>> - unwrappedInputType = new
>> DataTypeImpl<List<DataType<XMLType>>>("idl:unwrapped.input",
>> Object[].class,
>> + unwrappedInputType = new
>> DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class,
>>
>> childTypes);
>> }
>> return unwrappedInputType;
>> @@ -122,7 +122,7 @@
>> /**
>> * @return the unwrappedOutputType
>> */
>> - public DataType<XMLType> getUnwrappedOutputType() {
>> + public DataType getUnwrappedOutputType() {
>> if (unwrappedOutputType == null) {
>> List<ElementInfo> elements = getOutputChildElements();
>> if (elements != null && elements.size() > 0) {
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-commits-help@ws.apache.org
>>
>>
>>
>
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org