From 0f3f9b59b310833f31ba234ee4aefa808649833c Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:50 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835120 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/interface-wsdl-xml/.checkstyle | 24 + .../sca-java-0.91/modules/interface-wsdl-xml/.pmd | 20 + .../modules/interface-wsdl-xml/.ruleset | 190 +++++++ .../modules/interface-wsdl-xml/DISCLAIMER | 8 + .../modules/interface-wsdl-xml/LICENSE | 205 ++++++++ .../modules/interface-wsdl-xml/NOTICE | 6 + .../modules/interface-wsdl-xml/pom.xml | 50 ++ .../DefaultWSDLInterfaceIntrospector.java | 66 +++ .../wsdl/introspect/InvalidWSDLException.java | 35 ++ .../wsdl/introspect/WSDLInterfaceIntrospector.java | 43 ++ .../wsdl/introspect/WSDLOperation.java | 556 +++++++++++++++++++++ .../sca/interfacedef/wsdl/xml/WSDLConstants.java | 35 ++ .../wsdl/xml/WSDLDocumentProcessor.java | 190 +++++++ .../wsdl/xml/WSDLInterfaceProcessor.java | 195 ++++++++ .../wsdl/xml/XSDDocumentProcessor.java | 103 ++++ .../DefaultWSDLInterfaceIntrospectorTestCase.java | 85 ++++ .../wsdl/introspect/TestModelResolver.java | 63 +++ .../wsdl/introspect/WSDLOperationTestCase.java | 124 +++++ .../introspect/WrapperStyleOperationTestCase.java | 81 +++ .../sca/interfacedef/wsdl/xml/ReadTestCase.java | 118 +++++ .../sca/interfacedef/wsdl/xml/WSDLTestCase.java | 67 +++ .../sca/interfacedef/wsdl/xml/WriteTestCase.java | 108 ++++ .../sca/interfacedef/wsdl/xml/Calculator.composite | 55 ++ .../wsdl/xml/CalculatorComponent.constrainingType | 36 ++ .../wsdl/xml/CalculatorImpl.componentType | 33 ++ .../tuscany/sca/interfacedef/wsdl/xml/example.wsdl | 26 + .../interfacedef/wsdl/xml/invalid-stockquote.wsdl | 58 +++ .../tuscany/sca/interfacedef/wsdl/xml/ipo.xsd | 136 +++++ .../sca/interfacedef/wsdl/xml/stockquote.wsdl | 58 +++ .../tuscany/sca/interfacedef/wsdl/xml/test1.wsdl | 45 ++ .../tuscany/sca/interfacedef/wsdl/xml/test1.xsd | 33 ++ .../tuscany/sca/interfacedef/wsdl/xml/test2.wsdl | 63 +++ .../wsdl/xml/unwrapped-stockquote.wsdl | 76 +++ 33 files changed, 2991 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.checkstyle create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.pmd create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.ruleset create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/DISCLAIMER create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/InvalidWSDLException.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperation.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDDocumentProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorComponent.constrainingType create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl (limited to 'sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml') diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.checkstyle b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.checkstyle new file mode 100644 index 0000000000..e3c216986d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.checkstyle @@ -0,0 +1,24 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.pmd b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.pmd new file mode 100644 index 0000000000..2db10d6a6a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.pmd @@ -0,0 +1,20 @@ + + +truefalse \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.ruleset b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.ruleset new file mode 100644 index 0000000000..ba9b5ce886 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/DISCLAIMER b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/DISCLAIMER new file mode 100644 index 0000000000..d68a410903 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/DISCLAIMER @@ -0,0 +1,8 @@ +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/LICENSE b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/NOTICE b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/NOTICE new file mode 100644 index 0000000000..94481d6cfa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/pom.xml b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/pom.xml new file mode 100644 index 0000000000..0f7e3ef949 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 0.91-incubating-SNAPSHOT + ../pom.xml + + tuscany-interface-wsdl-xml + Apache Tuscany SCA XML WSDL Interface Extension + + + + org.apache.tuscany.sca + tuscany-contribution + 0.91-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 0.91-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 0.91-incubating-SNAPSHOT + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java new file mode 100644 index 0000000000..5d77d458ce --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospector.java @@ -0,0 +1,66 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import java.util.ArrayList; +import java.util.List; + +import javax.wsdl.PortType; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.ws.commons.schema.XmlSchemaCollection; + +/** + * Introspector for creating WSDLInterface definitions from WSDL PortTypes. + */ +public class DefaultWSDLInterfaceIntrospector implements WSDLInterfaceIntrospector { + + private WSDLFactory wsdlFactory; + + public DefaultWSDLInterfaceIntrospector(WSDLFactory wsdlFactory) { + super(); + this.wsdlFactory = wsdlFactory; + } + + // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS spec? + protected List introspectOperations(PortType portType, XmlSchemaCollection inlineSchemas, ModelResolver resolver) throws InvalidInterfaceException { + List operations = new ArrayList(); + for (Object o : portType.getOperations()) { + javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)o; + WSDLOperation op = new WSDLOperation(wsdlFactory, wsdlOp, inlineSchemas, null, resolver); + operations.add(op.getOperation()); + } + return operations; + } + + public WSDLInterface introspect(PortType portType, XmlSchemaCollection inlineSchemas, ModelResolver resolver) throws InvalidInterfaceException { + WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface(); + wsdlInterface.setPortType(portType); + wsdlInterface.getOperations().addAll(introspectOperations(portType, inlineSchemas, resolver)); + // FIXME: set to Non-conversational for now + wsdlInterface.setConversational(false); + return wsdlInterface; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/InvalidWSDLException.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/InvalidWSDLException.java new file mode 100644 index 0000000000..20780df23e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/InvalidWSDLException.java @@ -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.sca.interfacedef.wsdl.introspect; + +import org.apache.tuscany.sca.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); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java new file mode 100644 index 0000000000..075c41b3b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospector.java @@ -0,0 +1,43 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import javax.wsdl.PortType; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.ws.commons.schema.XmlSchemaCollection; + +/** + * 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, XmlSchemaCollection inlineSchemas, ModelResolver resolver) throws InvalidInterfaceException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperation.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperation.java new file mode 100644 index 0000000000..70f56ff8a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperation.java @@ -0,0 +1,556 @@ +/* + * 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.sca.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.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.ConversationSequence; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; +import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; +import org.apache.tuscany.sca.interfacedef.util.ElementInfo; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.interfacedef.util.TypeInfo; +import org.apache.tuscany.sca.interfacedef.util.WrapperInfo; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition; +import org.apache.ws.commons.schema.XmlSchemaCollection; +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 { + private WSDLFactory wsdlFactory; + protected ModelResolver resolver; + protected XmlSchemaCollection inlineSchemas; + protected javax.wsdl.Operation operation; + protected Operation operationModel; + protected DataType> inputType; + protected DataType outputType; + protected List faultTypes; + private String dataBinding; + + /** + * @param operation The WSDL4J operation + * @param dataBinding The default databinding + * @param schemaRegistry The XML Schema registry + */ + public WSDLOperation( + WSDLFactory wsdlFactory, + javax.wsdl.Operation operation, + XmlSchemaCollection inlineSchemas, + String dataBinding, + ModelResolver resolver) { + super(); + this.wsdlFactory = wsdlFactory; + this.operation = operation; + this.inlineSchemas = inlineSchemas; + this.resolver = resolver; + this.dataBinding = dataBinding; + 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> 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 + */ + @SuppressWarnings("unchecked") + public DataType 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 getFaultTypes() throws InvalidWSDLException { + if (faultTypes == null) { + Collection faults = operation.getFaults().values(); + faultTypes = new ArrayList(); + 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> getMessageType(Message message) throws InvalidWSDLException { + List partTypes = new ArrayList(); + if (message != null) { + Collection parts = message.getOrderedParts(null); + for (Object p : parts) { + WSDLPart part = new WSDLPart((Part)p, Object.class); + DataType partType = part.getDataType(); + partTypes.add(partType); + } + } + return new DataTypeImpl>(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.setFaultTypes(getFaultTypes()); + operationModel.setNonBlocking(oneway); + operationModel.setConversationSequence(ConversationSequence.CONVERSATION_NONE); + operationModel.setInputType(getInputType()); + operationModel.setOutputType(getOutputType()); + + operationModel.setWrapperStyle(isWrapperStyle()); + if (isWrapperStyle()) { + WrapperInfo wrapperInfo = getWrapper().getWrapperInfo(); + operationModel.setWrapper(wrapperInfo); + } + } + return operationModel; + } + + private XmlSchemaElement getElement(QName elementName) { + XmlSchemaElement element = inlineSchemas.getElementByQName(elementName); + if (element == null) { + XSDefinition definition = wsdlFactory.createXSDefinition(); + definition.setUnresolved(true); + definition.setNamespace(elementName.getNamespaceURI()); + definition = resolver.resolveModel(XSDefinition.class, definition); + if (definition.getSchema() != null) { + element = definition.getSchema().getElementByName(elementName); + } + } + return element; + } + + private XmlSchemaType getType(QName typeName) { + XmlSchemaType type = inlineSchemas.getTypeByQName(typeName); + if (type == null) { + XSDefinition definition = wsdlFactory.createXSDefinition(); + definition.setNamespace(typeName.getNamespaceURI()); + definition.setUnresolved(true); + definition = resolver.resolveModel(XSDefinition.class, definition); + if (definition.getSchema() != null) { + type = definition.getSchema().getTypeByName(typeName); + } + } + return type; + } + + /** + * Metadata for a WSDL part + */ + public class WSDLPart { + private Part part; + + private XmlSchemaElement element; + + private DataType dataType; + + public WSDLPart(Part part, Class javaType) throws InvalidWSDLException { + this.part = part; + QName elementName = part.getElementName(); + if (elementName != null) { + element = WSDLOperation.this.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 = WSDLOperation.this.getType(typeName); + if (type == null) { + throw new InvalidWSDLException("Type cannot be resolved: " + typeName.toString()); + } + element.setSchemaType(type); + element.setSchemaTypeName(type.getQName()); + } + } + dataType = new DataTypeImpl(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 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.

A WSDL operation qualifies for wrapper style mapping + * only if the following criteria are met: + *

    + *
  • (i) The operation�s input and output messages (if present) each + * contain only a single part + *
  • (ii) The input message part refers to a global element declaration + * whose localname is equal to the operation name + *
  • (iii) The output message part refers to a global element declaration + *
  • (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 + *
  • (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. + *
+ */ + public class Wrapper { + private XmlSchemaElement inputWrapperElement; + + private XmlSchemaElement outputWrapperElement; + + private List inputElements; + + private List outputElements; + +// private DataType>> unwrappedInputType; +// +// private DataType unwrappedOutputType; + + private transient WrapperInfo wrapperInfo; + + private List 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 childElements = new ArrayList(); + 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 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 = 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 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 = WSDLOperation.this.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>> getUnwrappedInputType() throws InvalidWSDLException { + if (unwrappedInputType == null) { + List> childTypes = new ArrayList>(); + for (XmlSchemaElement element : getInputChildElements()) { + DataType type = + new DataType(dataBinding, Object.class, new XMLType(getElementInfo(element))); + // type.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); + childTypes.add(type); + } + unwrappedInputType = + new DataType>>("idl:unwrapped.input", Object[].class, childTypes); + } + return unwrappedInputType; + } + + public DataType getUnwrappedOutputType() throws InvalidServiceContractException { + if (unwrappedOutputType == null) { + List 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(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 inChildren = new ArrayList(); + for (XmlSchemaElement e : getInputChildElements()) { + inChildren.add(getElementInfo(e)); + } + List outChildren = new ArrayList(); + 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)); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java new file mode 100644 index 0000000000..7de5d5349f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java @@ -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.sca.interfacedef.wsdl.xml; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; + +public interface WSDLConstants { + + String INTERFACE_WSDL = "interface.wsdl"; + QName INTERFACE_WSDL_QNAME = new QName(Constants.SCA10_NS, "interface.wsdl"); + String INTERFACE = "interface"; + String CALLBACK_INTERFACE = "callbackInterface"; + String WSDL_LOCATION = "wsdlLocation"; + String WSDLI_NS = "http://www.w3.org/2004/08/wsdl-instance"; + QName WSDL_LOCATION_QNAME = new QName(WSDLI_NS, WSDL_LOCATION); + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java new file mode 100644 index 0000000000..782340982a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java @@ -0,0 +1,190 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; + +import javax.wsdl.Definition; +import javax.wsdl.Types; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensionRegistry; +import javax.wsdl.extensions.schema.Schema; +import javax.wsdl.xml.WSDLLocator; +import javax.wsdl.xml.WSDLReader; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionRuntimeException; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.ws.commons.schema.resolver.URIResolver; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; + +/** + * An ArtifactProcessor for WSDL documents. + * + * @version $Rev$ $Date$ + */ +public class WSDLDocumentProcessor implements URLArtifactProcessor { + + private javax.wsdl.factory.WSDLFactory wsdlFactory; + private ExtensionRegistry wsdlExtensionRegistry; + private WSDLFactory factory; + + /** + * Implementation of a WSDL locator. + */ + private class WSDLLocatorImpl implements WSDLLocator { + private InputStream inputStream; + private URL base; + private String latestImportURI; + + public WSDLLocatorImpl(URL base, InputStream is) { + this.base = base; + this.inputStream = is; + } + + public void close() { + } + + public InputSource getBaseInputSource() { + return new InputSource(inputStream); + } + + public String getBaseURI() { + return base.toString(); + } + + public InputSource getImportInputSource(String parentLocation, String importLocation) { + try { + URL url = new URL(new URL(parentLocation), importLocation); + latestImportURI = url.toString(); + return new InputSource(url.openStream()); + } catch (Exception e) { + throw new ContributionRuntimeException(e); + } + } + + public String getLatestImportURI() { + return latestImportURI; + } + + } + + /** + * URI resolver implementation for xml schema + */ + private class URIResolverImpl implements URIResolver { + + public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace, + java.lang.String schemaLocation, + java.lang.String baseUri) { + try { + URL url = new URL(new URL(baseUri), schemaLocation); + return new InputSource(url.openStream()); + } catch (IOException e) { + return null; + } + } + } + + public WSDLDocumentProcessor(WSDLFactory factory, javax.wsdl.factory.WSDLFactory wsdlFactory) { + this.factory = factory; + + if (wsdlFactory != null) { + this.wsdlFactory = wsdlFactory; + } else { + try { + this.wsdlFactory = javax.wsdl.factory.WSDLFactory.newInstance(); + } catch (WSDLException e) { + throw new ContributionRuntimeException(e); + } + } + + wsdlExtensionRegistry = this.wsdlFactory.newPopulatedExtensionRegistry(); + } + + public WSDLDefinition read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException { + try { + + // Read a WSDL document + InputStream is = artifactURL.openStream(); + WSDLReader reader = wsdlFactory.newWSDLReader(); + reader.setFeature("javax.wsdl.verbose", false); + reader.setExtensionRegistry(wsdlExtensionRegistry); + + WSDLLocatorImpl locator = new WSDLLocatorImpl(artifactURL, is); + Definition definition = reader.readWSDL(locator); + + WSDLDefinition wsdlDefinition = factory.createWSDLDefinition(); + wsdlDefinition.setDefinition(definition); + + // get base uri for any relative schema includes + + + // Read inline schemas + Types types = definition.getTypes(); + if (types != null) { + wsdlDefinition.getInlinedSchemas().setSchemaResolver(new URIResolverImpl()); + for (Object ext : types.getExtensibilityElements()) { + if (ext instanceof Schema) { + Element element = ((Schema)ext).getElement(); + + // TODO: fix to make includes in imported + // schema work. The XmlSchema library was crashing + // because the base uri was not set. This doesn't + // affect imports. Need to check that this + // is the right approach for XSDs included by a + // XSD which is itself imported inline in a WSDL + XmlSchemaCollection schemaCollection = wsdlDefinition.getInlinedSchemas(); + schemaCollection.setBaseUri(((Schema)ext).getDocumentBaseURI()); + + wsdlDefinition.getInlinedSchemas().read(element, element.getBaseURI()); + } + } + } + + return wsdlDefinition; + + } catch (WSDLException e) { + throw new ContributionReadException(e); + } catch (IOException e) { + throw new ContributionReadException(e); + } + } + + public void resolve(WSDLDefinition model, ModelResolver resolver) throws ContributionResolveException { + } + + public String getArtifactType() { + return ".wsdl"; + } + + public Class getModelType() { + return WSDLDefinition.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java new file mode 100644 index 0000000000..9f5c83cda6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java @@ -0,0 +1,195 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import javax.wsdl.PortType; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; +import org.apache.tuscany.sca.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector; + +public class WSDLInterfaceProcessor implements StAXArtifactProcessor, WSDLConstants { + + private WSDLFactory wsdlFactory; + private WSDLInterfaceIntrospector wsdlIntrospector; + + public WSDLInterfaceProcessor(WSDLFactory wsdlFactory, WSDLInterfaceIntrospector wsdlIntrospector) { + this.wsdlFactory = wsdlFactory; + this.wsdlIntrospector = wsdlIntrospector; + } + + /** + * Create a WSDL interface from a URI. + * @param uri + * @return + * @throws ContributionReadException + */ + private WSDLInterface createWSDLInterface(String uri) throws ContributionReadException { + WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface(); + wsdlInterface.setUnresolved(true); + + // Read a qname in the form: + // namespace#wsdl.interface(name) + int index = uri.indexOf('#'); + if (index == -1) { + throw new ContributionReadException("Invalid WSDL interface attribute: " + uri); + } + String namespace = uri.substring(0, index); + String name = uri.substring(index + 1); + name = name.substring("wsdl.interface(".length(), name.length() - 1); + wsdlInterface.setName(new QName(namespace, name)); + + return wsdlInterface; + } + + public WSDLInterfaceContract read(XMLStreamReader reader) throws ContributionReadException { + try { + + // Read an + WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract(); + + // Read wsdlLocation + String location = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION); + wsdlInterfaceContract.setLocation(location); + + String uri = reader.getAttributeValue(null, INTERFACE); + if (uri != null) { + WSDLInterface wsdlInterface = createWSDLInterface(uri); + wsdlInterfaceContract.setInterface(wsdlInterface); + } + + uri = reader.getAttributeValue(null, CALLBACK_INTERFACE); + if (uri != null) { + WSDLInterface wsdlCallbackInterface = createWSDLInterface(uri); + wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface); + } + + // Skip to end element + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName())) { + break; + } + } + return wsdlInterfaceContract; + + } catch (XMLStreamException e) { + throw new ContributionReadException(e); + } + } + + public void write(WSDLInterfaceContract wsdlInterfaceContract, XMLStreamWriter writer) throws ContributionWriteException { + try { + // Write an + writer.writeStartElement(Constants.SCA10_NS, INTERFACE_WSDL); + + // Write interface name + WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface(); + if (wsdlInterface != null) { + QName qname = wsdlInterface.getName(); + String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")"; + writer.writeAttribute(INTERFACE, uri); + } + + WSDLInterface wsdlCallbackInterface = (WSDLInterface)wsdlInterfaceContract.getCallbackInterface(); + if (wsdlCallbackInterface != null) { + QName qname = wsdlCallbackInterface.getName(); + String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")"; + writer.writeAttribute(CALLBACK_INTERFACE, uri); + } + + // Write location + if (wsdlInterfaceContract.getLocation() != null) { + writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation()); + } + + writer.writeEndElement(); + + } catch (XMLStreamException e) { + throw new ContributionWriteException(e); + } + } + + private WSDLInterface resolveWSDLInterface(WSDLInterface wsdlInterface, ModelResolver resolver) throws ContributionResolveException { + + if (wsdlInterface != null && wsdlInterface.isUnresolved()) { + + // Resolve the WSDL interface + wsdlInterface = resolver.resolveModel(WSDLInterface.class, wsdlInterface); + if (wsdlInterface.isUnresolved()) { + + // If the WSDL interface has never been resolved yet, do it now + // First, resolve the WSDL definition for the given namespace + WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); + wsdlDefinition.setUnresolved(true); + wsdlDefinition.setNamespace(wsdlInterface.getName().getNamespaceURI()); + wsdlDefinition = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition); + if (!wsdlDefinition.isUnresolved()) { + PortType portType = wsdlDefinition.getDefinition().getPortType(wsdlInterface.getName()); + if (portType != null) { + + // Introspect the WSDL portType and add the resulting + // WSDLInterface to the resolver + try { + wsdlInterface = wsdlIntrospector.introspect(portType, wsdlDefinition.getInlinedSchemas(), resolver); + } catch (InvalidInterfaceException e) { + throw new ContributionResolveException(e); + } + resolver.addModel(wsdlInterface); + wsdlInterface.setWsdlDefinition(wsdlDefinition); + } + } + } + } + return wsdlInterface; + } + + public void resolve(WSDLInterfaceContract wsdlInterfaceContract, ModelResolver resolver) throws ContributionResolveException { + + // Resolve the interface and callback interface + WSDLInterface wsdlInterface = resolveWSDLInterface((WSDLInterface)wsdlInterfaceContract.getInterface(), resolver); + wsdlInterfaceContract.setInterface(wsdlInterface); + + WSDLInterface wsdlCallbackInterface = resolveWSDLInterface((WSDLInterface)wsdlInterfaceContract.getCallbackInterface(), resolver); + wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface); + } + + public QName getArtifactType() { + return WSDLConstants.INTERFACE_WSDL_QNAME; + } + + public Class getModelType() { + return WSDLInterfaceContract.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDDocumentProcessor.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDDocumentProcessor.java new file mode 100644 index 0000000000..d80f24b74a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDDocumentProcessor.java @@ -0,0 +1,103 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.ws.commons.schema.resolver.URIResolver; +import org.xml.sax.InputSource; + +/** + * An ArtifactProcessor for XSD documents. + * + * @version $Rev$ $Date$ + */ +public class XSDDocumentProcessor implements URLArtifactProcessor { + + private WSDLFactory factory; + + /** + * URI resolver implementation for xml schema + */ + private class URIResolverImpl implements URIResolver { + + public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace, + java.lang.String schemaLocation, + java.lang.String baseUri) { + try { + URL url = new URL(new URL(baseUri), schemaLocation); + return new InputSource(url.openStream()); + } catch (IOException e) { + return null; + } + } + } + + public XSDDocumentProcessor(WSDLFactory factory) { + this.factory = factory; + } + + public XSDefinition read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException { + try { + + // Read an XSD document + InputStream is = artifactURL.openStream(); + try { + + XmlSchemaCollection collection = new XmlSchemaCollection(); + collection.setSchemaResolver(new URIResolverImpl()); + XmlSchema schema = collection.read(new InputStreamReader(is), null); + + XSDefinition xsDefinition = factory.createXSDefinition(); + xsDefinition.setSchema(schema); + + return xsDefinition; + } finally { + is.close(); + } + + } catch (IOException e) { + throw new ContributionReadException(e); + } + } + + public void resolve(XSDefinition model, ModelResolver resolver) throws ContributionResolveException { + } + + public String getArtifactType() { + return ".xsd"; + } + + public Class getModelType() { + return XSDefinition.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java new file mode 100644 index 0000000000..55a9b1a068 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/DefaultWSDLInterfaceIntrospectorTestCase.java @@ -0,0 +1,85 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import java.net.URI; +import java.net.URL; +import java.util.List; + +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; + +/** + * Test case for InterfaceWSDLIntrospectorImpl + */ +public class DefaultWSDLInterfaceIntrospectorTestCase extends TestCase { + private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); + + private WSDLDocumentProcessor registry; + private PortType portType; + private ModelResolver resolver; + private WSDLDefinition definition; + + /** + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + registry = new WSDLDocumentProcessor(new DefaultWSDLFactory(), null); + resolver = new TestModelResolver(getClass().getClassLoader()); + URL url = getClass().getResource("../xml/stockquote.wsdl"); + definition = registry.read(null, new URI("stockquote.wsdl"), url); + portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + } + + @SuppressWarnings("unchecked") + public final void testIntrospectPortType() throws InvalidInterfaceException { + DefaultWSDLInterfaceIntrospector introspector = new DefaultWSDLInterfaceIntrospector(new DefaultWSDLFactory()); + WSDLInterface contract = introspector.introspect(portType, definition.getInlinedSchemas(), resolver); + Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType"); + List operations = contract.getOperations(); + Assert.assertEquals(1, operations.size()); + Operation operation = operations.get(0); + Assert.assertEquals("getLastTradePrice", operation.getName()); + DataType> inputType = operation.getInputType(); + Assert.assertEquals(1, inputType.getLogical().size()); + DataType returnType = operation.getOutputType(); + Assert.assertNotNull(returnType); + Assert.assertEquals(0, operation.getFaultTypes().size()); + // Assert.assertEquals(1, + // operation.getWrapper().getInputChildElements().size()); + // Assert.assertEquals(1, + // operation.getWrapper().getOutputChildElements().size()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java new file mode 100644 index 0000000000..b9a9ba8cfa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java @@ -0,0 +1,63 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; + + +/** + * A default implementation of an artifact resolver, based on a map. + * + * @version $Rev$ $Date$ + */ +public class TestModelResolver implements ModelResolver { + private static final long serialVersionUID = -7826976465762296634L; + + private Map map = new HashMap(); + + public TestModelResolver(ClassLoader classLoader) { + } + + public T resolveModel(Class modelClass, T unresolved) { + Object resolved = map.get(unresolved); + if (resolved != null) { + + // Return the resolved object + return modelClass.cast(resolved); + + } else { + + // Return the unresolved object + return unresolved; + } + } + + public void addModel(Object resolved) { + map.put(resolved, resolved); + } + + public Object removeModel(Object resolved) { + return map.remove(resolved); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationTestCase.java new file mode 100644 index 0000000000..6bf9628390 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationTestCase.java @@ -0,0 +1,124 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import java.net.URI; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Operation; +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; + +/** + * Test case for WSDLOperation + */ +public class WSDLOperationTestCase extends TestCase { + private static final QName PORTTYPE_NAME = + new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); + + private WSDLDocumentProcessor processor; + private ModelResolver resolver; + private WSDLFactory wsdlFactory; + + /** + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + processor = new WSDLDocumentProcessor(new DefaultWSDLFactory(), null); + resolver = new TestModelResolver(getClass().getClassLoader()); + wsdlFactory = new DefaultWSDLFactory(); + } + + @SuppressWarnings("unchecked") + public final void testWrappedOperation() throws Exception { + URL url = getClass().getResource("../xml/stockquote.wsdl"); + WSDLDefinition definition = processor.read(null, new URI("stockquote.wsdl"), url); + PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + Operation operation = portType.getOperation("getLastTradePrice", null, null); + + WSDLOperation op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + + DataType> inputType = op.getInputType(); + Assert.assertEquals(1, inputType.getLogical().size()); + DataType type = inputType.getLogical().get(0); + Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), type.getLogical().getElementName()); + + DataType outputType = op.getOutputType(); + Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"), + outputType.getLogical().getElementName()); + Assert.assertTrue(op.isWrapperStyle()); + + DataType> unwrappedInputType = op.getWrapper().getWrapperInfo().getUnwrappedInputType(); + List childTypes = unwrappedInputType.getLogical(); + Assert.assertEquals(1, childTypes.size()); + DataType childType = childTypes.get(0); + Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName()); + + childType = op.getWrapper().getWrapperInfo().getUnwrappedOutputType(); + Assert.assertEquals(new QName(null, "price"), childType.getLogical().getElementName()); + } + + public final void testUnwrappedOperation() throws Exception { + URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl"); + WSDLDefinition definition = processor.read(null, new URI("unwrapped-stockquote.wsdl"), url); + PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + + Operation operation = portType.getOperation("getLastTradePrice1", null, null); + WSDLOperation op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + Assert.assertFalse(op.isWrapperStyle()); + Assert.assertEquals(1, op.getInputType().getLogical().size()); + + operation = portType.getOperation("getLastTradePrice2", null, null); + op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + Assert.assertFalse(op.isWrapperStyle()); + Assert.assertEquals(2, op.getInputType().getLogical().size()); + } + + public final void testInvalidWSDL() throws Exception { + URL url = getClass().getResource("../xml/invalid-stockquote.wsdl"); + WSDLDefinition definition = processor.read(null, new URI("invalid-stockquote.wsdl"), url); + PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + + Operation operation = portType.getOperation("getLastTradePrice", null, null); + WSDLOperation op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + + try { + op.isWrapperStyle(); + fail("InvalidWSDLException should have been thrown"); + } catch (InvalidWSDLException e) { + // Expected + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java new file mode 100644 index 0000000000..ea95537bd1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java @@ -0,0 +1,81 @@ +/* + * 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.sca.interfacedef.wsdl.introspect; + +import java.net.URI; +import java.net.URL; + +import javax.wsdl.Operation; +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor; + +/** + * Test case for WSDLOperation + */ +public class WrapperStyleOperationTestCase extends TestCase { + private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); + + private WSDLDocumentProcessor registry; + private ModelResolver resolver; + private WSDLFactory wsdlFactory; + + /** + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + registry = new WSDLDocumentProcessor(new DefaultWSDLFactory(), null); + resolver = new TestModelResolver(getClass().getClassLoader()); + wsdlFactory = new DefaultWSDLFactory(); + } + + public final void testWrappedOperation() throws Exception { + URL url = getClass().getResource("../xml/stockquote.wsdl"); + WSDLDefinition definition = registry.read(null, new URI("stockquote.wsdl"), url); + PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + Operation operation = portType.getOperation("getLastTradePrice", null, null); + WSDLOperation op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + Assert.assertTrue(op.isWrapperStyle()); + Assert.assertEquals(1, op.getWrapper().getInputChildElements().size()); + Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size()); + } + + public final void testUnwrappedOperation() throws Exception { + URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl"); + WSDLDefinition definition = registry.read(null, new URI("unwrapped-stockquote.wsdl"), url); + PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); + Operation operation = portType.getOperation("getLastTradePrice1", null, null); + WSDLOperation op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + Assert.assertFalse(op.isWrapperStyle()); + operation = portType.getOperation("getLastTradePrice2", null, null); + op = new WSDLOperation(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver); + Assert.assertFalse(op.isWrapperStyle()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java new file mode 100644 index 0000000000..56355afb2b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java @@ -0,0 +1,118 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.DefaultSCABindingFactory; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor; +import org.apache.tuscany.sca.assembly.xml.CompositeProcessor; +import org.apache.tuscany.sca.assembly.xml.ConstrainingTypeProcessor; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.policy.DefaultPolicyFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * Test reading WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class ReadTestCase extends TestCase { + + XMLInputFactory inputFactory; + DefaultStAXArtifactProcessorExtensionPoint staxProcessors; + ExtensibleStAXArtifactProcessor staxProcessor; + private AssemblyFactory assemblyFactory; + private SCABindingFactory scaBindingFactory; + private PolicyFactory policyFactory; + private InterfaceContractMapper mapper; + + public void setUp() throws Exception { + assemblyFactory = new DefaultAssemblyFactory(); + scaBindingFactory = new DefaultSCABindingFactory(); + policyFactory = new DefaultPolicyFactory(); + mapper = new InterfaceContractMapperImpl(); + inputFactory = XMLInputFactory.newInstance(); + staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); + + WSDLInterfaceProcessor wsdlProcessor = new WSDLInterfaceProcessor(new DefaultWSDLFactory(), null); + staxProcessors.addArtifactProcessor(wsdlProcessor); + } + + public void tearDown() throws Exception { + inputFactory = null; + staxProcessors = null; + policyFactory = null; + assemblyFactory = null; + mapper = null; + } + + public void testReadComponentType() throws Exception { + ComponentTypeProcessor componentTypeProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor); + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + ComponentType componentType = componentTypeProcessor.read(reader); + assertNotNull(componentType); + + //new PrintUtil(System.out).print(componentType); + } + + public void testReadConstrainingType() throws Exception { + ConstrainingTypeProcessor constrainingTypeProcessor = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor); + InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + ConstrainingType constrainingType = constrainingTypeProcessor.read(reader); + assertNotNull(constrainingType); + + //new PrintUtil(System.out).print(constrainingType); + } + + public void testReadComposite() throws Exception { + CompositeProcessor compositeProcessor = new CompositeProcessor(assemblyFactory, policyFactory, mapper, staxProcessor); + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = compositeProcessor.read(reader); + assertNotNull(composite); + + CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, mapper, null); + compositeUtil.build(composite); + + //new PrintUtil(System.out).print(composite); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java new file mode 100644 index 0000000000..fb71175931 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java @@ -0,0 +1,67 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import java.net.URI; +import java.net.URL; + +import javax.xml.stream.XMLInputFactory; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; + +/** + * Test reading WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class WSDLTestCase extends TestCase { + + XMLInputFactory inputFactory; + DefaultURLArtifactProcessorExtensionPoint documentProcessors; + ExtensibleURLArtifactProcessor documentProcessor; + + public void setUp() throws Exception { + inputFactory = XMLInputFactory.newInstance(); + documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(); + documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors); + + WSDLDocumentProcessor wsdlProcessor = new WSDLDocumentProcessor(new DefaultWSDLFactory(), null); + documentProcessors.addArtifactProcessor(wsdlProcessor); + } + + public void tearDown() throws Exception { + inputFactory = null; + documentProcessors = null; + } + + public void testReadWSDLDocument() throws Exception { + URL url = getClass().getResource("example.wsdl"); + WSDLDefinition definition = documentProcessor.read(null, new URI("example.wsdl"), url, WSDLDefinition.class); + assertNotNull(definition); + assertNotNull(definition.getDefinition()); + assertEquals(definition.getNamespace(), "http://www.example.org"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java new file mode 100644 index 0000000000..99fca23b7a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java @@ -0,0 +1,108 @@ +/* + * 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.sca.interfacedef.wsdl.xml; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor; +import org.apache.tuscany.sca.assembly.xml.CompositeProcessor; +import org.apache.tuscany.sca.assembly.xml.ConstrainingTypeProcessor; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.policy.DefaultPolicyFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * Test reading/write WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class WriteTestCase extends TestCase { + + XMLInputFactory inputFactory; + DefaultStAXArtifactProcessorExtensionPoint staxProcessors; + private ExtensibleStAXArtifactProcessor staxProcessor; + private AssemblyFactory factory; + private PolicyFactory policyFactory; + private InterfaceContractMapper mapper; + + public void setUp() throws Exception { + factory = new DefaultAssemblyFactory(); + policyFactory = new DefaultPolicyFactory(); + mapper = new InterfaceContractMapperImpl(); + inputFactory = XMLInputFactory.newInstance(); + staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance()); + + staxProcessors.addArtifactProcessor(new CompositeProcessor(factory, policyFactory, mapper, staxProcessor)); + staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(factory, policyFactory, staxProcessor)); + staxProcessors.addArtifactProcessor(new ConstrainingTypeProcessor(factory, policyFactory, staxProcessor)); + + WSDLInterfaceProcessor wsdlProcessor = new WSDLInterfaceProcessor(new DefaultWSDLFactory(), null); + staxProcessors.addArtifactProcessor(wsdlProcessor); + } + + public void tearDown() throws Exception { + inputFactory = null; + staxProcessors = null; + policyFactory = null; + factory = null; + mapper = null; + } + + public void testReadWriteComponentType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + ComponentType componentType = staxProcessor.read(is, ComponentType.class); + assertNotNull(componentType); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(componentType, bos); + } + + public void testReadWriteConstrainingType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType"); + ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class); + assertNotNull(constrainingType); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(constrainingType, bos); + } + + public void testReadWriteComposite() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + Composite composite = staxProcessor.read(is, Composite.class); + assertNotNull(composite); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, bos); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite new file mode 100644 index 0000000000..875fdf35d2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorComponent.constrainingType b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorComponent.constrainingType new file mode 100644 index 0000000000..3eb81b61bd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorComponent.constrainingType @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType new file mode 100644 index 0000000000..aea7046a3d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl new file mode 100644 index 0000000000..5e8e5dad0d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl new file mode 100644 index 0000000000..ad81fc7867 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd new file mode 100644 index 0000000000..241ec15d36 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd @@ -0,0 +1,136 @@ + + + + + + International Purchase order schema for Example.com + Copyright 2000 Example.com. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl new file mode 100644 index 0000000000..39cd5547d9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl new file mode 100644 index 0000000000..8e26f7b4b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd new file mode 100644 index 0000000000..c2210f4a94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl new file mode 100644 index 0000000000..529b395fd5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl new file mode 100644 index 0000000000..666a7e4069 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.91/modules/interface-wsdl-xml/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3