diff options
Diffstat (limited to 'sca-java-2.x/trunk')
14 files changed, 265 insertions, 73 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 86c18378b8..fdea709b9a 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -85,6 +85,8 @@ import org.apache.tuscany.sca.xsd.XSDFactory; import org.apache.tuscany.sca.xsd.XSDefinition; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.ws.commons.schema.XmlSchemaComplexContent; +import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension; import org.apache.ws.commons.schema.XmlSchemaComplexType; import org.apache.ws.commons.schema.XmlSchemaElement; import org.apache.ws.commons.schema.XmlSchemaException; @@ -197,10 +199,11 @@ public class Interface2WSDLGenerator { if (db == null) { return null; } - if ("java:array".equals(db)) { - DataType dt = (DataType)type.getLogical(); - db = dt.getDataBinding(); - } + // TUSCANY-3800 + while ("java:array".equals(db)) { + type = (DataType)type.getLogical(); + db = type.getDataBinding(); + } return helpers.get(db); } @@ -373,7 +376,7 @@ public class Interface2WSDLGenerator { // call each helper in turn to populate the wsdl.types element XmlSchemaCollection schemaCollection = new XmlSchemaCollection(); - // TUSCANY-3283 - "true" here means also generate the include the wrapper types for xsd generation using JAXB + // TUSCANY-3283 - "true" here means also generate the wrapper types using JAXB Map<XMLTypeHelper, List<DataType>> dataTypes = getDataTypes(interfaze, true, helpers); for (Map.Entry<XMLTypeHelper, List<DataType>> en: dataTypes.entrySet()) { XMLTypeHelper helper = en.getKey(); @@ -387,7 +390,9 @@ public class Interface2WSDLGenerator { mergeNoNamespaceSchema(namespaceURI, xsDefinitions); for (XSDefinition xsDef: xsDefinitions) { - addSchemaExtension(xsDef, schemaCollection, wsdlDefinition, definition); + //addSchemaExtension(xsDef, schemaCollection, wsdlDefinition, definition); + loadXSD(schemaCollection, xsDef); + wsdlDefinition.getXmlSchemas().add(xsDef); } } @@ -397,10 +402,17 @@ public class Interface2WSDLGenerator { wrappers.remove(wrapperName); } } + + // below we might generate wrapper schema into a DOM. If the schema are in a namespace + // that is already been loaded then we need to throw away the schema collection and reload + // it because you can't load a DOM into a schema collection if the schema for the namespace + // has already been loaded + boolean reloadSchema = false; // generate schema elements for wrappers that aren't defined in the schemas // TUSCANY-3283 - as we're generating wrappers with JAXB it won't - // go through here for all wrappers??? + // go through here for all wrappers. It will just have to do there ones + // where there is no JAXB mapping for the child types, e.g. SDO DataObject if (wrappers.size() > 0) { int i = 0; int index = 0; @@ -415,24 +427,25 @@ public class Interface2WSDLGenerator { schemaDoc = xsDef.getDocument(); schema = schemaDoc.getDocumentElement(); } else { - // TUSCANY-3283 - if we have to generate a new check to see if the + // TUSCANY-3283 - if we have to generate a new schema check to see if the // WSDL doc already has a schema in this namespace -// xsDef = wsdlDefinition.getSchema(targetNS); -// if (xsDef != null) { -// schemaDoc = xsDef.getDocument(); -// schema = schemaDoc.getDocumentElement(); -// wrapperXSDs.put(targetNS, xsDef); -// Map<String, String> prefixMap = prefixMaps.get(schema); -// if (prefixMap == null){ -// prefixMap = new HashMap<String, String>(); -// prefixMaps.put(schema, prefixMap); -// String [] prefixes = xsDef.getSchema().getNamespaceContext().getDeclaredPrefixes(); -// for (int j = 0; j < prefixes.length; j++){ -// prefixMap.put(xsDef.getSchema().getNamespaceContext().getNamespaceURI(prefixes[j]), -// prefixes[j]); -// } -// } -// } else { + xsDef = wsdlDefinition.getSchema(targetNS); + if (xsDef != null) { + schemaDoc = xsDef.getDocument(); + schema = schemaDoc.getDocumentElement(); + //wrapperXSDs.put(targetNS, xsDef); + Map<String, String> prefixMap = prefixMaps.get(schema); + if (prefixMap == null){ + prefixMap = new HashMap<String, String>(); + prefixMaps.put(schema, prefixMap); + String [] prefixes = xsDef.getSchema().getNamespaceContext().getDeclaredPrefixes(); + for (int j = 0; j < prefixes.length; j++){ + prefixMap.put(xsDef.getSchema().getNamespaceContext().getNamespaceURI(prefixes[j]), + prefixes[j]); + } + } + reloadSchema = true; + } else { schemaDoc = createDocument(); schema = schemaDoc.createElementNS(SCHEMA_NS, "xs:schema"); // The elementFormDefault should be set to unqualified, see TUSCANY-2388 @@ -441,8 +454,9 @@ public class Interface2WSDLGenerator { schema.setAttribute("targetNamespace", targetNS); schema.setAttributeNS(XMLNS_NS, "xmlns:xs", SCHEMA_NS); schemaDoc.appendChild(schema); - Schema schemaExt = createSchemaExt(definition); - schemaExt.setElement(schema); + // TUSCANY-3283 - the extension is created at the bottom + //Schema schemaExt = createSchemaExt(definition); + //schemaExt.setElement(schema); prefixMaps.put(schema, new HashMap<String, String>()); xsDef = xsdFactory.createXSDefinition(); xsDef.setUnresolved(true); @@ -452,7 +466,8 @@ public class Interface2WSDLGenerator { xsDef.setLocation(URI.create("xsd_" + index + ".xsd")); index++; wrapperXSDs.put(targetNS, xsDef); -// } + wsdlDefinition.getXmlSchemas().add(xsDef); + } } Element wrapper = schemaDoc.createElementNS(SCHEMA_NS, "xs:element"); schema.appendChild(wrapper); @@ -523,13 +538,19 @@ public class Interface2WSDLGenerator { } } } - - // resolve XSDefinitions containing generated wrappers - for (XSDefinition xsDef: wrapperXSDs.values()) { - loadXSD(schemaCollection, xsDef); - wsdlDefinition.getXmlSchemas().add(xsDef); + } + + if (reloadSchema){ + schemaCollection = new XmlSchemaCollection(); + for (XSDefinition xsDef: wsdlDefinition.getXmlSchemas()){ + xsDef.setSchema(null); + xsDef.setSchemaCollection(null); } } + + for (XSDefinition xsDef: wsdlDefinition.getXmlSchemas()){ + addSchemaExtension(xsDef, schemaCollection, wsdlDefinition, definition); + } return definition; } @@ -618,6 +639,7 @@ public class Interface2WSDLGenerator { // copy all the FROM items to the TO schema XmlSchemaObjectCollection fromItems = fromSchema.getItems(); XmlSchemaObjectCollection toItems = toSchema.getItems(); + List<XmlSchemaObject> movedItems = new ArrayList<XmlSchemaObject>(); Iterator<XmlSchemaObject> iter = fromItems.getIterator(); while(iter.hasNext()){ @@ -628,16 +650,20 @@ public class Interface2WSDLGenerator { // do nothing } else { toItems.add(obj); - // correct any references to the item just moved - fixUpMovedTypeReferences(fromNamespace, toNamespace, obj, resultSchema); + movedItems.add(obj); } } + // check that all types in the TO namespace are now referred to correctly across the schema + for(XmlSchemaObject obj : movedItems){ + fixUpMovedTypeReferences(fromNamespace, toNamespace, obj, resultSchema); + } + return resultSchema; } // TUSCANY-3283 - fix up any references to types moved to the default namespace schema - public void fixUpMovedTypeReferences(String fromNamespace, String toNamespace, XmlSchemaObject fixUpObj, List<org.apache.ws.commons.schema.XmlSchema> relatedSchema){ + public void fixUpMovedTypeReferences(String fromNamespace, String toNamespace, XmlSchemaObject fixUpObj, List<XmlSchema> relatedSchema){ if (!(fixUpObj instanceof XmlSchemaComplexType)){ return; @@ -648,11 +674,7 @@ public class Interface2WSDLGenerator { for (int i = 0; i < schema.getItems().getCount(); i++){ XmlSchemaObject obj = schema.getItems().getItem(i); - // if this is not the TO schema then fix up all references - // to items moved to the TO schema - if(!schema.getTargetNamespace().equals(toNamespace)){ - processXMLSchemaObject(toNamespace, obj, fixUpObj); - } + processXMLSchemaObject(toNamespace, obj, fixUpObj); // remove FROM imports if (obj instanceof XmlSchemaImport && @@ -671,6 +693,9 @@ public class Interface2WSDLGenerator { public void processXMLSchemaObject(String toNamespace, XmlSchemaObject obj, XmlSchemaObject fixUpObj){ if (obj instanceof XmlSchemaComplexType){ processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getParticle(), fixUpObj); + processXMLSchemaObject(toNamespace, ((XmlSchemaComplexType)obj).getContentModel(), fixUpObj); + } else if (obj instanceof XmlSchemaComplexContent){ + processXMLSchemaObject(toNamespace, ((XmlSchemaComplexContent)obj).getContent(), fixUpObj); } else if (obj instanceof XmlSchemaElement){ XmlSchemaElement element = (XmlSchemaElement)obj; if(element.getSchemaType() == fixUpObj){ @@ -685,6 +710,11 @@ public class Interface2WSDLGenerator { while(iter.hasNext()){ processXMLSchemaObject(toNamespace, iter.next(), fixUpObj); } + } else if (obj instanceof XmlSchemaComplexContentExtension){ + XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)obj; + QName name = extension.getBaseTypeName(); + QName newName = new QName(toNamespace, name.getLocalPart()); + extension.setBaseTypeName(newName); } // TODO - what other structure items will be generated by JAXB? } @@ -765,7 +795,7 @@ public class Interface2WSDLGenerator { } } loadXSD(schemaCollection, xsDef); - wsdlDefinition.getXmlSchemas().add(xsDef); + //wsdlDefinition.getXmlSchemas().add(xsDef); Element schema = document.getDocumentElement(); Schema schemaExt = createSchemaExt(definition); schemaExt.setDocumentBaseURI(document.getDocumentURI()); @@ -1062,6 +1092,12 @@ public class Interface2WSDLGenerator { element.setMany(javaType.isArray()); } + // TUSCANY-3298: Check the "many" flag set by databinding introspection + Object logical = dataType.getLogical(); + if (logical instanceof XMLType && ((XMLType)logical).isMany()) { + element.setMany(true); + } + element.setNillable(!javaType.isPrimitive()); return element; } diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java index 3fb405064b..dfb6827762 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java @@ -113,13 +113,28 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> for (int i = 0; i < list1.size(); i++) { String n1 = list1.get(i).getQName().getLocalPart(); String n2 = list2.get(i).getQName().getLocalPart(); - if (!n1.equals(n2)) { + // TUSCANY-3298: In the following situation: + // 1. The child is a java.util.Map type + // 2. The child's name is a Java keyword (e.g., return) + // 3. Tuscany is using a generated JAXB wrapper class for WSDL generation + // the Java to WSDL generation process results in the WSDL element name + // having a leading underscore added to the actual element name. This is + // because of a known JAXB issue that prevents the @XmlElement annotation + // being used on a java.util.Map type property field in the wrapper bean + // (see https://jaxb.dev.java.net/issues/show_bug.cgi?id=268). + // To prevent the compatibility match from failing in this situation, + // we strip any leading underscore before doing the comparison. + if (!stripLeadingUnderscore(n1).equals(stripLeadingUnderscore(n2))) { return false; } } return true; } + private static String stripLeadingUnderscore(String name) { + return name.startsWith("_") ? name.substring(1) : name; + } + @SuppressWarnings("unchecked") public Object[] transform(Object[] source, TransformationContext context) { // Check if the source operation is wrapped diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java index f59666127d..b12d75e513 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java @@ -139,23 +139,27 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im String n1 = list1.get(i).getQName().getLocalPart(); String n2 = list2.get(i).getQName().getLocalPart(); - // TUSCANY-3283 - strip off any leading "_" characters for this comparison. - // Now we generate wrappers with JAXB it names the response - // wrapper's child as "_return" - if (n1.startsWith("_")){ - n1 = n1.substring(1); - } - - if (n2.startsWith("_")){ - n2 = n2.substring(1); - } - - if (!n1.equals(n2)) { + // TUSCANY-3298: In the following situation: + // 1. The child is a java.util.Map type + // 2. The child's name is a Java keyword (e.g., return) + // 3. Tuscany is using a generated JAXB wrapper class for WSDL generation + // the Java to WSDL generation process results in the WSDL element name + // having a leading underscore added to the actual element name. This is + // because of a known JAXB issue that prevents the @XmlElement annotation + // being used on a java.util.Map type property field in the wrapper bean + // (see https://jaxb.dev.java.net/issues/show_bug.cgi?id=268). + // To prevent the compatibility match from failing in this situation, + // we strip any leading underscore before doing the comparison. + if (!stripLeadingUnderscore(n1).equals(stripLeadingUnderscore(n2))) { return false; } } return true; } + + private static String stripLeadingUnderscore(String name) { + return name.startsWith("_") ? name.substring(1) : name; + } @SuppressWarnings("unchecked") public Object transform(Object response, TransformationContext context) { diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java index 0003e7d46f..ef46a2b3c7 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java @@ -19,8 +19,10 @@ package org.apache.tuscany.sca.databinding.sdo; +import java.lang.reflect.ParameterizedType; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Collection; import javax.xml.namespace.QName; @@ -62,7 +64,7 @@ public class SDODataBinding extends BaseDataBinding { @Override public boolean introspect(DataType dataType, final Operation operation) { - final Class javaType = dataType.getPhysical(); + Class javaType = dataType.getPhysical(); // Allow privileged access to read system properties. Requires PropertyPermission // java.specification.version read in security policy. final HelperContext context = AccessController.doPrivileged(new PrivilegedAction<HelperContext>() { @@ -74,11 +76,33 @@ public class SDODataBinding extends BaseDataBinding { final Type type = context.getTypeHelper().getType(javaType); if (type == null) { // FIXME: Need a better to test dynamic SDO + // TUSCANY-3298: get underlying element type for collections + boolean isMany = false; + if (Collection.class.isAssignableFrom(javaType)) { + java.lang.reflect.Type genericType = dataType.getGenericType(); + if (genericType instanceof ParameterizedType) { + java.lang.reflect.Type actualType = ((ParameterizedType)genericType).getActualTypeArguments()[0]; + if (actualType instanceof Class) { + javaType = (Class)actualType; + isMany = true; + } + } + } if (DataObject.class.isAssignableFrom(javaType)) { // Dynamic SDO dataType.setDataBinding(getName()); - if (dataType.getLogical() == null) { - dataType.setLogical(XMLType.UNKNOWN); + // TUSCANY-3298: use XMLType many value to indicate a collection + Object logical = dataType.getLogical(); + if (logical == null) { + if (!isMany) { + dataType.setLogical(XMLType.UNKNOWN); + } else { + XMLType xmlType = new XMLType(null, null); + xmlType.setMany(true); + dataType.setLogical(xmlType); + } + } else if (logical instanceof XMLType && isMany) { + ((XMLType)logical).setMany(true); } return true; } diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java index dc1b3fc4fa..4c2075fcc4 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java @@ -32,6 +32,7 @@ import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.databinding.XMLTypeHelper; +import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; @@ -91,8 +92,8 @@ public class SDOTypeHelper implements XMLTypeHelper { xmlType = ((XMLType)logical).getTypeName(); } if (xmlType == null) { - xmlType = - new QName(JavaXMLMapper.getNamespace(javaType), Introspector.decapitalize(javaType.getSimpleName())); + // TUSCANY-3298: dynamic SDO or collection of dynamic SDO + return new TypeInfo(SimpleTypeMapperImpl.XSD_ANYTYPE, true, null); } return new TypeInfo(xmlType, false, null); } diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer index b1916fd32a..a172eef34b 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer @@ -17,11 +17,11 @@ # Implementation classes for the transformers org.apache.tuscany.sca.databinding.sdo.DataObject2String;source=commonj.sdo.DataObject,target=java.lang.String,weight=510 -org.apache.tuscany.sca.databinding.sdo.DataObject2XMLStreamReader;source=commonj.sdo.DataObject,target=javax.xml.stream.XMLStreamReader,weight=490 -org.apache.tuscany.sca.databinding.sdo.XMLDocument2String;source=commonj.sdo.helper.XMLDocument,target=java.lang.String,weight=510 +#org.apache.tuscany.sca.databinding.sdo.DataObject2XMLStreamReader;source=commonj.sdo.DataObject,target=javax.xml.stream.XMLStreamReader,weight=490 +#org.apache.tuscany.sca.databinding.sdo.XMLDocument2String;source=commonj.sdo.helper.XMLDocument,target=java.lang.String,weight=510 org.apache.tuscany.sca.databinding.sdo.String2DataObject;source=java.lang.String,target=commonj.sdo.DataObject,weight=500 -org.apache.tuscany.sca.databinding.sdo.XMLDocument2XMLStreamReader;source=commonj.sdo.helper.XMLDocument,target=javax.xml.stream.XMLStreamReader,weight=490 -org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2DataObject;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.DataObject,weight=490 -org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2XMLDocument;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.helper.XMLDocument,weight=490 -org.apache.tuscany.sca.databinding.sdo.DataObject2Node;source=commonj.sdo.DataObject,target=org.w3c.dom.Node,weight=500 -org.apache.tuscany.sca.databinding.sdo.Node2DataObject;source=org.w3c.dom.Node,target=commonj.sdo.DataObject,weight=500 +#org.apache.tuscany.sca.databinding.sdo.XMLDocument2XMLStreamReader;source=commonj.sdo.helper.XMLDocument,target=javax.xml.stream.XMLStreamReader,weight=490 +#org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2DataObject;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.DataObject,weight=490 +#org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2XMLDocument;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.helper.XMLDocument,weight=490 +#org.apache.tuscany.sca.databinding.sdo.DataObject2Node;source=commonj.sdo.DataObject,target=org.w3c.dom.Node,weight=500 +#org.apache.tuscany.sca.databinding.sdo.Node2DataObject;source=org.w3c.dom.Node,target=commonj.sdo.DataObject,weight=500 diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedClient.composite b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedClient.composite new file mode 100644 index 0000000000..44074bf719 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedClient.composite @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo" targetNamespace="http://foo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ name="MatchWSDistributedClient" >
+
+ <component name="DistributedClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl" />
+ <reference name="aCallBackService" target="DistributedServiceComponent" />
+ </component>
+
+</composite>
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedService.composite b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedService.composite new file mode 100644 index 0000000000..981f5d172c --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedService.composite @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo" targetNamespace="http://foo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ name="MatchWSDistributedService" >
+
+ <component name="DistributedServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl" />
+ <service name="ServiceComponent">
+ <binding.ws/>
+ </service>
+ </component>
+</composite>
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java index f4d5f009ed..28b1bc442f 100644 --- a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java @@ -208,5 +208,53 @@ public class InerfaceMatchTestCase { node1.stop();
node2.stop();
+ }
+
+ /**
+ * Remotable client and service interfaces where the interfaces match.
+ * Components running in the separate composite/JVM, i.e. there is a remote registry
+ * and with binding.ws explicitly configured at the service
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWSDistributedRemotable() throws Exception {
+
+
+ String [] contributions = {"./target/classes"};
+ Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
+ "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedClient.composite",
+ contributions);
+ node1.start();
+
+ Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"),
+ "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchWSDistributedService.composite",
+ contributions);
+
+ // force default binding on node2 to use a different port from node 1(which will default to 8080)
+ ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
+ ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
+ node2.start();
+
+ ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
+ ParameterObject po = new ParameterObject();
+
+ try {
+ String response = local.foo1(po);
+ Assert.assertEquals("AComponent", response);
+ } catch (ServiceRuntimeException ex){
+ Assert.fail("Unexpected exception with foo " + ex.toString());
+ }
+
+ try {
+ local.callback("Callback");
+ String response = local.getCallbackValue();
+ Assert.assertEquals("Callback", response);
+ } catch (ServiceRuntimeException ex){
+ Assert.fail("Unexpected exception with callback" + ex.toString());
+ }
+
+ node1.stop();
+ node2.stop();
}
}
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/java/datatypes/impl/GetDataServiceWithoutExceptionImpl.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/java/datatypes/impl/GetDataServiceWithoutExceptionImpl.java index 3b597e9e8e..d28df3fbdd 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/java/datatypes/impl/GetDataServiceWithoutExceptionImpl.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/java/datatypes/impl/GetDataServiceWithoutExceptionImpl.java @@ -37,7 +37,7 @@ public class GetDataServiceWithoutExceptionImpl implements GetDataServiceWithout public DataObject getMessageSDO(String paramString) {
return null;
}
-
+
public List<DataObject> getMessageListSDOList(String paramString) {
return null;
}
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/resources/helloworld.composite index 0f668613d9..52b957d4a6 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/resources/helloworld.composite +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/main/resources/helloworld.composite @@ -27,7 +27,7 @@ <implementation.java class="helloworld.HelloWorldClientImpl" />
<service name="HelloWorldService">
<binding.sca/>
- </service>
+ </service>
<reference name="hwService">
<binding.ws uri="http://localhost:8085/HelloWorldServiceComponent"/>
</reference>
@@ -45,13 +45,11 @@ gen'd WSDL by setting the service interface to the RI WSDL. Tuscany should
generate a WSDL for the component and compare the two for compatibility
-->
-<!--
<component name="HelloWorldServiceCompatibilityComponent">
<implementation.java class="helloworld.HelloWorldImpl" />
<service name="HelloWorldService">
<interface.wsdl interface="http://helloworld/#wsdl.interface(HelloWorldImpl)"/>
- <binding.ws uri="http://localhost:8085/HelloWorldServiceComponent"/>
+ <binding.ws uri="http://localhost:8085/HelloWorldServiceCompatibilityComponent"/>
</service>
</component>
- -->
</composite>
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java index 7132e6a77e..75a4c300b4 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DataTypesTestCase.java @@ -31,7 +31,7 @@ import static org.junit.Assert.assertEquals; *
* @version $Rev: 814373 $ $Date: 2009-09-13 19:06:29 +0100 (Sun, 13 Sep 2009) $
*/
-@Ignore("In the process of porting from 1.x")
+//@Ignore("In the process of porting from 1.x")
public class DataTypesTestCase extends BaseFramework {
@Test
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java index 4a621c7498..1254d147ee 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/datatypes/DynamicSDOTestCase.java @@ -31,7 +31,7 @@ import static org.junit.Assert.assertEquals; *
* @version $Rev: 814373 $ $Date: 2009-09-13 19:06:29 +0100 (Sun, 13 Sep 2009) $
*/
-@Ignore("In the process of porting from 1.x")
+//@Ignore("In the process of porting from 1.x")
public class DynamicSDOTestCase extends BaseFramework {
@Test
diff --git a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java index 6fb6d89068..7fabf4cc92 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/ws/wsdlgen/src/test/java/helloworld/WSDLGenTestCase.java @@ -86,6 +86,13 @@ public class WSDLGenTestCase{ abean.setField3(bbean);
assertEquals("Hello Hello 3 4 1 2", helloWorldClient.getGreetingsDBean(abean));
+
+ try {
+ helloWorldClient.getGreetingsException("Fred");
+ fail("exception not returned");
+ } catch(Exception ex) {
+
+ }
}
@Test
|