diff options
author | ramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68> | 2008-12-02 11:17:24 +0000 |
---|---|---|
committer | ramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68> | 2008-12-02 11:17:24 +0000 |
commit | eed639ccf7fd95e0b31caf61787126e69592f207 (patch) | |
tree | 401cafc53175c67ac1aea5398986400b416bcde3 /branches/sca-java-1.4/modules/binding-ws | |
parent | e2af7d8b2dc498e63375fec8d97186dc261a428f (diff) |
Branch for 1.4
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@722428 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
212 files changed, 18198 insertions, 0 deletions
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/LICENSE b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/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/branches/sca-java-1.4/modules/binding-ws-axis2-policy/NOTICE b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/pom.xml b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/pom.xml new file mode 100644 index 0000000000..24a06b8bef --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/pom.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-ws-axis2-policy</artifactId> + <name>Apache Tuscany SCA Policy Model for Axis2 Web Service Binding</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-policy-security</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-api</artifactId> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + <exclusion> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + </exclusion> + </exclusions> + <version>1.2.7</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-impl</artifactId> + <version>1.2.7</version> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-kernel</artifactId> + <version>1.4.1</version> + <exclusions> + <exclusion> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + </exclusion> + <exclusion> + <groupId>xalan</groupId> + <artifactId>xalan</artifactId> + </exclusion> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + <version>3.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.neethi</groupId> + <artifactId>neethi</artifactId> + <version>2.0.4</version> + <exclusions> + <exclusion> + <groupId>wsdl4j</groupId> + <artifactId>wsdl4j</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-impl</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.binding.ws.axis2.policy</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.binding.ws.axis2.policy*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java new file mode 100644 index 0000000000..8fecb84bb4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java @@ -0,0 +1,56 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.policy.Policy; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicy implements Policy { + public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "axis2TokenAuthentication"); + public static final String AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName"; + + private QName tokenName; + + public QName getTokenName() { + return tokenName; + } + + public void setTokenName(QName tokenName) { + this.tokenName = tokenName; + } + + public QName getSchemaName() { + return AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java new file mode 100644 index 0000000000..e8a7872858 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java @@ -0,0 +1,112 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +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.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +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.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2TokenAuthenticationPolicy> { + + public QName getArtifactType() { + return Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; + } + + public Axis2TokenAuthenticationPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public Axis2TokenAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + Axis2TokenAuthenticationPolicy policy = new Axis2TokenAuthenticationPolicy(); + int event = reader.getEventType(); + QName name = null; + + while (reader.hasNext()) { + event = reader.getEventType(); + switch (event) { + case START_ELEMENT : { + name = reader.getName(); + if ( name.equals(getArtifactType()) ) { + policy.setTokenName(getQName(reader, Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME)); + } + break; + } + } + + if ( event == END_ELEMENT ) { + if ( getArtifactType().equals(reader.getName()) ) { + break; + } + } + + //Read the next element + if (reader.hasNext()) { + reader.next(); + } + } + + return policy; + } + + public void write(Axis2TokenAuthenticationPolicy policy, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + if ( policy.getTokenName() != null ) { + writer.writeStartElement(prefix, + Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME, + getArtifactType().getNamespaceURI()); + writer.writeCharacters(policy.getTokenName().toString()); + writer.writeEndElement(); + } + + writer.writeEndElement(); + } + + public Class<Axis2TokenAuthenticationPolicy> getModelType() { + return Axis2TokenAuthenticationPolicy.class; + } + + public void resolve(Axis2TokenAuthenticationPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java new file mode 100644 index 0000000000..cef881af30 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java @@ -0,0 +1,75 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory<Axis2TokenAuthenticationPolicy> { + private ExtensionPointRegistry registry; + + public Axis2TokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation) + */ + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return new Axis2TokenAuthenticationReferencePolicyProvider(component, reference, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new Axis2TokenAuthenticationServicePolicyProvider(component, service, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java new file mode 100644 index 0000000000..c6cd96e647 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java @@ -0,0 +1,100 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import java.util.logging.ConsoleHandler; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMText; +import org.apache.axiom.om.impl.llom.util.AXIOMUtil; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.Policy; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationReferencePolicyInterceptor implements Interceptor { + + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2TokenAuthenticationPolicy policy; + + public Axis2TokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2TokenAuthenticationPolicy){ + policy = (Axis2TokenAuthenticationPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + // could call out here to some 3rd party system to get credentials + + if ( policy.getTokenName() != null){ + // create Axis representation of header + Axis2SOAPHeaderString header = new Axis2SOAPHeaderString(); + header.setHeaderName(policy.getTokenName()); + header.setHeaderString("SomeWSAuthorizationToken"); + + // add header to Tuscany message + msg.getHeaders().add(header); + } + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java new file mode 100644 index 0000000000..147fd1f42a --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java @@ -0,0 +1,90 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyProvider { + private RuntimeComponent component; + private RuntimeComponentReference reference; + private Binding binding; + + public Axis2TokenAuthenticationReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + super(); + this.component = component; + this.reference = reference; + this.binding = binding; + } + + private PolicySet findPolicySet() { + if (binding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + return ps; + } + } + } + } + return null; + } + + private String getContext() { + return "component.reference: " + component.getURI() + + "#" + + reference.getName() + + "(" + + binding.getClass().getName() + + ")"; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Interceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2TokenAuthenticationReferencePolicyInterceptor(getContext(), operation, ps); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() + */ + public String getPhase() { + return Phase.REFERENCE_POLICY; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java new file mode 100644 index 0000000000..2928647445 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java @@ -0,0 +1,94 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + + +import java.security.Principal; + +import javax.security.auth.Subject; + +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeader; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.SecurityUtil; +import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationServicePolicyInterceptor implements Interceptor { + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2TokenAuthenticationPolicy policy; + + public Axis2TokenAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2TokenAuthenticationPolicy){ + policy = (Axis2TokenAuthenticationPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + + Axis2SOAPHeaderString header = (Axis2SOAPHeaderString)Axis2HeaderPolicyUtil.getHeader(msg, policy.getTokenName()); + + if (header != null) { + System.out.println("Web service received token: " + header.getHeaderString()); + + // call out here to some 3rd party system to do whatever you + // need to turn header credentials into an authenticated principal + + Subject subject = SecurityUtil.getSubject(msg); + Principal principal = new TokenPrincipal(header.getHeaderString()); + subject.getPrincipals().add(principal); + } + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java new file mode 100644 index 0000000000..e3e2a4b9a0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java @@ -0,0 +1,88 @@ +/* + * 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.binding.ws.axis2.policy.authentication.token; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProvider { + private RuntimeComponent component; + private RuntimeComponentService service; + private Binding binding; + + public Axis2TokenAuthenticationServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { + super(); + this.component = component; + this.service = service; + this.binding = binding; + } + + private PolicySet findPolicySet() { + if (binding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + return ps; + } + } + } + } + return null; + } + + private String getContext() { + return "component.service: " + component.getURI() + + "#" + + service.getName() + + "(" + + binding.getClass().getName() + + ")"; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Interceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2TokenAuthenticationServicePolicyInterceptor(getContext(), operation, ps); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() + */ + public String getPhase() { + return Phase.SERVICE_POLICY; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java new file mode 100644 index 0000000000..8d08a3f78e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java @@ -0,0 +1,54 @@ +/* + * 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.binding.ws.axis2.policy.configuration; + +import java.util.Hashtable; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.policy.Policy; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicy implements Policy { + public static final QName NAME = new QName(Constants.SCA10_TUSCANY_NS, "wsConfigParam"); + private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>(); + + public Map<String, OMElement> getParamElements() { + return paramElements; + } + + public QName getSchemaName() { + return NAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java new file mode 100644 index 0000000000..5ac4e3f5fd --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java @@ -0,0 +1,79 @@ +/* + * 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.binding.ws.axis2.policy.configuration; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.Parameter; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + + +/** + * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances + * + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicyHandler implements PolicyHandler { + private PolicySet applicablePolicySet = null; + + public void setUp(Object... context) { + Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; + Parameter configParam = null; + for ( Object contextObject : context ) { + if ( contextObject instanceof ConfigurationContext ) { + ConfigurationContext configContext = (ConfigurationContext)contextObject; + for ( Object policy : applicablePolicySet.getPolicies() ) { + if ( policy instanceof Axis2ConfigParamPolicy ) { + axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + for ( String paramName : axis2ConfigParamPolicy.getParamElements().keySet() ) { + configParam = new Parameter(paramName, + axis2ConfigParamPolicy.getParamElements().get(paramName).getFirstElement()); + configParam.setParameterElement(axis2ConfigParamPolicy.getParamElements().get(paramName)); + try { + configContext.getAxisConfiguration().addParameter(configParam); + } catch ( AxisFault e ) { + throw new RuntimeException(e); + } + } + } + } + } + } + } + + public void cleanUp(Object... context) { + } + + public void beforeInvoke(Object... context) { + } + + public void afterInvoke(Object... context) { + + } + + public PolicySet getApplicablePolicySet() { + return applicablePolicySet; + } + + public void setApplicablePolicySet(PolicySet applicablePolicySet) { + this.applicablePolicySet = applicablePolicySet; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java new file mode 100644 index 0000000000..6478fbedad --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java @@ -0,0 +1,157 @@ +/* + * 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.binding.ws.axis2.policy.configuration; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +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.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicyProcessor implements StAXArtifactProcessor<Axis2ConfigParamPolicy> { + public static final QName AXIS2_CONFIG_PARAM_POLICY_QNAME = Axis2ConfigParamPolicy.NAME; + public static final String PARAMETER = "parameter"; + public QName getArtifactType() { + return AXIS2_CONFIG_PARAM_POLICY_QNAME; + } + + public Axis2ConfigParamPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + public Axis2ConfigParamPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + Axis2ConfigParamPolicy policy = new Axis2ConfigParamPolicy(); + int event = reader.getEventType(); + QName name = null; + OMElement parameterElement = null; + String paramName = null; + while (reader.hasNext()) { + event = reader.getEventType(); + switch (event) { + case START_ELEMENT : { + name = reader.getName(); + if ( PARAMETER.equals(name.getLocalPart()) ) { + paramName = reader.getAttributeValue(null, Constants.NAME); + parameterElement = loadElement(reader); + policy.getParamElements().put(paramName, parameterElement); + } + break; + } + } + + if ( event == END_ELEMENT ) { + if ( AXIS2_CONFIG_PARAM_POLICY_QNAME.equals(reader.getName()) ) { + break; + } + } + + //Read the next element + if (reader.hasNext()) { + reader.next(); + } + } + + return policy; + } + + public void write(Axis2ConfigParamPolicy arg0, XMLStreamWriter arg1) throws ContributionWriteException, + XMLStreamException { + } + + public Class<Axis2ConfigParamPolicy> getModelType() { + return Axis2ConfigParamPolicy.class; + } + + public void resolve(Axis2ConfigParamPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } + + private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement head = fac.createOMElement(reader.getName()); + OMElement current = head; + while (true) { + switch (reader.next()) { + case XMLStreamConstants.START_ELEMENT: + //since the axis2 code checks against a no namespace we need to generate accordingly + QName name = new QName(reader.getName().getLocalPart()); + OMElement child = fac.createOMElement(name, current); + + int count = reader.getNamespaceCount(); + for (int i = 0; i < count; i++) { + String prefix = reader.getNamespacePrefix(i); + String ns = reader.getNamespaceURI(i); + child.declareNamespace(ns, prefix); + } + + if(!"".equals(name.getNamespaceURI())) { + child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); + } + + // add the attributes for this element + count = reader.getAttributeCount(); + for (int i = 0; i < count; i++) { + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + + if (ns != null) { + child.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); + child.declareNamespace(ns, prefix); + } else { + child.addAttribute(qname, value, null); + } + } + current = child; + break; + case XMLStreamConstants.CDATA: + fac.createOMText(current, reader.getText()); + break; + case XMLStreamConstants.CHARACTERS: + fac.createOMText(current, reader.getText()); + break; + case XMLStreamConstants.END_ELEMENT: + if ( current == head ) { + return head; + } else { + current = (OMElement)current.getParent(); + } + } + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java new file mode 100644 index 0000000000..21261359cb --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java @@ -0,0 +1,99 @@ +/* + * 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.binding.ws.axis2.policy.configuration; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.Parameter; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.osoa.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicyProviderFactory implements PolicyProviderFactory<Axis2ConfigParamPolicy> { + + public Axis2ConfigParamPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation) + */ + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class<Axis2ConfigParamPolicy> getModelType() { + return Axis2ConfigParamPolicy.class; + } + + // FIXME: [rfeng] I think this should be refactored into the binding.ws axis2 code + public void setUp(ConfigurationContext configContext, PolicySet ps) { + Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; + Parameter configParam = null; + for (Object policy : ps.getPolicies()) { + if (policy instanceof Axis2ConfigParamPolicy) { + axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + for (String paramName : axis2ConfigParamPolicy.getParamElements().keySet()) { + configParam = + new Parameter(paramName, axis2ConfigParamPolicy.getParamElements().get(paramName) + .getFirstElement()); + configParam.setParameterElement(axis2ConfigParamPolicy.getParamElements().get(paramName)); + try { + configContext.getAxisConfiguration().addParameter(configParam); + } catch (AxisFault e) { + throw new ServiceRuntimeException(e); + } + } + } + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java new file mode 100644 index 0000000000..244e501901 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java @@ -0,0 +1,56 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.policy.Policy; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2HeaderPolicy implements Policy { + public static final QName AXIS2_HEADER_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "axis2Header"); + public static final String AXIS2_HEADER_NAME = "headerName"; + + private QName headerName; + + public QName getHeaderName() { + return headerName; + } + + public void setHeaderName(QName headerName) { + this.headerName = headerName; + } + + public QName getSchemaName() { + return AXIS2_HEADER_POLICY_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java new file mode 100644 index 0000000000..3466b9def7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java @@ -0,0 +1,114 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import java.util.logging.Level; + +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.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +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.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class Axis2HeaderPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2HeaderPolicy> { + + public QName getArtifactType() { + return Axis2HeaderPolicy.AXIS2_HEADER_POLICY_QNAME; + } + + public Axis2HeaderPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public Axis2HeaderPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + Axis2HeaderPolicy policy = new Axis2HeaderPolicy(); + int event = reader.getEventType(); + QName name = null; + + while (reader.hasNext()) { + event = reader.getEventType(); + switch (event) { + case START_ELEMENT : { + name = reader.getName(); + if ( name.equals(getArtifactType()) ) { + policy.setHeaderName(getQName(reader, Axis2HeaderPolicy.AXIS2_HEADER_NAME)); + } + break; + } + } + + if ( event == END_ELEMENT ) { + if ( getArtifactType().equals(reader.getName()) ) { + break; + } + } + + //Read the next element + if (reader.hasNext()) { + reader.next(); + } + } + + return policy; + } + + public void write(Axis2HeaderPolicy policy, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + if ( policy.getHeaderName() != null ) { + writer.writeStartElement(prefix, + Axis2HeaderPolicy.AXIS2_HEADER_NAME, + getArtifactType().getNamespaceURI()); + writer.writeCharacters(policy.getHeaderName().toString()); + writer.writeEndElement(); + } + + writer.writeEndElement(); + } + + public Class<Axis2HeaderPolicy> getModelType() { + return Axis2HeaderPolicy.class; + } + + public void resolve(Axis2HeaderPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java new file mode 100644 index 0000000000..71833df382 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java @@ -0,0 +1,75 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2HeaderPolicyProviderFactory implements PolicyProviderFactory<Axis2HeaderPolicy> { + private ExtensionPointRegistry registry; + + public Axis2HeaderPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation) + */ + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return new Axis2HeaderReferencePolicyProvider(component, reference, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new Axis2HeaderServicePolicyProvider(component, service, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java new file mode 100644 index 0000000000..98d011a8fc --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java @@ -0,0 +1,50 @@ +/* + * 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.binding.ws.axis2.policy.header; + + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.invocation.Message; + + +/** + * + * @version $Rev$ $Date$ + */ +public class Axis2HeaderPolicyUtil { + + public static Axis2SOAPHeader getHeader(Message msg, QName headerName){ + + Axis2SOAPHeader axis2Header = null; + + for (Object header : msg.getHeaders()){ + if (header instanceof Axis2SOAPHeader){ + Axis2SOAPHeader tmpHeader = (Axis2SOAPHeader)header; + + if (tmpHeader.getHeaderName().equals(headerName)){ + axis2Header = tmpHeader; + break; + } + } + } + + return axis2Header; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java new file mode 100644 index 0000000000..1b3315bb76 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java @@ -0,0 +1,88 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import java.util.logging.ConsoleHandler; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMText; +import org.apache.axiom.om.impl.llom.util.AXIOMUtil; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.Policy; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2HeaderReferencePolicyInterceptor implements Interceptor { + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2HeaderPolicy policy; + + public Axis2HeaderReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2HeaderPolicy){ + policy = (Axis2HeaderPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + // TODO - not yet implemented + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java new file mode 100644 index 0000000000..0af5a09d8d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java @@ -0,0 +1,90 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2HeaderReferencePolicyProvider implements PolicyProvider { + private RuntimeComponent component; + private RuntimeComponentReference reference; + private Binding binding; + + public Axis2HeaderReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + super(); + this.component = component; + this.reference = reference; + this.binding = binding; + } + + private PolicySet findPolicySet() { + if (binding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2HeaderPolicy.class.isInstance(p)) { + return ps; + } + } + } + } + return null; + } + + private String getContext() { + return "component.reference: " + component.getURI() + + "#" + + reference.getName() + + "(" + + binding.getClass().getName() + + ")"; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Interceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2HeaderReferencePolicyInterceptor(getContext(), operation, ps); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() + */ + public String getPhase() { + return Phase.REFERENCE_POLICY; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java new file mode 100644 index 0000000000..a758ca5261 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java @@ -0,0 +1,77 @@ +/* + * 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.binding.ws.axis2.policy.header; + + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2HeaderServicePolicyInterceptor implements Interceptor { + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2HeaderPolicy policy; + + public Axis2HeaderServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2HeaderPolicy){ + policy = (Axis2HeaderPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + // TODO - not yet implemented + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java new file mode 100644 index 0000000000..126073beb7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java @@ -0,0 +1,88 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2HeaderServicePolicyProvider implements PolicyProvider { + private RuntimeComponent component; + private RuntimeComponentService service; + private Binding binding; + + public Axis2HeaderServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { + super(); + this.component = component; + this.service = service; + this.binding = binding; + } + + private PolicySet findPolicySet() { + if (binding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2HeaderPolicy.class.isInstance(p)) { + return ps; + } + } + } + } + return null; + } + + private String getContext() { + return "component.service: " + component.getURI() + + "#" + + service.getName() + + "(" + + binding.getClass().getName() + + ")"; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Interceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2HeaderServicePolicyInterceptor(getContext(), operation, ps); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() + */ + public String getPhase() { + return Phase.SERVICE_POLICY; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java new file mode 100644 index 0000000000..7a1f26bf04 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java @@ -0,0 +1,60 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMText; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.policy.Policy; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2SOAPHeader { + + private QName headerName; + + public QName getHeaderName() { + return headerName; + } + + public void setHeaderName(QName headerName) { + this.headerName = headerName; + } + + public OMElement getAsSOAPHeaderBlock(OMFactory factory) { + OMNamespace ns1 = factory.createOMNamespace(headerName.getNamespaceURI(), + headerName.getPrefix()); + OMElement header = ((SOAPFactory)factory).createSOAPHeaderBlock(headerName.getLocalPart(),ns1); + return header; + } + + public void setAsSOAPHeaderBlock(OMElement header) { + headerName = header.getQName(); + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java new file mode 100644 index 0000000000..0eefeac87b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java @@ -0,0 +1,60 @@ +/* + * 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.binding.ws.axis2.policy.header; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.policy.Policy; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2SOAPHeaderString extends Axis2SOAPHeader { + + private String headerString; + + public String getHeaderString() { + return headerString; + } + + public void setHeaderString(String headerString) { + this.headerString = headerString; + } + + public OMElement getAsSOAPHeaderBlock(OMFactory factory) { + OMElement header = super.getAsSOAPHeaderBlock(factory); + OMText headerText = factory.createOMText(header, headerString); + header.addChild(headerText); + return header; + } + + public void setAsSOAPHeaderBlock(OMElement header) { + super.setAsSOAPHeaderBlock(header); + headerString = header.getText(); + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..96782b74bf --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,21 @@ +# 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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wsConfigParam,model=org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#axis2TokenAuthentication,model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#axis2Header,model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..ced48cf236 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -0,0 +1,20 @@ +# 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.
+
+# Implementation class for the policy extension
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java new file mode 100644 index 0000000000..cf14e54b5f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java @@ -0,0 +1,60 @@ +/* + * 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.binding.ws.axis2.policy.configuration; + + +import java.io.InputStream; +import java.net.URL; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; + +import junit.framework.TestCase; + +/** + * + * Test the reading of ws config params policy. + * + * @version $Rev$ $Date$ + */ +public class PolicyReadTestCase extends TestCase { + + public void testPolicyReading() throws Exception { + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + StAXArtifactProcessor<Object> staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); + + URL url = getClass().getResource("mock_policies.xml"); + + InputStream urlStream = url.openStream(); + XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream); + + Axis2ConfigParamPolicy policy = (Axis2ConfigParamPolicy)staxProcessor.read(reader); + assertEquals(policy.getParamElements().size(), 2); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml new file mode 100644 index 0000000000..77f750cd0d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<tuscany:wsConfigParam xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> + <parameter name="InflowSecurity"> + <action> + <items>Timestamp Signature</items> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile> + </action> + </parameter> + <parameter name="OutflowSecurity"> + <action> + <items>Timestamp Signature</items> + <user>TuscanyWsUser</user> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.IntegrityPWCBHandler</passwordCallbackClass>" + + <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier> + </action> + </parameter> +</tuscany:wsConfigParam>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/LICENSE b/branches/sca-java-1.4/modules/binding-ws-axis2/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/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/branches/sca-java-1.4/modules/binding-ws-axis2/NOTICE b/branches/sca-java-1.4/modules/binding-ws-axis2/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/pom.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/pom.xml new file mode 100644 index 0000000000..b91e86bbd4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/pom.xml @@ -0,0 +1,334 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-binding-ws-axis2</artifactId> + <name>Apache Tuscany SCA Axis2-based WS Binding Extension</name> + + <repositories> + <repository> + <id>apache.ws</id> + <name>Apache WebServices Repository</name> + <url>http://ws.zones.apache.org/repository/</url> + <layout>legacy</layout> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-databinding</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-axiom</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-jaxb-axiom</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-http</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-policy-xml-ws</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2-policy</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-kernel</artifactId> + <version>1.4.1</version> + <exclusions> + <exclusion> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant-launcher</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + <version>3.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-java2wsdl</artifactId> + <version>1.4.1</version> + <exclusions> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant-launcher</artifactId> + </exclusion> + <exclusion> + <groupId>xom</groupId> + <artifactId>xom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-codegen</artifactId> + <version>1.4.1</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.neethi</groupId> + <artifactId>neethi</artifactId> + <version>2.0.4</version> + <exclusions> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + </dependency> + + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.3</version> + <exclusions> + <exclusion> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-mtompolicy</artifactId> + <version>1.4.1</version> + </dependency> + + <dependency> + <groupId>org.apache.santuario</groupId> + <artifactId>xmlsec</artifactId> + <version>1.4.2</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.security</groupId> + <artifactId>wss4j</artifactId> + <version>1.5.4</version> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>mex</artifactId> + <version>1.41</version> + <classifier>impl</classifier> + </dependency> + + <dependency> + <groupId>org.apache.rampart</groupId> + <artifactId>rampart-core</artifactId> + <version>1.4</version> + <exclusions> + <exclusion> + <groupId>org.apache.ant</groupId> + <artifactId>ant-nodeps</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>addressing</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-xmlbeans</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>mex</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-codegen</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb-codegen</artifactId> + </exclusion> + <exclusion> + <groupId>xmlbeans</groupId> + <artifactId>xbean</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ws.commons.schema</groupId> + <artifactId>XmlSchema</artifactId> + </exclusion> + <exclusion> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + + <!-- xerces, xalan, and xml-apis are required for running in websphere --> + <dependency> + <groupId>xalan</groupId> + <artifactId>xalan</artifactId> + <version>2.7.0</version> + <scope>optional</scope> + </dependency> + + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.8.1</version> + </dependency> + + <dependency> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + <version>1.3.03</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.binding.ws.axis2</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.binding.ws.axis2*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java new file mode 100644 index 0000000000..d468370a7e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java @@ -0,0 +1,298 @@ +/* + * 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.binding.ws.axis2; + +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.soap.SOAPBody; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.AddressingConstants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.addressing.EndpointReferenceHelper; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingBasicAuthenticationConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.invocation.DataExchangeSemantics; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.runtime.ReferenceParameters; + +/** + * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics { + + public static final QName QNAME_WSA_FROM = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM, + AddressingConstants.WSA_DEFAULT_PREFIX); + public static final String TUSCANY_PREFIX = "tuscany"; + public static final QName CALLBACK_ID_REFPARM_QN = + new QName(Constants.SCA10_TUSCANY_NS, "CallbackID", TUSCANY_PREFIX); + public static final QName CONVERSATION_ID_REFPARM_QN = + new QName(Constants.SCA10_TUSCANY_NS, "ConversationID", TUSCANY_PREFIX); + + private Axis2ServiceClient serviceClient; + private QName wsdlOperationName; + private Options options; + private SOAPFactory soapFactory; + private List<PolicyHandler> policyHandlerList = null; + private WebServiceBinding wsBinding; + + private BasicAuthenticationPolicy basicAuthenticationPolicy = null; + private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null; + private List<Axis2HeaderPolicy> axis2HeaderPolicies = new ArrayList<Axis2HeaderPolicy>(); + + public Axis2BindingInvoker(Axis2ServiceClient serviceClient, + QName wsdlOperationName, + Options options, + SOAPFactory soapFactory, + List<PolicyHandler> policyHandlerList, + WebServiceBinding wsBinding) { + this.serviceClient = serviceClient; + this.wsdlOperationName = wsdlOperationName; + this.options = options; + this.soapFactory = soapFactory; + this.policyHandlerList = policyHandlerList; + this.wsBinding = wsBinding; + + // find out which policies are active + if (wsBinding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (BasicAuthenticationPolicy.class.isInstance(p)) { + basicAuthenticationPolicy = (BasicAuthenticationPolicy)p; + } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p; + } else if (Axis2HeaderPolicy.class.isInstance(p)) { + axis2HeaderPolicies.add((Axis2HeaderPolicy)p); + }else { + // etc. check for other types of policy being present + } + } + } + } + } + + private static final QName EXCEPTION = new QName("", "Exception"); + + public Message invoke(Message msg) { + try { + Object resp = invokeTarget(msg); + + msg.setBody(resp); + } catch (AxisFault e) { + if (e.getDetail() != null ) { + FaultException f = new FaultException(e.getMessage(), e.getDetail(), e); + f.setFaultName(e.getDetail().getQName()); + msg.setFaultBody(f); + } else { + msg.setFaultBody(e); + } + } catch (Throwable e) { + msg.setFaultBody(e); + } + + return msg; + } + + protected Object invokeTarget(Message msg) throws AxisFault { + final OperationClient operationClient = createOperationClient(msg); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); + requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + requestMC.getOptions().setTimeOutInMilliSeconds(240000L); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(msg, requestMC, operationClient); + } + + // set policy specified headers + for (Axis2HeaderPolicy policy : axis2HeaderPolicies){ + Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, policy.getHeaderName()); + } + + if (basicAuthenticationPolicy != null) { + Axis2BindingBasicAuthenticationConfigurator.setOperationOptions(operationClient, msg, basicAuthenticationPolicy); + } + + if (axis2TokenAuthenticationPolicy != null) { + Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, axis2TokenAuthenticationPolicy.getTokenName()); + } + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { + public Object run() throws AxisFault { + operationClient.execute(true); + return null; + } + }); + } catch (PrivilegedActionException e) { + operationClient.complete(requestMC); + throw (AxisFault)e.getException(); + } + + MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(msg, responseMC, operationClient); + } + + OMElement response = responseMC.getEnvelope().getBody().getFirstElement(); + + // FIXME: [rfeng] We have to pay performance penalty to build the complete OM as the operationClient.complete() will + // release the underlying HTTP connection. + // Force the response to be populated, see https://issues.apache.org/jira/browse/TUSCANY-1541 + if (response != null) { + response.build(); + } + + operationClient.complete(requestMC); + + return response; + } + + @SuppressWarnings("deprecation") + protected OperationClient createOperationClient(Message msg) throws AxisFault { + SOAPEnvelope env = soapFactory.getDefaultEnvelope(); + Object[] args = (Object[])msg.getBody(); + if (args != null && args.length > 0) { + SOAPBody body = env.getBody(); + for (Object bc : args) { + if (bc instanceof OMElement) { + body.addChild((OMElement)bc); + } else { + throw new IllegalArgumentException( + "Can't handle mixed payloads between OMElements and other types."); + } + } + } + final MessageContext requestMC = new MessageContext(); + requestMC.setEnvelope(env); + + // Axis2 operationClients can not be shared so create a new one for each request + final OperationClient operationClient = serviceClient.getServiceClient().createClient(wsdlOperationName); + operationClient.setOptions(options); + + ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); + + // set callback endpoint and callback ID for WS-Addressing header + EndpointReference fromEPR = null; + org.apache.tuscany.sca.runtime.EndpointReference callbackEPR = parameters.getCallbackReference(); + if (callbackEPR != null) { + fromEPR = new EndpointReference(callbackEPR.getBinding().getURI()); + } + Object callbackID = parameters.getCallbackID(); + if (callbackID != null) { + if (fromEPR == null) { + fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL); + } + //FIXME: serialize callback ID to XML in case it is not a string + fromEPR.addReferenceParameter(CALLBACK_ID_REFPARM_QN, callbackID.toString()); + } + + // set conversation ID for WS-Addressing header + Object conversationId = parameters.getConversationID(); + if (conversationId != null) { + if (fromEPR == null) { + fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL); + } + //FIXME: serialize conversation ID to XML in case it is not a string + fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId.toString()); + } + + // add WS-Addressing header + //FIXME: is there any way to use the Axis2 addressing support for this? + if (fromEPR != null) { + SOAPEnvelope sev = requestMC.getEnvelope(); + SOAPHeader sh = sev.getHeader(); + OMElement epr = + EndpointReferenceHelper.toOM(sev.getOMFactory(), + fromEPR, + QNAME_WSA_FROM, + AddressingConstants.Final.WSA_NAMESPACE); + sh.addChild(epr); + requestMC.setFrom(fromEPR); + } + + // Set any message headers required by policy + // Get the header from the tuscany message + // If its not already an OM convert it to OM + // add it to the envelope header + + // if target endpoint was not specified when this invoker was created, + // use dynamically specified target endpoint passed in on this call + if (options.getTo() == null) { + org.apache.tuscany.sca.runtime.EndpointReference ep = msg.getTo(); + if (ep != null) { + requestMC.setTo(new EndpointReference(ep.getURI())); + } else { + throw new RuntimeException("Unable to determine destination endpoint"); + } + } else { + requestMC.setTo(new EndpointReference(options.getTo().getAddress())); + } + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { + public Object run() throws AxisFault { + operationClient.addMessageContext(requestMC); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + return operationClient; + } + + public boolean allowsPassByReference() { + return true; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java new file mode 100644 index 0000000000..c7eb2b7794 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.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.binding.ws.axis2; + +import java.util.List; + +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandlerDefinitionsLoader; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.osoa.sca.ServiceRuntimeException; + +/** + * Axis2BindingProviderFactory + * + * @version $Rev$ $Date$ + */ + +public class Axis2BindingProviderFactory implements BindingProviderFactory<WebServiceBinding> { + + private ModelFactoryExtensionPoint modelFactories; + private ServletHost servletHost; + private List<PolicyHandlerTuple> policyHandlerClassnames = null; + private DataBindingExtensionPoint dataBindings; + + public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); + List<ServletHost> hosts = servletHosts.getServletHosts(); + if (!hosts.isEmpty()) { + this.servletHost = hosts.get(0); + } + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + policyHandlerClassnames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames(); + dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + WebServiceBinding binding) { + return new Axis2ReferenceBindingProvider(component, reference, binding, + modelFactories, policyHandlerClassnames, dataBindings); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + WebServiceBinding binding) { + return new Axis2ServiceBindingProvider(component, service, binding, + servletHost, modelFactories, + policyHandlerClassnames, dataBindings); + } + + public Class<WebServiceBinding> getModelType() { + return WebServiceBinding.class; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java new file mode 100644 index 0000000000..f8d0cf55b0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java @@ -0,0 +1,71 @@ +/* + * 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.binding.ws.axis2; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + +/** + * Axis2OneWayBindingInvoker uses an Axis2 OperationClient to invoke a OneWay remote web service. + * + * @version $Rev$ $Date$ + */ +public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker { + + public Axis2OneWayBindingInvoker(Axis2ServiceClient serviceClient, + QName wsdlOperationName, + Options options, + SOAPFactory soapFactory, + List<PolicyHandler> policyHandlerList, + WebServiceBinding wsBinding) { + + super(serviceClient, wsdlOperationName, options, soapFactory, policyHandlerList, wsBinding); + } + + @Override + protected Object invokeTarget(Message msg) throws AxisFault { + OperationClient operationClient = createOperationClient(msg); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); + //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + Options opt = requestMC.getOptions(); + opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + opt.setUseSeparateListener(true); + opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE); + + operationClient.execute(false); + + // REVIEW it seems ok to return null + return null; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java new file mode 100644 index 0000000000..958d4aa41d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider { + + private WebServiceBinding wsBinding; + private Axis2ServiceClient axisClient; + + public Axis2ReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + WebServiceBinding wsBinding, + ModelFactoryExtensionPoint modelFactories, + List<PolicyHandlerTuple> policyHandlerClassnames, + DataBindingExtensionPoint dataBindings) { + + MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class); + this.wsBinding = wsBinding; + + // A WSDL document should always be present in the binding + if (wsBinding.getWSDLDocument() == null) { + throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + reference.getName()); + } + + // Set to use the Axiom data binding + InterfaceContract contract = wsBinding.getBindingInterfaceContract(); + if (contract.getInterface() != null) { + contract.getInterface().resetDataBinding(OMElement.class.getName()); + } + + axisClient = new Axis2ServiceClient(component, reference, wsBinding, messageFactory, policyHandlerClassnames); + } + + public void start() { + axisClient.start(); + } + + public void stop() { + axisClient.stop(); + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public Invoker createInvoker(Operation operation) { + return axisClient.createInvoker(operation); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java new file mode 100644 index 0000000000..5b26290732 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java @@ -0,0 +1,84 @@ +/* + * 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.binding.ws.axis2; + +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceBindingProvider implements ServiceBindingProvider { + + private WebServiceBinding wsBinding; + private Axis2ServiceProvider axisProvider; + + public Axis2ServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + WebServiceBinding wsBinding, + ServletHost servletHost, + ModelFactoryExtensionPoint modelFactories, + List<PolicyHandlerTuple> policyHandlerClassnames, + DataBindingExtensionPoint dataBindings) { + + if (servletHost == null) { + throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services"); + } + + MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class); + this.wsBinding = wsBinding; + + // A WSDL document should always be present in the binding + if (wsBinding.getWSDLDocument() == null) { + throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + service.getName()); + } + + // Set to use the Axiom data binding + InterfaceContract contract = wsBinding.getBindingInterfaceContract(); + contract.getInterface().resetDataBinding(OMElement.class.getName()); + + axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, policyHandlerClassnames); + } + + public void start() { + axisProvider.start(); + } + + public void stop() { + axisProvider.stop(); + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java new file mode 100644 index 0000000000..0d3916019f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java @@ -0,0 +1,503 @@ +/* + * 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.binding.ws.axis2; + +import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.SOAP12_INTENT; +import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.isIntentRequired; + +import java.io.IOException; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Port; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.namespace.QName; +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.dom.DOMSource; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.addressing.EndpointReferenceHelper; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.AxisEndpoint; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.WSDL11ToAxisServiceBuilder; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.util.threadpool.ThreadPool; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.params.HttpConnectionManagerParams; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.xsd.xml.XMLDocumentHelper; +import org.apache.ws.commons.schema.resolver.URIResolver; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceClient { + + private RuntimeComponent component; + private AbstractContract contract; + private WebServiceBinding wsBinding; + private ServiceClient serviceClient; + List<PolicyHandlerTuple> policyHandlerClassnames = null; + private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>(); + + public Axis2ServiceClient(RuntimeComponent component, + AbstractContract contract, + WebServiceBinding wsBinding, + MessageFactory messageFactory, + List<PolicyHandlerTuple> policyHandlerClassnames) { + + this.component = component; + this.contract = contract; + this.wsBinding = wsBinding; + this.policyHandlerClassnames = policyHandlerClassnames; + } + + protected void start() { + if (serviceClient == null) { + this.serviceClient = createServiceClient(); + } + } + + public ServiceClient getServiceClient() { + return serviceClient; + } + + protected void configurePolicy(ConfigurationContext context, PolicySet ps) throws AxisFault { + if (ps == null) { + return; + } + for (Object policy : ps.getPolicies()) { + if (policy instanceof Axis2ConfigParamPolicy) { + Axis2ConfigParamPolicy axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + for (Map.Entry<String, OMElement> param : axis2ConfigParamPolicy.getParamElements().entrySet()) { + Parameter configParam = new Parameter(param.getKey(), param.getValue().getFirstElement()); + configParam.setParameterElement(param.getValue()); + context.getAxisConfiguration().addParameter(configParam); + } + } + } + } + + /** + * Create an Axis2 ServiceClient + */ + protected ServiceClient createServiceClient() { + try { + final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding); + ConfigurationContext configContext; + + try { + // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); + // Allow privileged access to read properties. Requires PropertyPermission read in + // security policy. + TuscanyAxisConfigurator tuscanyAxisConfigurator = + AccessController.doPrivileged(new PrivilegedExceptionAction<TuscanyAxisConfigurator>() { + public TuscanyAxisConfigurator run() throws AxisFault { + return new TuscanyAxisConfigurator(isRampartRequired); + } + }); + configContext = tuscanyAxisConfigurator.getConfigurationContext(); + // deployRampartModule(); + // configureSecurity(); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } + + createPolicyHandlers(); + setupPolicyHandlers(policyHandlerList, configContext); + + Definition definition = wsBinding.getWSDLDocument(); + QName serviceQName = wsBinding.getService().getQName(); + Port port = wsBinding.getPort(); + if (port == null) { + // service has multiple ports, select one port to use + Collection<Port> ports = wsBinding.getService().getPorts().values(); + for (Port p : ports) { + // look for a SOAP 1.1 port first + if (p.getExtensibilityElements().get(0) instanceof SOAPAddress) { + port = p; + break; + } + } + if (port == null) { + // no SOAP 1.1 port available, so look for a SOAP 1.2 port + for (Port p : ports) { + if (p.getExtensibilityElements().get(0) instanceof SOAP12Address) { + port = p; + break; + } + } + } + } + AxisService axisService = + createClientSideAxisService(definition, serviceQName, port.getName(), new Options()); + + HttpClient httpClient = (HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT); + if (httpClient == null) { + MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); + HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams(); + connectionManagerParams.setDefaultMaxConnectionsPerHost(2); + connectionManagerParams.setTcpNoDelay(true); + connectionManagerParams.setStaleCheckingEnabled(true); + connectionManagerParams.setLinger(0); + connectionManager.setParams(connectionManagerParams); + httpClient = new HttpClient(connectionManager); + configContext.setThreadPool(new ThreadPool(1, 5)); + configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); + } + + return new ServiceClient(configContext, axisService); + + } catch (AxisFault e) { + throw new RuntimeException(e); // TODO: better exception + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + /** + * URI resolver implementation for XML schema + */ + public static class URIResolverImpl implements URIResolver { + private Definition definition; + + public URIResolverImpl(Definition definition) { + this.definition = definition; + } + + public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace, + java.lang.String schemaLocation, + java.lang.String baseUri) { + try { + if (baseUri == null) { + baseUri = definition.getDocumentBaseURI(); + } + URL url = new URL(new URL(baseUri), schemaLocation); + return XMLDocumentHelper.getInputSource(url); + } catch (IOException e) { + return null; + } + } + } + + /** + * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 + * @param definition + * @param serviceName + * @return + */ + private static Definition getDefinition(Definition definition, QName serviceName) { + + if (serviceName == null) { + return definition; + } + + if (definition == null) { + return null; + } + Object service = definition.getServices().get(serviceName); + if (service != null) { + return definition; + } + for (Object i : definition.getImports().values()) { + List<Import> imports = (List<Import>)i; + for (Import imp : imports) { + Definition d = getDefinition(imp.getDefinition(), serviceName); + if (d != null) { + return d; + } + } + } + return null; + } + + /** + * This method is copied from AxisService.createClientSideAxisService to + * work around http://issues.apache.org/jira/browse/WSCOMMONS-228 + * + * @param wsdlDefinition + * @param wsdlServiceName + * @param portName + * @param options + * @return + * @throws AxisFault + */ + @Deprecated + public static AxisService createClientSideAxisService(Definition definition, + QName serviceName, + String portName, + Options options) throws AxisFault { + Definition def = getDefinition(definition, serviceName); + final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, serviceName, portName); + serviceBuilder.setServerSide(false); + // [rfeng] Add a custom resolver to work around WSCOMMONS-228 + serviceBuilder.setCustomResolver(new URIResolverImpl(def)); + serviceBuilder.setBaseUri(def.getDocumentBaseURI()); + // [rfeng] + // Allow access to read properties. Requires PropertiesPermission in security policy. + AxisService axisService; + try { + axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() { + public AxisService run() throws AxisFault { + return serviceBuilder.populateService(); + } + }); + } catch ( PrivilegedActionException e ) { + throw (AxisFault) e.getException(); + } + + AxisEndpoint axisEndpoint = (AxisEndpoint)axisService.getEndpoints().get(axisService.getEndpointName()); + options.setTo(new EndpointReference(axisEndpoint.getEndpointURL())); + if (axisEndpoint != null) { + options.setSoapVersionURI((String)axisEndpoint.getBinding().getProperty(WSDL2Constants.ATTR_WSOAP_VERSION)); + } + return axisService; + } + + /* + private static <T extends ExtensibilityElement> T getExtensibilityElement(List elements, Class<T> type) { + for (Object e : elements) { + if (type.isInstance(e)) { + return type.cast(e); + } + } + return null; + } + */ + + protected void stop() { + if (serviceClient != null) { + // close all connections that we have initiated, so that the jetty server + // can be restarted without seeing ConnectExceptions + HttpClient httpClient = + (HttpClient)serviceClient.getServiceContext().getConfigurationContext() + .getProperty(HTTPConstants.CACHED_HTTP_CLIENT); + if (httpClient != null) + ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown(); + + serviceClient = null; + } + } + + /** + * Create and configure an Axis2BindingInvoker for each operation + */ + protected Invoker createInvoker(Operation operation) { + Options options = new Options(); + EndpointReference epTo = getWSATOEPR(wsBinding); + if (epTo != null) { + options.setTo(epTo); + } + options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE); + + String operationName = operation.getName(); + + String soapAction = getSOAPAction(operationName); + if (soapAction != null && soapAction.length() > 1) { + options.setAction(soapAction); + } + + options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + SOAPFactory soapFactory = AccessController.doPrivileged(new PrivilegedAction<SOAPFactory>() { + public SOAPFactory run() { + if (requiresSOAP12()) + return OMAbstractFactory.getSOAP12Factory(); + else + return OMAbstractFactory.getSOAP11Factory(); + + } + }); + QName wsdlOperationQName = new QName(operationName); + if (requiresMTOM()) + { + options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM, org.apache.axis2.Constants.VALUE_TRUE); + } + Axis2BindingInvoker invoker; + if (operation.isNonBlocking()) { + invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding); + } else { + invoker = new Axis2BindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding); + } + + return invoker; + } + + private boolean requiresSOAP12() { + return isIntentRequired(wsBinding, SOAP12_INTENT); + } + + private boolean requiresMTOM() { + return isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT); + } + + protected EndpointReference getWSATOEPR(WebServiceBinding binding) { + EndpointReference epr = getEPR(binding); + if (epr == null) { + epr = getPortLocationEPR(binding); + } else if (epr.getAddress() == null || epr.getAddress().length() < 1) { + EndpointReference bindingEPR = getPortLocationEPR(binding); + if (bindingEPR != null) { + epr.setAddress(bindingEPR.getAddress()); + } + } + return epr; + } + + protected EndpointReference getPortLocationEPR(WebServiceBinding binding) { + String ep = null; + if (binding.getPort() != null) { + List<?> wsdlPortExtensions = binding.getPort().getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + ep = ((SOAPAddress)extension).getLocationURI(); + break; + } + if (extension instanceof SOAP12Address) { + SOAP12Address address = (SOAP12Address)extension; + ep = address.getLocationURI(); + break; + } + } + } + if(ep == null || ep.equals("")) { + ep = binding.getURI(); + } + return ep == null || "".equals(ep) ? null : new EndpointReference(ep); + } + + protected org.apache.axis2.addressing.EndpointReference getEPR(WebServiceBinding wsBinding) { + if (wsBinding.getEndPointReference() == null) { + return null; + } + try { + + XMLStreamReader parser = + XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(wsBinding.getEndPointReference())); + StAXOMBuilder builder = new StAXOMBuilder(parser); + OMElement omElement = builder.getDocumentElement(); + org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement); + return epr; + + } catch (IOException e) { + throw new RuntimeException(e); + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } catch (FactoryConfigurationError e) { + throw new RuntimeException(e); + } + } + + protected String getSOAPAction(String operationName) { + Binding binding = wsBinding.getBinding(); + if (binding != null) { + for (Object o : binding.getBindingOperations()) { + BindingOperation bop = (BindingOperation)o; + if (bop.getName().equalsIgnoreCase(operationName)) { + for (Object o2 : bop.getExtensibilityElements()) { + if (o2 instanceof SOAPOperation) { + return ((SOAPOperation)o2).getSoapActionURI(); + } + } + } + } + } + return null; + } + + private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException { + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + PolicyHandler policyHandler = null; + for (PolicySet policySet : policiedBinding.getPolicySets()) { + policyHandler = PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames); + if (policyHandler != null) { + policyHandler.setApplicablePolicySet(policySet); + policyHandlerList.add(policyHandler); + } + } + + // code to create policy handlers using the new policy SPI based + // on policy providers +/* + List<PolicyProvider> policyProviders = ((RuntimeComponentReference)contract).getPolicyProviders(wsBinding); + + for (PolicyProvider policyProvider : policyProviders){ + policyHandler = policyProvider.createHandler(); + if (policyHandler != null) { + policyHandlerList.add(policyHandler); + } + } +*/ + } + } + + private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, ConfigurationContext configContext) { + for (PolicyHandler aHandler : policyHandlers) { + aHandler.setUp(configContext); + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java new file mode 100644 index 0000000000..a0cfab9154 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java @@ -0,0 +1,79 @@ +/* + * 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.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.receivers.AbstractInMessageReceiver; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + +public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver { + + protected Operation operation; + + private Axis2ServiceProvider provider; + + private List<PolicyHandler> policyHandlerList = null; + + public Axis2ServiceInMessageReceiver(Axis2ServiceProvider provider, Operation operation, List<PolicyHandler> policyHandlerList) { + this.provider = provider; + this.operation = operation; + this.policyHandlerList = policyHandlerList; + } + + public Axis2ServiceInMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + Object[] args = new Object[] {requestOM}; + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(operation, args, inMC); + } + */ + + provider.invokeTarget(operation, args, inMC); + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(operation, args, inMC); + } + */ + + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof Exception) { + throw AxisFault.makeFault((Exception)t); + } + throw new RuntimeException(e); + } catch (Exception e) { + e.printStackTrace(); + throw AxisFault.makeFault(e); + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java new file mode 100644 index 0000000000..d467e0b3c8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.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.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver { + private static final Logger logger = Logger.getLogger(Axis2ServiceInOutSyncMessageReceiver.class.getName()); + + protected Operation operation; + private List<PolicyHandler> policyHandlerList = null; + + private Axis2ServiceProvider provider; + + public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceProvider provider, Operation operation, List<PolicyHandler> policyHandlerList) { + this.provider = provider; + this.operation = operation; + this.policyHandlerList = policyHandlerList; + } + + public Axis2ServiceInOutSyncMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + Object[] args = null; + + if (requestOM != null) { + args = new Object[] {requestOM}; + } + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(operation, args, inMC); + } + */ + + OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, inMC); + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(operation, args, inMC, responseOM); + } + */ + + SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope(); + if (null != responseOM ) { + soapEnvelope.getBody().addChild(responseOM); + } + outMC.setEnvelope(soapEnvelope); + outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE); + + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof FaultException && ((FaultException)t).getFaultInfo() instanceof OMElement) { + OMElement faultDetail = (OMElement)((FaultException)t).getFaultInfo(); + inMC.setProperty(Constants.FAULT_NAME, faultDetail.getQName().getLocalPart()); + AxisFault f = new AxisFault(null, e.getMessage(), "faultNode", "faultRole", faultDetail); + throw f; + } + if (t instanceof Exception) { + throw AxisFault.makeFault((Exception)t); + } + logger.log(Level.SEVERE, e.getMessage(), t); + throw new ServiceRuntimeException(e); + } catch (Throwable e) { + logger.log(Level.SEVERE, e.getMessage(), e); + throw AxisFault.makeFault(e); + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java new file mode 100644 index 0000000000..e82dd64ba5 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java @@ -0,0 +1,826 @@ +/* + * 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.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Port; +import javax.wsdl.Types; +import javax.wsdl.extensions.UnknownExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.addressing.AddressingConstants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.deployment.util.Utils; +import org.apache.axis2.description.AxisEndpoint; +import org.apache.axis2.description.AxisOperation; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.description.TransportOutDescription; +import org.apache.axis2.description.WSDL11ToAxisServiceBuilder; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.description.WSDLToAxisServiceBuilder; +import org.apache.axis2.engine.ListenerManager; +import org.apache.axis2.engine.MessageReceiver; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSListener; +import org.apache.axis2.transport.jms.JMSSender; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceClient.URIResolverImpl; +import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingBasicAuthenticationConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils; +import org.apache.tuscany.sca.runtime.EndpointReference; +import org.apache.tuscany.sca.runtime.ReferenceParameters; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.xsd.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; +import org.apache.ws.security.WSSecurityEngineResult; +import org.apache.ws.security.handler.WSHandlerConstants; +import org.apache.ws.security.handler.WSHandlerResult; +import org.osoa.sca.ServiceRuntimeException; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + + +public class Axis2ServiceProvider { + public static final String IMPORT_TAG = "import"; + public static final String INCLUDE_TAG = "include"; + + private static final Logger logger = Logger.getLogger(Axis2ServiceProvider.class.getName()); + + private RuntimeComponent component; + private AbstractContract contract; + private WebServiceBinding wsBinding; + private ServletHost servletHost; + private MessageFactory messageFactory; + private ConfigurationContext configContext; + private JMSSender jmsSender; + private JMSListener jmsListener; + private List<PolicyHandlerTuple> policyHandlerClassnames = null; + private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>(); + private Map<String, Port> urlMap = new HashMap<String, Port>(); + + private BasicAuthenticationPolicy basicAuthenticationPolicy = null; + private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null; + private List<Axis2HeaderPolicy> axis2HeaderPolicies = new ArrayList<Axis2HeaderPolicy>(); + + public static final QName QNAME_WSA_ADDRESS = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS); + public static final QName QNAME_WSA_FROM = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM); + public static final QName QNAME_WSA_REFERENCE_PARAMETERS = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS); + + private static final QName TRANSPORT_JMS_QUALIFIED_INTENT = + new QName("http://www.osoa.org/xmlns/sca/1.0", "transport.jms"); + private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory"; + + //Schema element names + public static final String ELEM_SCHEMA = "schema"; + + //Schema URI + public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema"; + public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema"; + public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema"; + + //Schema QNames + public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA); + public static final List<QName> XSD_QNAME_LIST = + Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001}); + + public Axis2ServiceProvider(RuntimeComponent component, + AbstractContract contract, + WebServiceBinding wsBinding, + ServletHost servletHost, + MessageFactory messageFactory, + List<PolicyHandlerTuple> policyHandlerClassnames) { + + this.component = component; + this.contract = contract; + this.wsBinding = wsBinding; + this.servletHost = servletHost; + this.messageFactory = messageFactory; + this.policyHandlerClassnames = policyHandlerClassnames; + + final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding); + try { + // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); + // Allow privileged access to read properties. Requires PropertyPermission read in + // security policy. + TuscanyAxisConfigurator tuscanyAxisConfigurator = + AccessController.doPrivileged(new PrivilegedExceptionAction<TuscanyAxisConfigurator>() { + public TuscanyAxisConfigurator run() throws AxisFault { + return new TuscanyAxisConfigurator(isRampartRequired); + } + }); + configContext = tuscanyAxisConfigurator.getConfigurationContext(); + // deployRampartModule(); + // configureSecurity(); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } catch (AxisFault e) { + throw new ServiceRuntimeException(e); // TODO: better exception + } + + configContext.setContextRoot(servletHost.getContextPath()); + + // Enable MTOM if the policy intent is specified. + if (AxisPolicyHelper.isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT)) { + configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false); + configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true"); + } + + // Update port addresses with runtime information, and create a + // map from endpoint URIs to WSDL ports that eliminates duplicate + // ports for the same endpoint. + for (Object port : wsBinding.getService().getPorts().values()) { + String portAddress = getPortAddress((Port)port); + String endpointURI = computeEndpointURI(portAddress, servletHost); + setPortAddress((Port)port, endpointURI); + urlMap.put(endpointURI, (Port)port); + } + + // find out which policies are active + if (wsBinding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (BasicAuthenticationPolicy.class.isInstance(p)) { + basicAuthenticationPolicy = (BasicAuthenticationPolicy)p; + } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p; + } else if (Axis2HeaderPolicy.class.isInstance(p)) { + axis2HeaderPolicies.add((Axis2HeaderPolicy)p); + } else { + // etc. check for other types of policy being present + } + } + } + } + } + + static String getPortAddress(Port port) { + Object ext = port.getExtensibilityElements().get(0); + if (ext instanceof SOAPAddress) { + return ((SOAPAddress)ext).getLocationURI(); + } + if (ext instanceof SOAP12Address) { + return ((SOAP12Address)ext).getLocationURI(); + } + return null; + } + + static void setPortAddress(Port port, String locationURI) { + Object ext = port.getExtensibilityElements().get(0); + if (ext instanceof SOAPAddress) { + ((SOAPAddress)ext).setLocationURI(locationURI); + } + if (ext instanceof SOAP12Address) { + ((SOAP12Address)ext).setLocationURI(locationURI); + } + } + + private String computeEndpointURI(String uri, ServletHost servletHost) { + + if (uri == null) { + return null; + } + + // pull out the binding intents to see what sort of transport is required + PolicySet transportJmsPolicySet = AxisPolicyHelper.getPolicySet(wsBinding, TRANSPORT_JMS_QUALIFIED_INTENT); + if (transportJmsPolicySet != null){ + if (!uri.startsWith("jms:/")) { + uri = "jms:" + uri; + } + + // construct the rest of the URI based on the policy. All the details are put + // into the URI here rather than being place directly into the Axis configuration + // as the Axis JMS sender relies on parsing the target URI + Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; + for ( Object policy : transportJmsPolicySet.getPolicies() ) { + if ( policy instanceof Axis2ConfigParamPolicy ) { + axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + Iterator paramIterator = axis2ConfigParamPolicy.getParamElements().get(DEFAULT_QUEUE_CONNECTION_FACTORY).getChildElements(); + + if (paramIterator.hasNext()){ + StringBuffer uriParams = new StringBuffer("?"); + + while (paramIterator.hasNext()){ + OMElement parameter = (OMElement)paramIterator.next(); + uriParams.append(parameter.getAttributeValue(new QName("","name"))); + uriParams.append("="); + uriParams.append(parameter.getText()); + + if (paramIterator.hasNext()){ + uriParams.append("&"); + } + } + + uri = uri + uriParams; + } + } + } + } else { + if (!uri.startsWith("jms:")) { + uri = servletHost.getURLMapping(uri).toString(); + } + } + + return uri; + } + + public void start() { + + try { + createPolicyHandlers(); + for (Map.Entry<String, Port> entry : urlMap.entrySet()) { + AxisService axisService = createAxisService(entry.getKey(), entry.getValue()); + configContext.getAxisConfiguration().addService(axisService); + } + setupPolicyHandlers(policyHandlerList, configContext); + + Axis2ServiceServlet servlet = null; + for (String endpointURL : urlMap.keySet()) { + if (endpointURL.startsWith("http://") || endpointURL.startsWith("https://") || endpointURL.startsWith("/")) { + if (servlet == null) { + servlet = new Axis2ServiceServlet(); + servlet.init(configContext); + } + //[nash] configContext.setContextRoot(endpointURL); + servletHost.addServletMapping(endpointURL, servlet); + } else if (endpointURL.startsWith("jms")) { + logger.log(Level.INFO,"Axis2 JMS URL=" + endpointURL); + + jmsListener = new JMSListener(); + jmsSender = new JMSSender(); + ListenerManager listenerManager = configContext.getListenerManager(); + TransportInDescription trsIn = configContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS); + + // get JMS transport parameters from the computed URL + Map<String, String> jmsProps = JMSUtils.getProperties(endpointURL); + + // collect the parameters used to configure the JMS transport + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement parms = fac.createOMElement(DEFAULT_QUEUE_CONNECTION_FACTORY, null); + + for ( String key : jmsProps.keySet() ) { + OMElement param = fac.createOMElement("parameter", null); + param.addAttribute( "name", key, null ); + param.addChild(fac.createOMText(param, jmsProps.get(key))); + parms.addChild(param); + } + + Parameter queueConnectionFactory = new Parameter(DEFAULT_QUEUE_CONNECTION_FACTORY, parms); + trsIn.addParameter( queueConnectionFactory ); + + trsIn.setReceiver(jmsListener); + + configContext.getAxisConfiguration().addTransportIn( trsIn ); + TransportOutDescription trsOut = configContext.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS); + //configContext.getAxisConfiguration().addTransportOut( trsOut ); + trsOut.setSender(jmsSender); + + if (listenerManager == null) { + listenerManager = new ListenerManager(); + listenerManager.init(configContext); + } + listenerManager.addListener(trsIn, true); + jmsSender.init(configContext, trsOut); + jmsListener.init(configContext, trsIn); + jmsListener.start(); + } + } + } catch (AxisFault e) { + throw new RuntimeException(e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public void stop() { + if ( jmsListener != null ) { + jmsListener.stop(); + jmsListener.destroy(); + } + else { + for (String endpointURL : urlMap.keySet()) { + servletHost.removeServletMapping(endpointURL); + } + } + + if ( jmsSender != null ) + jmsSender.stop(); + + try { + for (String endpointURL : urlMap.keySet()) { + // get the path to the service + URI uriPath = new URI(endpointURL); + String stringURIPath = uriPath.getPath(); + + /* [nash] Need a leading slash for WSDL imports to work with ?wsdl + // remove any "/" from the start of the path + if (stringURIPath.startsWith("/")) { + stringURIPath = stringURIPath.substring(1, stringURIPath.length()); + } + */ + + configContext.getAxisConfiguration().removeService(stringURIPath); + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } catch (AxisFault e) { + throw new RuntimeException(e); + } + } + + private AxisService createAxisService(String endpointURL, Port port) throws AxisFault { + AxisService axisService; + if (wsBinding.getWSDLDocument() != null) { + axisService = createWSDLAxisService(endpointURL, port); + } else { + axisService = createJavaAxisService(endpointURL); + } + initAxisOperations(axisService); + return axisService; + } + + /** + * Create an AxisService from the interface class from the SCA service interface + */ + protected AxisService createJavaAxisService(String endpointURL) throws AxisFault { + AxisService axisService = new AxisService(); + String path = URI.create(endpointURL).getPath(); + axisService.setName(path); + axisService.setServiceDescription("Tuscany configured AxisService for service: " + endpointURL); + axisService.setClientSide(false); + Parameter classParam = + new Parameter(Constants.SERVICE_CLASS, ((JavaInterface)contract.getInterfaceContract().getInterface()) + .getJavaClass().getName()); + axisService.addParameter(classParam); + try { + Utils.fillAxisService(axisService, configContext.getAxisConfiguration(), null, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return axisService; + } + + /** + * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 + * @param definition + * @param serviceName + * @return + */ + private static Definition getDefinition(Definition definition, QName serviceName) { + + if (serviceName == null){ + return definition; + } + + if (definition == null) { + return null; + } + Object service = definition.getServices().get(serviceName); + if (service != null) { + return definition; + } + for (Object i : definition.getImports().values()) { + List<Import> imports = (List<Import>)i; + for (Import imp : imports) { + Definition d = getDefinition(imp.getDefinition(), serviceName); + if (d != null) { + return d; + } + } + } + return null; + } + + /** + * Create an AxisService from the WSDL doc used by ws binding + */ + protected AxisService createWSDLAxisService(String endpointURL, Port port) throws AxisFault { + + Definition definition = wsBinding.getWSDLDocument(); + QName serviceQName = wsBinding.getService().getQName(); + Definition def = getDefinition(definition, serviceQName); + + final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, port.getName()); + builder.setServerSide(true); + // [rfeng] Add a custom resolver to work around WSCOMMONS-228 + builder.setCustomResolver(new URIResolverImpl(def)); + builder.setBaseUri(def.getDocumentBaseURI()); + // [rfeng] + // AxisService axisService = builder.populateService(); + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + AxisService axisService; + try { + axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() { + public AxisService run() throws AxisFault { + return builder.populateService(); + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + + String name = URI.create(endpointURL).getPath(); + //[nash] HTTP endpoints need a leading slash for WSDL imports to work with ?wsdl + if (endpointURL.startsWith("jms")) { + name = name.startsWith("/") ? name.substring(1) : name; + } + axisService.setName(name); + axisService.setEndpointURL(endpointURL); + axisService.setDocumentation("Tuscany configured AxisService for service: " + endpointURL); + for ( Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext(); ) { + AxisEndpoint ae = (AxisEndpoint)i.next(); + if (endpointURL.startsWith("jms") ) { + Parameter qcf = new Parameter(JMSConstants.CONFAC_PARAM, null); + qcf.setValue(DEFAULT_QUEUE_CONNECTION_FACTORY); + axisService.addParameter(qcf); + break; + } + } + + // Add schema information to the AxisService (needed for "?xsd=" support) + addSchemas(wsBinding.getWSDLDefinition(), axisService); + + // Use the existing WSDL + Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null); + wsdlParam.setValue(definition); + axisService.addParameter(wsdlParam); + Parameter userWSDL = new Parameter("useOriginalwsdl", "true"); + axisService.addParameter(userWSDL); + + // Modify schema imports and includes to add "servicename?xsd=" prefix. + // Axis2 does this for schema extensibility elements, but Tuscany has + // overriden the WSDl4J deserializer to create UnknownExtensibilityElement + // elements in place of these. + modifySchemaImportsAndIncludes(definition, name); + + // Axis2 1.3 has a bug with returning incorrect values for the port + // addresses. To work around this, compute the values here. + Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false"); + axisService.addParameter(modifyAddr); + + return axisService; + } + + private void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) { + for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) { + if (xsDef.getSchema() != null) { + axisService.addSchema(xsDef.getSchema()); + updateSchemaRefs(xsDef.getSchema(), axisService.getName()); + } + } + for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) { + addSchemas(impDef, axisService); + } + } + + private void updateSchemaRefs(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + String location = extSchema.getSchemaLocation(); + if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) { + extSchema.setSchemaLocation(name + "?xsd=" + location); + } + if (extSchema.getSchema() != null) { + updateSchemaRefs(extSchema.getSchema(), name); + } + } + } + } + + private void modifySchemaImportsAndIncludes(Definition definition, String name){ + // adjust the schema locations in types section + Types types = definition.getTypes(); + if (types != null) { + for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) { + Object ext = iter.next(); + if (ext instanceof UnknownExtensibilityElement && + XSD_QNAME_LIST.contains(((UnknownExtensibilityElement)ext).getElementType())) { + changeLocations(((UnknownExtensibilityElement)ext).getElement(), name); + } + } + } + for (Iterator iter = definition.getImports().values().iterator(); iter.hasNext();) { + Vector values = (Vector)iter.next(); + for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) { + Import wsdlImport = (Import)valuesIter.next(); + modifySchemaImportsAndIncludes(wsdlImport.getDefinition(), name); + } + } + } + + private void changeLocations(Element element, String name) { + NodeList nodeList = element.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + String tagName = nodeList.item(i).getLocalName(); + if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) { + processImport(nodeList.item(i), name); + } + } + } + + private void processImport(Node importNode, String name) { + NamedNodeMap nodeMap = importNode.getAttributes(); + for (int i = 0; i < nodeMap.getLength(); i++) { + Node attribute = nodeMap.item(i); + if (attribute.getNodeName().equals("schemaLocation")) { + String location = attribute.getNodeValue(); + if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) { + attribute.setNodeValue(name + "?xsd=" + location); + } + } + } + } + + protected void initAxisOperations(AxisService axisService) { + for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { + AxisOperation axisOp = (AxisOperation)i.next(); + Operation op = getOperation(axisOp); + if (op != null) { + + if (op.isNonBlocking()) { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY); + } else { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT); + } + + MessageReceiver msgrec = null; + if (op.isNonBlocking()) { + msgrec = new Axis2ServiceInMessageReceiver(this, op, policyHandlerList); + } else { + msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op, policyHandlerList); + } + axisOp.setMessageReceiver(msgrec); + } + } + } + + protected Operation getOperation(AxisOperation axisOp) { + String operationName = axisOp.getName().getLocalPart(); + Interface iface = wsBinding.getBindingInterfaceContract().getInterface(); + for (Operation op : iface.getOperations()) { + if (op.getName().equalsIgnoreCase(operationName)) { + return op; + } + } + return null; + } + + // methods for Axis2 message receivers + + public Object invokeTarget(Operation op, Object[] args, MessageContext inMC) throws InvocationTargetException { + String callbackAddress = null; + String callbackID = null; + Object conversationID = null; + + // create a message object and set the args as its body + Message msg = messageFactory.createMessage(); + msg.setBody(args); + msg.setOperation(op); + + //FIXME: can we use the Axis2 addressing support for this? + SOAPHeader header = inMC.getEnvelope().getHeader(); + if (header != null) { + OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM); + if (from != null) { + OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS); + if (callbackAddrElement != null) { + if (contract.getInterfaceContract().getCallbackInterface() != null) { + callbackAddress = callbackAddrElement.getText(); + } + } + OMElement params = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS); + if (params != null) { + OMElement convIDElement = + params.getFirstChildWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN); + if (convIDElement != null) { + if (isConversational()) { + conversationID = convIDElement.getText(); + } + } + OMElement callbackIDElement = + params.getFirstChildWithName(Axis2BindingInvoker.CALLBACK_ID_REFPARM_QN); + if (callbackIDElement != null) { + callbackID = callbackIDElement.getText(); + } + } + } + + // get policy specified headers + for (Axis2HeaderPolicy policy : axis2HeaderPolicies){ + //Axis2BindingHeaderConfigurator.getHeader(inMC, msg, policy.getHeaderName()); + } + + if (axis2TokenAuthenticationPolicy != null) { + Axis2SOAPHeaderString tokenHeader = new Axis2SOAPHeaderString(); + Axis2BindingHeaderConfigurator.getHeader(inMC, + msg, + axis2TokenAuthenticationPolicy.getTokenName(), + tokenHeader); + } + } + + //fill message with QoS context info + fillQoSContext(msg, inMC); + + // if reference parameters are needed, create a new "From" EPR to hold them + EndpointReference from = null; + ReferenceParameters parameters = null; + if (callbackAddress != null || + callbackID != null || + conversationID != null) { + from = new EndpointReferenceImpl(null); + parameters = from.getReferenceParameters(); + msg.setFrom(from); + } + + // set the reference parameters into the "From" EPR + if (callbackAddress != null) { + parameters.setCallbackReference(new EndpointReferenceImpl(callbackAddress)); + } + if (callbackID != null) { + parameters.setCallbackID(callbackID); + } + if (conversationID != null) { + parameters.setConversationID(conversationID); + } + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(msg, inMC); + } + + if (basicAuthenticationPolicy != null) { + Axis2BindingBasicAuthenticationConfigurator.parseHTTPHeader(inMC, msg, basicAuthenticationPolicy); + } + + // find the runtime wire and invoke it with the message + RuntimeWire wire = ((RuntimeComponentService)contract).getRuntimeWire(getBinding()); + Object response = wire.invoke(op, msg); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(response, inMC); + } + + return response; + } + + public boolean isConversational() { + return wsBinding.getBindingInterfaceContract().getInterface().isConversational(); + } + + /** + * Return the binding for this provider as a primitive binding type + * For use when looking up wires registered against the binding. + * + * @return the binding + */ + protected Binding getBinding() { + return wsBinding; + } + + private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, ConfigurationContext configContext) { + for ( PolicyHandler aHandler : policyHandlers ) { + aHandler.setUp(configContext); + } + } + + private void createPolicyHandlers() throws IllegalAccessException, + InstantiationException, + ClassNotFoundException { + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + PolicyHandler policyHandler = null; + + for (PolicySet policySet : policiedBinding.getPolicySets()) { + policyHandler = + PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames); + + if (policyHandler != null) { + policyHandler.setApplicablePolicySet(policySet); + policyHandlerList.add(policyHandler); + } + } + + // code to create policy handlers using a policy SPI based + // on policy providers +/* + List<PolicyProvider> policyProviders = ((RuntimeComponentService)contract).getPolicyProviders(wsBinding); + + for (PolicyProvider policyProvider : policyProviders){ + policyHandler = policyProvider.createHandler(); + if (policyHandler != null) { + policyHandlerList.add(policyHandler); + } + } +*/ + } + } + + private void fillQoSContext(Message message, MessageContext axis2MsgCtx) { + if ( axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS) != null && + axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS) instanceof Vector ) { + Vector recvResults = (Vector)axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS); + for ( int count1 = 0 ; count1 < recvResults.size() ; ++count1 ) { + if ( recvResults.elementAt(count1) instanceof WSHandlerResult ) { + WSHandlerResult wshr = (WSHandlerResult)recvResults.elementAt(count1); + Vector results = wshr.getResults(); + for ( int count2 = 0 ; count2 < results.size() ; ++count2 ) { + if ( results.elementAt(count2) instanceof WSSecurityEngineResult ) { + WSSecurityEngineResult securityResult = + (WSSecurityEngineResult)wshr.getResults().elementAt(count2); + if ( securityResult.get("principal") != null ) { + message.getHeaders().add(securityResult.get("principal")); + } + } + } + } + } + + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java new file mode 100644 index 0000000000..746b850ff0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java @@ -0,0 +1,295 @@ +/* + * 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.binding.ws.axis2; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.SocketException; +import java.net.URI; +import java.net.URL; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Set; +import java.util.Vector; + +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.transport.http.AxisServlet; +import org.apache.axis2.transport.http.ListingAgent; +import org.apache.axis2.transport.http.server.HttpUtils; + +/** + * This overrides the Servlet init of the AxisServlet so Tuscany can use + * a single Axis2 ConfigurationContext instance shared between AxisServlet + * instances for each SCA service with a ws binding. + * TODO: need to review if thats really what we want to be doing + * + * @version $Rev$ $Date$ + */ +public class Axis2ServiceServlet extends AxisServlet { + + protected TuscanyListingAgent agent; + + private static final long serialVersionUID = 1L; + private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig(); + +//JIRA TUSCANY-1561 Port to Axis2 1.3 + private ConfigurationContext tmpconfigContext; + + public void init(ConfigurationContext configContext) { + this.tmpconfigContext = configContext; + try { + super.init(DUMMY_CONFIG); + } catch (ServletException e) { + throw new RuntimeException(e); + } + agent = new TuscanyListingAgent(configContext); + } + + /** + * Override Axis2 Servlet method to avoid loop when init + * is called after servletConfig already initialized by + * this classes init(ConfigurationContext) method. + */ + @Override + public void init() throws ServletException { + } + + @Override + public void init(ServletConfig config) throws ServletException { + ServletContext servletContext = config.getServletContext(); + servletContext.setAttribute(CONFIGURATION_CONTEXT, tmpconfigContext); + super.init(config); + } + + /** + * We've setup the Servlet by passing in a ConfigurationContext on our init method + * override this method to just return that + */ + @Override + protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException { + return this.tmpconfigContext; + } + + @Override + public ServletConfig getServletConfig() { + return DUMMY_CONFIG; + } + + @Override + public String getServletName() { + return "TuscanyAxis2Servlet"; + } + + /** + * The AxisServlet gets NPE during init without a ServletConfig so this is a mocked up one to prevent that. + */ + private static ServletConfig createDummyServletConfig() { + ServletConfig sc = new ServletConfig() { + + public String getServletName() { + return "TuscanyAxis2DummyServlet"; + } + + public ServletContext getServletContext() { + return new ServletContext() { + + public ServletContext getContext(String uripath) { + return null; + } + + @SuppressWarnings("unused") // it's on the Servlet 2.5 API so we need it + public String getContextPath() { + return null; + } + + public int getMajorVersion() { + return 0; + } + + public int getMinorVersion() { + return 0; + } + + public String getMimeType(String file) { + return null; + } + + public Set<?> getResourcePaths(String path) { + return Collections.emptySet(); + } + + public URL getResource(String path) throws MalformedURLException { + if("/".equals(path)) { + // HACK: To avoid NPE + return new URL("/axis2"); + } + return null; + } + + public InputStream getResourceAsStream(String path) { + return null; + } + + public RequestDispatcher getRequestDispatcher(String path) { + return null; + } + + public RequestDispatcher getNamedDispatcher(String arg0) { + return null; + } + + public Servlet getServlet(String arg0) throws ServletException { + return null; + } + + public Enumeration getServlets() { + return null; + } + + public Enumeration getServletNames() { + return null; + } + + public void log(String arg0) { + } + + public void log(Exception arg0, String arg1) { + } + + public void log(String arg0, Throwable arg1) { + } + + public String getRealPath(String arg0) { + return null; + } + + public String getServerInfo() { + return null; + } + + public String getInitParameter(String arg0) { + return null; + } + + public Enumeration getInitParameterNames() { + return null; + } + + public Object getAttribute(String arg0) { + return null; + } + + public Enumeration getAttributeNames() { + return null; + } + + public void setAttribute(String arg0, Object arg1) { + } + + public void removeAttribute(String arg0) { + } + + public String getServletContextName() { + return null; + } + }; + } + + public String getInitParameter(String arg0) { + return null; + } + + public Enumeration getInitParameterNames() { + return new Vector().elements(); + } + }; + return sc; + } + + @Override + public void destroy() { + try { + super.destroy(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Override the AxisServlet doGet to use the TuscanyListingAgent for ?wsdl + */ + @Override + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + + initContextRoot(request); + + String query = request.getQueryString(); + if ((query != null) && (query.indexOf("wsdl2") >= 0 || + query.indexOf("wsdl") >= 0 || query.indexOf("xsd") >= 0 || + query.indexOf("policy") >= 0)) { + agent.processListService(request, response); + } else { + super.doGet(request, response); + } + } + + /** + + /** + * Override the AxisServlet method so as to not add "/services" into the URL + * and to work with Tuscany service names. can go once moved to Axis2 1.3 + */ + @Override + public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault { + //RUNNING_PORT + String port = (String) configContext.getProperty(ListingAgent.RUNNING_PORT); + if (port == null) { + port = "8080"; + } + if (ip == null) { + try { + ip = HttpUtils.getIpAddress(); + if (ip == null) { + ip = "localhost"; + } + } catch (SocketException e) { +//TUSCANY-1561 Port to Axis2 1.3 +// throw new AxisFault.(e); + throw AxisFault.makeFault(e); + } + } + + URI epURI = URI.create("http://" + ip + ":" + port + "/" + serviceName).normalize(); + + return new EndpointReference[]{new EndpointReference(epURI.toString())}; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java new file mode 100644 index 0000000000..1f389b422f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java @@ -0,0 +1,79 @@ +/* + * 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.binding.ws.axis2; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPoint; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +/** + * @version $Rev$ $Date$ + */ +public class AxisPolicyHelper { + + public static final String XMLNS_SCA_1_0 = "http://www.osoa.org/xmlns/sca/1.0"; + public static final QName AUTHENTICATION_INTENT = new QName(XMLNS_SCA_1_0, "authentication"); + public static final QName CONFIDENTIALITY_INTENT = new QName(XMLNS_SCA_1_0, "confidentiality"); + public static final QName INTEGRITY_INTENT = new QName(XMLNS_SCA_1_0, "integrity"); + public static final QName MTOM_INTENT = new QName(XMLNS_SCA_1_0, "MTOM"); + public static final QName SOAP12_INTENT = new QName(XMLNS_SCA_1_0, "SOAP12"); + + public static PolicySet getPolicySet(Binding wsBinding, QName intentName) { + PolicySet returnPolicySet = null; + + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + for (PolicySet policySet : policiedBinding.getPolicySets()) { + for (Intent intent : policySet.getProvidedIntents()) { + if (intent.getName().equals(intentName)) { + returnPolicySet = policySet; + break; + } + } + } + } + + return returnPolicySet; + } + + public static boolean isIntentRequired(Binding wsBinding, QName intent) { + if (wsBinding instanceof IntentAttachPoint) { + List<Intent> intents = ((IntentAttachPoint)wsBinding).getRequiredIntents(); + for (Intent i : intents) { + if (intent.equals(i.getName())) { + return true; + } + } + } + return getPolicySet(wsBinding, intent) != null; + } + + public static boolean isRampartRequired(Binding wsBinding) { + return isIntentRequired(wsBinding, AUTHENTICATION_INTENT) || isIntentRequired(wsBinding, INTEGRITY_INTENT) + || isIntentRequired(wsBinding, CONFIDENTIALITY_INTENT); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java new file mode 100644 index 0000000000..bd154dbc67 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java @@ -0,0 +1,207 @@ +/* + * 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.binding.ws.axis2; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.deployment.DeploymentConstants; +import org.apache.axis2.deployment.DeploymentErrorMsgs; +import org.apache.axis2.deployment.DeploymentException; +import org.apache.axis2.deployment.ModuleBuilder; +import org.apache.axis2.deployment.URLBasedAxisConfigurator; +import org.apache.axis2.description.AxisModule; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.AxisConfigurator; +import org.apache.axis2.i18n.Messages; +import org.apache.axis2.util.Loader; + +/** + * Helps configure Axis2 from a resource in binding.ws.axis2 instead of Axis2.xml + * <p/> TODO: Review: should there be a single global Axis ConfigurationContext + * + * @version $Rev$ $Date$ + */ +public class TuscanyAxisConfigurator extends URLBasedAxisConfigurator implements AxisConfigurator { + + /* these two fields are part of a temporary fix to solve problems that Maven has with including + * rampart-1.4.mar into the classpath and also at the time of Release 1.0 rampart-1.4.mar seems + * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded + * as a Maven dependency and has been packed with this module + */ + /************start of fix *********************************************************************/ + private URL axis2_xml = + getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"); + private URL axis2_repository = null; + private URL rampart_mar_url = + getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar"); + /************** end of fix *************************************************************/ + + private boolean isRampartRequired; + + public TuscanyAxisConfigurator(boolean isRampartRequired) throws AxisFault { + //super(TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"), + // TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart.mar")); + super(getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"), + null); + this.isRampartRequired = isRampartRequired; + } + + private static URL getResource(final String name) { + return AccessController.doPrivileged(new PrivilegedAction<URL>() { + public URL run() { + return TuscanyAxisConfigurator.class.getResource(name); + } + }); + } + + public ConfigurationContext getConfigurationContext() throws AxisFault { + if (configContext == null) { + configContext = ConfigurationContextFactory.createConfigurationContext(this); + } + return configContext; + } + + /* these three methods are part of a temporary fix to solve problems that Maven has with including + * rampart-1.3.mar into the classpath and also at the time of Release 1.0 rampart-1.3.mar seems + * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded + * as a Maven dependency and has been packed with this module + */ + /************start of fix *********************************************************************/ + @Override + public AxisConfiguration getAxisConfiguration() throws AxisFault { + InputStream axis2xmlStream; + try { + if (axis2_xml == null) { + axis2xmlStream = + Loader.getResourceAsStream(DeploymentConstants.AXIS2_CONFIGURATION_RESOURCE); + } else { + axis2xmlStream = axis2_xml.openStream(); + } + axisConfig = populateAxisConfiguration(axis2xmlStream); + if (isRampartRequired) { + axisConfig.addGlobalModuleRef("rampart"); + } + if (axis2_repository == null) { + Parameter axis2repoPara = axisConfig.getParameter(DeploymentConstants.AXIS2_REPO); + if (axis2repoPara != null) { + String repoValue = (String) axis2repoPara.getValue(); + if (repoValue != null && !"".equals(repoValue.trim())) { + if (repoValue.startsWith("file:/")) { + // we treat this case specially , by assuming file is + // located in the local machine + loadRepository(repoValue); + } else { + loadRepositoryFromURL(new URL(repoValue)); + } + } + } else { + //log.info("No repository found , module will be loaded from classpath"); + try { + loadFromClassPath(); + } catch ( Exception e ) { + if (isRampartRequired) { + loadRampartModule(); + } + } + } + + } else { + loadRepositoryFromURL(axis2_repository); + } + + } catch (IOException e) { + throw new AxisFault(e.getMessage()); + } + axisConfig.setConfigurator(this); + return axisConfig; + } + + public void loadRampartModule() throws DeploymentException { + try { + ClassLoader deploymentClassLoader = + org.apache.axis2.deployment.util.Utils.createClassLoader( + new URL[]{rampart_mar_url}, + axisConfig.getModuleClassLoader(), + true, + (File) axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR)); + final AxisModule module = new AxisModule(); + module.setModuleClassLoader(deploymentClassLoader); + module.setParent(axisConfig); + //String moduleFile = fileUrl.substring(0, fileUrl.indexOf(".mar")); + if (module.getName() == null) { + module.setName(org.apache.axis2.util.Utils.getModuleName("rampart-1.4")); + module.setVersion(org.apache.axis2.util.Utils.getModuleVersion("rampart-1.4")); + } + populateModule(module, rampart_mar_url); + module.setFileName(rampart_mar_url); + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { + public Object run() throws IOException { + addNewModule(module, axisConfig); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + + org.apache.axis2.util.Utils. + calculateDefaultModuleVersion(axisConfig.getModules(), axisConfig); + axisConfig.validateSystemPredefinedPhases(); + } catch (IOException e) { + throw new DeploymentException(e); + } + } + + private void populateModule(AxisModule module, URL moduleUrl) throws DeploymentException { + try { + ClassLoader classLoader = module.getModuleClassLoader(); + InputStream moduleStream = classLoader.getResourceAsStream("META-INF/module.xml"); + if (moduleStream == null) { + moduleStream = classLoader.getResourceAsStream("meta-inf/module.xml"); + } + if (moduleStream == null) { + throw new DeploymentException( + Messages.getMessage( + DeploymentErrorMsgs.MODULE_XML_MISSING, moduleUrl.toString())); + } + ModuleBuilder moduleBuilder = new ModuleBuilder(moduleStream, module, axisConfig); + moduleBuilder.populateModule(); + } catch (IOException e) { + throw new DeploymentException(e); + } + } + + /************** end of fix *************************************************************/ + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java new file mode 100644 index 0000000000..34899a4af0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java @@ -0,0 +1,105 @@ +/* + * 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.binding.ws.axis2; + +import java.net.URI; +import java.util.HashMap; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.HandlerDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.RequestURIBasedDispatcher; +import org.apache.axis2.util.JavaUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A Tuscany specific Axis2 Dispatcher that enables using services + * exposed at the SCA defined service URI instead of /services/<serviceName> + * + * @version $Rev$ $Date$ + */ +public class TuscanyDispatcher extends RequestURIBasedDispatcher { + + public static final String NAME = "TuscanyDispatcher"; + private static final Log log = LogFactory.getLog(RequestURIBasedDispatcher.class); + private static final boolean isDebugEnabled = log.isDebugEnabled(); + + /* + * (non-Javadoc) + * + * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext) + */ + @Override + public AxisService findService(MessageContext messageContext) throws AxisFault { + EndpointReference toEPR = messageContext.getTo(); + + if (toEPR != null) { + if(isDebugEnabled){ + log.debug("Checking for Service using target endpoint address : " + toEPR.getAddress()); + } + + String path = URI.create(toEPR.getAddress()).getPath(); + + ConfigurationContext configurationContext = messageContext.getConfigurationContext(); + AxisConfiguration registry = configurationContext.getAxisConfiguration(); + + String serviceName = findAxisServiceName(registry, path); + return registry.getService(serviceName); + + } else { + if(isDebugEnabled){ + log.debug("Attempted to check for Service using null target endpoint URI"); + } + return null; + } + } + + @Override + public void initDispatcher() { + init(new HandlerDescription(NAME)); + } + + protected String findAxisServiceName(AxisConfiguration registry, String path) { + HashMap services = registry.getServices(); + if (services == null) { + return null; + } + String[] parts = JavaUtils.split(path, '/'); + String serviceName = ""; + for (int i=parts.length-1; i>=0; i--) { + serviceName = parts[i] + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + serviceName = "/" + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + } + + return null; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java new file mode 100644 index 0000000000..21fef3e5d8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java @@ -0,0 +1,238 @@ +/* + * 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.binding.ws.axis2; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.axiom.attachments.utils.IOUtils; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.deployment.DeploymentConstants; +import org.apache.axis2.description.AxisDescription; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.PolicyInclude; +import org.apache.axis2.transport.http.ListingAgent; +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.axis2.util.ExternalPolicySerializer; +import org.apache.axis2.util.JavaUtils; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.neethi.Policy; +import org.apache.neethi.PolicyRegistry; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; + +/** + * A Tuscany specific Axis2 ListingAgent as the Axis2 one does not work + * with the Tuscany service names which include slash ('/') characters. + * Unfortunately it ends up having to copy a fair amount of Axis2 code to do this. + * + * @version $Rev$ $Date$ + */ +public class TuscanyListingAgent extends ListingAgent { + + private static final String LIST_SINGLE_SERVICE_JSP_NAME = + "listSingleService.jsp"; + + public TuscanyListingAgent(ConfigurationContext aConfigContext) { + super(aConfigContext); + } + + /** + * This method overrides the Axis2 listing agent's computation of the + * service name. + */ + @Override + public String extractServiceName(String urlString) { + String serviceName = findAxisServiceName(urlString); + setContextRoot(urlString, serviceName); + return serviceName; + } + + /** + * Override ?xsd processing so that WSDL documents with XSD imports + * and includes work correctly. When we move to Axis2 1.4, we may + * be able to use SchemaSupplier to do this in a cleaner way. Also + * ensure that the correct IP address and port are returned by ?wsdl. + */ + @Override + public void processListService(HttpServletRequest req, + HttpServletResponse res) + throws IOException, ServletException { + + String url = req.getRequestURL().toString(); + String query = req.getQueryString(); + + // for ?wsdl requests, need to update the WSDL with correct IPaddr and port + int wsdl = query.indexOf("wsdl"); + if (wsdl >= 0) { + String serviceName = extractServiceName(url); + HashMap services = configContext.getAxisConfiguration().getServices(); + if ((services != null) && !services.isEmpty()) { + AxisService axisService = (AxisService)services.get(serviceName); + Parameter wsld4jdefinition = axisService.getParameter(WSDLConstants.WSDL_4_J_DEFINITION); + Definition definition = (Definition)wsld4jdefinition.getValue(); + for (Object s : definition.getServices().values()) { + for (Object p : ((Service)s).getPorts().values()) { + String endpointURL = Axis2ServiceProvider.getPortAddress((Port)p); + String modifiedURL = setIPAddress(endpointURL, url); + Axis2ServiceProvider.setPortAddress((Port)p, modifiedURL); + } + } + } + } + + // handle ?xsd requests here + int xsd = query.indexOf("xsd"); + if (xsd >= 0) { + String serviceName = extractServiceName(url); + HashMap services = configContext.getAxisConfiguration().getServices(); + if ((services != null) && !services.isEmpty()) { + Object serviceObj = services.get(serviceName); + if (serviceObj != null) { + String xsds = req.getParameter("xsd"); + if (xsds != null && !"".equals(xsds)) { + // a schema name (perhaps with path) is present + AxisService axisService = (AxisService)serviceObj; + ArrayList schemas = axisService.getSchema(); + for (Object rootSchema : axisService.getSchema()) { + XmlSchema schema = getSchema(((XmlSchema)rootSchema), xsds); + if (schema != null) { + // found the schema + res.setContentType("text/xml"); + OutputStream out = res.getOutputStream(); + schema.write(new OutputStreamWriter(out, "UTF8")); + out.flush(); + out.close(); + return; + } + } + } + } + } + } + + // in all other cases, delegate to the Axis2 code + super.processListService(req, res); + } + + private XmlSchema getSchema(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + if (extSchema.getSchemaLocation().endsWith(name)) { + return extSchema.getSchema(); + } else { + XmlSchema schema = getSchema(extSchema.getSchema(), name); + if (schema != null) { + return schema; + } + } + } + } + return null; + } + + private String findAxisServiceName(String path) { + HashMap services = configContext.getAxisConfiguration().getServices(); + if (services == null) { + return null; + } + String[] parts = JavaUtils.split(path, '/'); + String serviceName = ""; + for (int i=parts.length-1; i>=0; i--) { + serviceName = parts[i] + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + serviceName = "/" + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + } + + return null; + } + + /** + * Hack for Tuscany to get ?wsdl working with Tuscany service names + * Can go once moved up to Axis2 1.3 + */ + private void setContextRoot(String filePart, String serviceName) { + String contextRoot = configContext.getContextRoot(); + if (contextRoot != null && contextRoot.length() > 0) { + if (contextRoot.equals("/")) { + configContext.setServicePath("/"); + } else { + int i = filePart.indexOf(contextRoot) + contextRoot.length(); + int j = filePart.lastIndexOf(serviceName); + if (i>=j || (i+1 == j)) { + configContext.setServicePath("/"); + } else { + String mapping = filePart.substring(i+1, j); + configContext.setServicePath(mapping); + } + } + configContext.setContextRoot(contextRoot); + } + } + + private static String setIPAddress(String wsdlURI, String requestURI) { + try { + URI wsdlURIObj = new URI(wsdlURI); + String wsdlHost = wsdlURIObj.getHost(); + int wsdlPort = wsdlURIObj.getPort(); + String wsdlAddr = wsdlHost + (wsdlPort != -1 ? ":" + Integer.toString(wsdlPort) : ""); + URI requestURIObj = new URI(requestURI); + String ipAddr = HttpUtils.getIpAddress(); + int requestPort = requestURIObj.getPort(); + String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : ""); + return wsdlURI.replace(wsdlAddr, newAddr); + } catch (Exception e) { + // URI string not in expected format, so return the WSDL URI unmodified + return wsdlURI; + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java new file mode 100644 index 0000000000..5254a5716c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.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.binding.ws.axis2; + +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.SCADefinitions; +import org.apache.tuscany.sca.provider.SCADefinitionsProvider; +import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; + +/** + * Provider for Policy Intents and PolicySet definitions related to security + * + * @version $Rev$ $Date$ + */ +public class WSBindingDefinitionsProvider implements SCADefinitionsProvider { + private String definitionsFile = "org/apache/tuscany/sca/binding/ws/axis2/definitions.xml"; + URLArtifactProcessor urlArtifactProcessor = null; + + public WSBindingDefinitionsProvider(ExtensionPointRegistry registry) { + URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); + } + + public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { + final URL definitionsFileUrl = getClass().getClassLoader().getResource(definitionsFile); + SCADefinitions scaDefn = null; + try { + final URI uri = new URI(definitionsFile); + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction<SCADefinitions>() { + public SCADefinitions run() throws ContributionReadException { + return (SCADefinitions)urlArtifactProcessor.read(null, uri, definitionsFileUrl); + } + }); + } catch (Exception e) { + throw new SCADefinitionsProviderException(e); + } + return scaDefn; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java new file mode 100644 index 0000000000..4c18c89353 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java @@ -0,0 +1,111 @@ +/* + * 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.binding.ws.axis2.policy.configurator; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.security.auth.Subject; + +import org.apache.axiom.om.util.Base64; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.SecurityUtil; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; +import org.osoa.sca.ServiceRuntimeException; + +/** + * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingBasicAuthenticationConfigurator { + + + public static void setOperationOptions(OperationClient operationClient, Message msg, BasicAuthenticationPolicy policy) { + String username = null; + String password = null; + + // get the security context + Subject subject = SecurityUtil.getSubject(msg); + BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject, + BasicAuthenticationPrincipal.class); + + // could use the security principal to look up basic auth credentials + if ( principal != null ) { + username = ((BasicAuthenticationPrincipal)principal).getName(); + password = ((BasicAuthenticationPrincipal)principal).getPassword(); + } + + if (username == null || password == null ){ + throw new ServiceRuntimeException("Basic authentication username or password is null"); + } + + HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); + List<String> auth = new ArrayList<String>(); + auth.add(Authenticator.BASIC); + authenticator.setAuthSchemes(auth); + authenticator.setPreemptiveAuthentication(true); + authenticator.setUsername(username); + authenticator.setPassword(password); + + operationClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, + authenticator); + } + + public static void parseHTTPHeader(MessageContext messageContext, Message msg, BasicAuthenticationPolicy policy) { + + Map httpHeaderProperties = (Map)messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + + String basicAuthString = (String)httpHeaderProperties.get("Authorization"); + String decodedBasicAuthString = null; + String username = null; + String password = null; + + if (basicAuthString != null) { + basicAuthString = basicAuthString.trim(); + + if (basicAuthString.startsWith("Basic ")) { + decodedBasicAuthString = new String(Base64.decode(basicAuthString.substring(6))); + } + + int collonIndex = decodedBasicAuthString.indexOf(':'); + + if (collonIndex == -1){ + username = decodedBasicAuthString; + } else { + username = decodedBasicAuthString.substring(0, collonIndex); + password = decodedBasicAuthString.substring(collonIndex + 1); + } + } + + // get the security context + Subject subject = SecurityUtil.getSubject(msg); + BasicAuthenticationPrincipal principal = new BasicAuthenticationPrincipal(username, + password); + subject.getPrincipals().add(principal); + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java new file mode 100644 index 0000000000..647f934c02 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.configurator; + + + +import javax.xml.namespace.QName; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.context.MessageContext; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeader; +import org.apache.tuscany.sca.invocation.Message; + + +/** + * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingHeaderConfigurator { + + + public static void setHeader(MessageContext messageContext, Message msg, QName headerQName) { + + if (headerQName != null){ + SOAPEnvelope envelope = messageContext.getEnvelope(); + OMFactory factory = envelope.getOMFactory(); + SOAPHeader soapHeader = envelope.getHeader(); + + Axis2SOAPHeader header = Axis2HeaderPolicyUtil.getHeader(msg, headerQName) ; + + if (header != null){ + soapHeader.addChild(header.getAsSOAPHeaderBlock(factory)); + } + } + } + + public static void getHeader(MessageContext messageContext, Message msg, QName headerQName, Axis2SOAPHeader header) { + + SOAPEnvelope sev = messageContext.getEnvelope(); + SOAPHeader sh = sev.getHeader(); + OMElement omHeader = sh.getFirstChildWithName(headerQName); + + header.setAsSOAPHeaderBlock(omHeader); + + msg.getHeaders().add(header); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..a48ff54c77 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# 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.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..370b83f87b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.binding.ws.axis2.WSBindingDefinitionsProvider
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml new file mode 100644 index 0000000000..6bff613a7c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <sca:bindingType type="sca:binding.ws" mayProvide="SOAP SOAP.1_1 SOAP.1_2 MTOM" alwaysProvides=""/>
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
+ <sca:intent name="SOAP" constrains="sca:binding.ws">
+ <sca:description>
+ Communication through this binding requires SOAP
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP.1_1">
+ <sca:description>
+ Communication through this binding requires SOAP 1.1
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP.1_2">
+ <sca:description>
+ Communication through this binding requires SOAP 1.2
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="MTOM" constrains="sca:binding.ws">
+ <sca:description>
+ Communication through this binding requires MTOM support
+ </sca:description>
+ </sca:intent>
+ </sca:definitions>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml new file mode 100644 index 0000000000..ea32836f2a --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml @@ -0,0 +1,504 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<axisconfig name="AxisJava2.0"> + <!-- ================================================= --> + <!-- Parameters --> + <!-- ================================================= --> + <parameter name="hotdeployment">true</parameter> + <parameter name="hotupdate">false</parameter> + <parameter name="enableMTOM">false</parameter> + <parameter name="enableSwA">false</parameter> + + <!-- Customized by Tuscany --> + <!-- parameter name="OutflowSecurity"> + <action> + <items>Timestamp</items> + </action> + </parameter--> + + <!--Uncomment if you want to enable file caching for attachments --> + <!--parameter name="cacheAttachments">true</parameter> + <parameter name="attachmentDIR"></parameter> + <parameter name="sizeThreshold">4000</parameter--> + + <!--This will give out the timout of the configuration contexts, in milliseconds--> + <parameter name="ConfigContextTimeoutInterval">30000</parameter> + + <!--During a fault, stacktrace can be sent with the fault message. The following flag will control --> + <!--that behavior.--> + + <!-- Customized by Tuscany --> + <parameter name="sendStacktraceDetailsWithFaults">true</parameter> + + <!--If there aren't any information available to find out the fault reason, we set the message of the exception--> + <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be --> + <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag--> + <!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.--> + <parameter name="DrillDownToRootCauseForFaultReason">false</parameter> + + <parameter name="userName">admin</parameter> + <parameter name="password">axis2</parameter> + + <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.--> + <!--ServicesDirectory only works on the following cases--> + <!---File based configurator and in that case the value should be a file URL (http:// not allowed)--> + <!---When creating URL Based configurator with URL “file://†--> + <!--- War based configurator with expanded case , --> + + <!--All the other scenarios it will be ignored.--> + <!--<parameter name="ServicesDirectory">service</parameter>--> + <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path--> + <!--<parameter name="ModulesDirectory">modules</parameter>--> + + + + <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context--> + <!--root which can configured using the following contextRoot parameter--> + <!--<parameter name="contextRoot">axis2</parameter>--> + + <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguiush those endpoints--> + <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this --> + <!--context path to proper Axis2 servlets--> + + <!-- Customized by Tuscany --> + <parameter name="servicePath">/</parameter> + + <!--<parameter name="restPath">rest</parameter>--> + + <!-- Following parameter will completely disable REST handling in Axis2--> + + <parameter name="disableREST" locked="true">false</parameter> + + <!--POJO deployer , this will alow users to drop .class file and make that into a service--> + <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/> + + <!-- Following parameter will set the host name for the epr--> + <!--<parameter name="hostname" locked="true">myhost.com</parameter>--> + + <!-- If you have a frontend host which exposes this webservice using a different public URL --> + <!-- use this parameter to override autodetected url --> + <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>--> + + + <!-- The way of adding listener to the system--> + <!-- <listener class="org.apache.axis2.ObserverIMPL">--> + <!-- <parameter name="RSS_URL">http://127.0.0.1/rss</parameter>--> + <!-- </listener>--> + + <!-- ================================================= --> + <!-- Message Receivers --> + <!-- ================================================= --> + <!--This is the deafult MessageReceiver for the system , if you want to have MessageReceivers for --> + <!--all the other MEP implement it and add the correct entry to here , so that you can refer from--> + <!--any operation --> + <!--Note : You can ovrride this for a particular service by adding the same element with your requirement--> + <messageReceivers> + + <!-- Added by Tuscany --> + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" + class="org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInMessageReceiver"/> + + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" + class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" + class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> + + <!-- Added by Tuscany --> + <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" + class="org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver"/> + + <!-- Added by Tuscany --> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only" + class="org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInMessageReceiver"/> + + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only" + class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out" + class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> + + <!-- Added by Tuscany --> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out" + class="org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver"/> + + </messageReceivers> + <!-- ================================================= --> + <!-- Message Formatter --> + <!-- ================================================= --> + <!--Following content type to message formatter mapping can be used to implement support for different message --> + <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. --> + <messageFormatters> + <messageFormatter contentType="application/x-www-form-urlencoded" + class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/> + <messageFormatter contentType="multipart/form-data" + class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/> + <messageFormatter contentType="application/xml" + class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/> + </messageFormatters> + + <!-- ================================================= --> + <!-- Message Builders --> + <!-- ================================================= --> + <!--Following content type to builder mapping can be used to implement support for different message --> + <!--formats in Axis2. These message formats are expected to be resolved based on the content type. --> + <messageBuilders> + <messageBuilder contentType="application/xml" + class="org.apache.axis2.builder.ApplicationXMLBuilder"/> + <messageBuilder contentType="application/x-www-form-urlencoded" + class="org.apache.axis2.builder.XFormURLEncodedBuilder"/> + <messageBuilder contentType="multipart/form-data" + class="org.apache.axis2.builder.MultipartFormDataBuilder"/> + </messageBuilders> + + <!-- ================================================= --> + <!-- Transport Ins --> + <!-- ================================================= --> + <transportReceiver name="http" + class="org.apache.axis2.transport.http.SimpleHTTPServer"> + + <!-- Customized by Tuscany --> + <parameter name="port" locked="false">6060</parameter> + + <!-- Here is the complete list of supported parameters (see example settings further below): + port: the port to listen on (default 6060) + hostname: if non-null, url prefix used in reply-to endpoint references (default null) + originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1") + requestTimeout: value in millis of time that requests can wait for data (default 20000) + requestTcpNoDelay: true to maximize performance and minimize latency (default true) + false to minimize bandwidth consumption by combining segments + requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25) + requestMaxThreadPoolSize: number of threads available for request processing if queue fills up (default 150) + note that default queue never fills up: see HttpFactory + threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180) + note that no such threads can exist with default unbounded request queue + threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS) + --> + <!-- <parameter name="hostname">http://www.myApp.com/ws</parameter> --> + <!-- <parameter name="originServer">My-Server/1.1</parameter> --> + <!-- <parameter name="requestTimeout">10000</parameter> --> + <!-- <parameter name="requestTcpNoDelay">false</parameter> --> + <!-- <parameter name="requestCoreThreadPoolSize">50</parameter> --> + <!-- <parameter name="RequestMaxThreadPoolSize">100</parameter> --> + <!-- <parameter name="threadKeepAliveTime">240000</parameter> --> + <!-- <parameter name="threadKeepAliveTimeUnit">MILLISECONDS</parameter> --> + </transportReceiver> + + <!-- Added by Tuscany --> + <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> + <!-- These configuation parameters now come from the binding.ws uri + or from a policy set + <parameter name="myTopicConnectionFactory"> + <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> + <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter> + <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter> + </parameter> + + <parameter name="myQueueConnectionFactory"> + <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> + <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter> + <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter> + </parameter> + + <parameter name="default"> + <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> + <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter> + <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter> + </parameter> + --> + </transportReceiver> + + <!-- ================================================= --> + <!-- Non-blocking http/s Transport Listener --> + + <!-- the non blocking http transport based on HttpCore + NIO extensions + <transportReceiver name="http" class="org.apache.axis2.transport.nhttp.HttpCoreNIOListener"> + <parameter name="port" locked="false">9000</parameter> + <parameter name="non-blocking" locked="false">true</parameter> + </transportReceiver>--> + + <!-- the non blocking https transport based on HttpCore + SSL-NIO extensions + <transportReceiver name="https" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSSLListener"> + <parameter name="port" locked="false">9002</parameter> + <parameter name="non-blocking" locked="false">true</parameter> + <parameter name="keystore" locked="false"> + <KeyStore> + <Location>identity.jks</Location> + <Type>JKS</Type> + <Password>password</Password> + <KeyPassword>password</KeyPassword> + </KeyStore> + </parameter> + <parameter name="truststore" locked="false"> + <TrustStore> + <Location>trust.jks</Location> + <Type>JKS</Type> + <Password>password</Password> + </TrustStore> + </parameter>--> + <!--<parameter name="SSLVerifyClient">require</parameter> + supports optional|require or defaults to none --> + <!--</transportReceiver>--> + + <!-- ================================================= --> + <!-- Mail Transport Listener --> + <!-- This is a sample configuration. It assumes a mail server running in localhost. + Listener pops messages that comes to the email address red@localhost. Users + password is red. Listener connect to the server every 3000 milliseconds. + Parameters with "transport." prefix is Axis2 specific. Others are all from Java Mail API. + http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html + --> + <!-- ================================================= --> + <!--<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.SimpleMailListener"> + <parameter name="mail.pop3.host">localhost</parameter> + <parameter name="mail.pop3.user">red</parameter> + <parameter name="mail.store.protocol">pop3</parameter> + <parameter name="transport.mail.pop3.password">red</parameter> + <parameter name="transport.mail.replyToAddress">red@localhost</parameter> + <parameter name="transport.listener.interval">3000</parameter> + </transportReceiver>--> + + <!--Uncomment if you want to have TCP transport support--> + <!--transportReceiver name="tcp" + class="org.apache.axis2.transport.tcp.TCPServer"> + <parameter name="port">6060</parameter-->> + <!--If you want to give your own host address for EPR generation--> + <!--uncomment the following paramter , and set it as you required.--> + <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>--> + <!-- /transportReceiver --> + + <!-- ================================================= --> + <!-- Transport Outs --> + <!-- ================================================= --> + + <transportSender name="tcp" + class="org.apache.axis2.transport.tcp.TCPTransportSender"/> + <transportSender name="local" + class="org.apache.axis2.transport.local.LocalTransportSender"/> + <transportSender name="http" + class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + <parameter name="PROTOCOL">HTTP/1.1</parameter> + <parameter name="Transfer-Encoding">chunked</parameter> + + <!-- If following is set to 'true', optional action part of the Content-Type will not be added to the SOAP 1.2 messages --> + <!-- <parameter name="OmitSOAP12Action">true</parameter> --> + </transportSender> + + <transportSender name="https" + class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> + <parameter name="PROTOCOL">HTTP/1.1</parameter> + <parameter name="Transfer-Encoding">chunked</parameter> + </transportSender> + <transportSender name="jms" + class="org.apache.axis2.transport.jms.JMSSender"/> + + <!-- ================================================= --> + <!-- Non-blocking http/s Transport Sender --> + + <!-- the non-blocking http transport sender based on HttpCore + NIO extensions + <transportSender name="http" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSender"> + <parameter name="non-blocking" locked="false">true</parameter> + </transportSender>--> + + <!-- the non-blocking https transport sender based on HttpCore + NIO SSL extensions + <transportSender name="https" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSSLSender"> + <parameter name="non-blocking" locked="false">true</parameter> + <parameter name="keystore" locked="false"> + <KeyStore> + <Location>identity.jks</Location> + <Type>JKS</Type> + <Password>password</Password> + <KeyPassword>password</KeyPassword> + </KeyStore> + </parameter> + <parameter name="truststore" locked="false"> + <TrustStore> + <Location>trust.jks</Location> + <Type>JKS</Type> + <Password>password</Password> + </TrustStore> + </parameter>--> + <!--<parameter name="HostnameVerifier">DefaultAndLocalhost</parameter> + supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified --> + <!--</transportSender>--> + + <!-- ================================================= --> + <!-- Mail Transport Sender --> + <!--Only need to uncomment the sender. Configuration is achieved with every client. + At any instant mail host should be given. Sample configuration has been given. + http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html + --> + <!-- ================================================= --> + <!--<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender"> + <parameter name="mail.smtp.host">localhost</parameter> + </transportSender>--> + + <!-- ================================================= --> + <!-- Global Modules --> + <!-- ================================================= --> + <!-- Comment this to disable Addressing --> + + <!-- Commented out by Tuscany + <module ref="addressing"/> + --> + + <!-- Added by Tuscany --> + <!-- + <module ref="rampart"/> + --> + + <!-- wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" /> + </wsp:Policy> + </sp:SignedSupportingTokens> + + <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> + <ramp:user>TuscanyWsUser</ramp:user> + <ramp:passwordType>PasswordText</ramp:passwordType> + <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.ClientPWCBHandler</ramp:passwordCallbackClass> + </ramp:RampartConfig> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy--> + + <!--Configuring module , providing parameters for modules whether they refer or not--> + <!--<moduleConfig name="addressing">--> + <!--<parameter name="addressingPara">N/A</parameter>--> + <!--</moduleConfig>--> + + <!-- ================================================= --> + <!-- Clustering --> + <!-- ================================================= --> + <!-- Configure and uncomment following for preparing Axis2 to a clustered environment --> + <!-- + <cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager"> + <parameter name="param1">value1</parameter> + <parameter name="domain">apache.axis2.domain</parameter> + <configurationManager class="org.apache.axis2.cluster.configuration.TribesConfigurationManager"> + <listener class="org.apache.axis2.cluster.configuration.DefaultConfigurationManagerListener"/> + </configurationManager> + <contextManager class="org.apache.axis2.cluster.context.TribesContextManager"> + <listener class="org.apache.axis2.cluster.context.DefaultContextManagerListener"/> + </contextManager> + </cluster> + --> + + <!-- ================================================= --> + <!-- Phases --> + <!-- ================================================= --> + <phaseOrder type="InFlow"> + <!-- System pre defined phases --> + <phase name="Transport"> + + <!-- Added by Tuscany --> + <handler name="TuscanyDispatcher" + class="org.apache.tuscany.sca.binding.ws.axis2.TuscanyDispatcher"> + <order phase="Transport"/> + </handler> + + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"> + <order phase="Transport"/> + </handler> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"> + <order phase="Transport"/> + </handler> + </phase> + <phase name="Addressing"> + <handler name="AddressingBasedDispatcher" + class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"> + <order phase="Addressing"/> + </handler> + </phase> + <phase name="Security"/> + <phase name="PreDispatch"/> + <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/> + <handler name="RequestURIOperationDispatcher" + class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/> + <handler name="SOAPMessageBodyBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/> +<!-- + <handler name="HTTPLocationBasedDispatcher" + class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/> +--> + </phase> + <phase name="RMPhase"/> + <!-- System pre defined phases --> + <!-- After Postdispatch phase module author or service author can add any phase he want --> + <phase name="OperationInPhase"/> + <phase name="soapmonitorPhase"/> + </phaseOrder> + <phaseOrder type="OutFlow"> + <!-- user can add his own phases to this area --> + <phase name="soapmonitorPhase"/> + <phase name="OperationOutPhase"/> + <!--system predefined phase--> + <!--these phase will run irrespective of the service--> + <phase name="RMPhase"/> + <phase name="PolicyDetermination"/> + <phase name="MessageOut"/> + <phase name="Security"/> + </phaseOrder> + <phaseOrder type="InFaultFlow"> + <phase name="Addressing"> + <handler name="AddressingBasedDispatcher" + class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"> + <order phase="Addressing"/> + </handler> + </phase> + <phase name="Security"/> + <phase name="PreDispatch"/> + <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"> + <handler name="RequestURIBasedDispatcher" + class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/> + <handler name="SOAPActionBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/> + <handler name="RequestURIOperationDispatcher" + class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/> + <handler name="SOAPMessageBodyBasedDispatcher" + class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/> +<!-- + <handler name="HTTPLocationBasedDispatcher" + class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/> +--> + </phase> + <phase name="RMPhase"/> + <!-- user can add his own phases to this area --> + <phase name="OperationInFaultPhase"/> + <phase name="soapmonitorPhase"/> + </phaseOrder> + <phaseOrder type="OutFaultFlow"> + <!-- user can add his own phases to this area --> + <phase name="soapmonitorPhase"/> + <phase name="OperationOutFaultPhase"/> + <phase name="RMPhase"/> + <phase name="PolicyDetermination"/> + <phase name="MessageOut"/> + <phase name="Security"/> + </phaseOrder> +</axisconfig> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list new file mode 100644 index 0000000000..e6e70dfd4b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list @@ -0,0 +1 @@ +rampart-1.4.mar
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar Binary files differnew file mode 100644 index 0000000000..ec870734a5 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java new file mode 100644 index 0000000000..2ce23bf2c4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java @@ -0,0 +1,83 @@ +/* + * 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.binding.ws.axis2; + +import junit.framework.TestCase; + +public class Axis2ReferenceTestCase extends TestCase { + + public void testInvokeService() throws Exception { +// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); +// ServiceContract contract = new JavaServiceContract(); +// Operation operation = new Operation<Type>("sayHi", null, null, null, false, null, NO_CONVERSATION); +// TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(contract, operation); +// assertNotNull(targetInvoker); +// assertFalse(targetInvoker instanceof Axis2AsyncTargetInvoker); + } + + public void testAsyncTargetInvoker() throws Exception { +// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); +// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class +// Wire inboundWire = EasyMock.createNiceMock(Wire.class); +// JavaServiceContract contract = new JavaServiceContract(Greeter.class); +// contract.setCallbackName(""); +// contract.setCallbackClass(GreetingCallback.class); +// Operation<Type> callbackOp = +// new Operation<Type>("sayHiCallback", null, null, null, true, null, NO_CONVERSATION); +// HashMap<String, Operation<Type>> callbackOps = new HashMap<String, Operation<Type>>(); +// callbackOps.put("sayHiCallback", callbackOp); +// contract.setCallbackOperations(callbackOps); +// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes(); +// EasyMock.replay(inboundWire); +// +// axis2Reference.setWire(inboundWire); +// Operation operation = new Operation<Type>("sayHi", null, null, null, true, null, NO_CONVERSATION); +// TargetInvoker asyncTargetInvoker = axis2Reference.createTargetInvoker(contract, operation); +// assertNotNull(asyncTargetInvoker); +// assertTrue(asyncTargetInvoker instanceof Axis2AsyncTargetInvoker); + } + +// @SuppressWarnings("unchecked") +// private Axis2ReferenceBinding createAxis2Reference(String webAppName, String serviceName) throws Exception { +// //Create WebServiceBindingDefinition +// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; +// URL url = getClass().getResource(wsdlLocation); +// assertNotNull("Could not find wsdl " + url.toString(), url); +// +// WSDLFactory factory = WSDLFactory.newInstance(); +// WSDLReader reader = factory.newWSDLReader(); +// reader.setFeature("javax.wsdl.verbose", false); +// InputSource input = new InputSource(url.openStream()); +// Definition wsdlDef = reader.readWSDL(url.toString(), input); +// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", +// "SOAPService")); +// Port port = wsdlService.getPort("SoapPort"); +// WebServiceBindingDefinition wsBinding = +// new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); +// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. +// // TODO figure out what to do with the service contract +// ServiceContract<?> contract = new WSDLServiceContract(); +// contract.setInterfaceClass(Greeter.class); +// return new Axis2ReferenceBinding(URI.create(serviceName), +// wsBinding, +// contract, +// null, +// null); +// } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java new file mode 100644 index 0000000000..d4d20414e5 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java @@ -0,0 +1,104 @@ +/* + * 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.binding.ws.axis2; + +import junit.framework.TestCase; + +public class Axis2ServiceTestCase extends TestCase { + + public void testInvokeService() throws Exception { +// TestServletHost tomcatHost = new TestServletHost(); +// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, false); +// axis2Service.start(); +// +// if (true) return; +// Servlet servlet = tomcatHost.getMapping("testWebAppName/serviceBindings/testServiceName"); +// assertNotNull(servlet); +// +// //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet +// //To be done: + + } + + public void testAsyncMessageReceiver() throws Exception { + +// TestServletHost tomcatHost = new TestServletHost(); +// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, true); +// axis2Service.start(); + } + +// @SuppressWarnings("unchecked") +// private Axis2ServiceBinding createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback) +// throws Exception { +// //Create WebServiceBindingDefinition +// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; +// URL url = getClass().getResource(wsdlLocation); +// assertNotNull("Could not find wsdl " + url.toString(), url); +// +// WSDLFactory factory = WSDLFactory.newInstance(); +// WSDLReader reader = factory.newWSDLReader(); +// reader.setFeature("javax.wsdl.verbose", false); +// InputSource input = new InputSource(url.openStream()); +// Definition wsdlDef = reader.readWSDL(url.toString(), input); +// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", +// "SOAPService")); +// Port port = wsdlService.getPort("SoapPort"); +// WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); +// +// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. +//// WireService wireService = EasyMock.createNiceMock(WireService.class); +//// wireService.createProxy(EasyMock.isA(Class.class), EasyMock.isA(Wire.class)); +//// EasyMock.expectLastCall().andReturn(null); +//// EasyMock.replay(wireService); +// +// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class +// Wire inboundWire = EasyMock.createNiceMock(Wire.class); +// JavaServiceContract contract = new JavaServiceContract(Greeter.class); +// Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>(); +// for (Method m : Greeter.class.getMethods()) { +// opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null)); +// } +// contract.setOperations(opMap); +// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes(); +// if (callback) { +// contract.setCallbackName(""); +// } +// EasyMock.replay(inboundWire); +// +// Wire outboundWire = EasyMock.createNiceMock(Wire.class); +// Map<Operation<?>, InvocationChain> map = new HashMap<Operation<?>, InvocationChain>(); +// EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once(); +// EasyMock.replay(outboundWire); +// +// TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); +// ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext(); +// Axis2ServiceBinding axis2Service = +// new Axis2ServiceBinding(URI.create(serviceName), +// contract, +// null, +// wsBinding, +// tomcatHost, +// configurationContext, null); +// axis2Service.setWire(inboundWire); +//// axis2Service.setOutboundWire(outboundWire); +// +// return axis2Service; +// } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java new file mode 100644 index 0000000000..767f59646f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java @@ -0,0 +1,31 @@ +/* + * 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.binding.ws.axis2; + +public interface Greeter { + + String sayHi(); + + String greetMe(String requestType); + + void greetMeOneWay(String requestType); + + void greetMeWithCallback(String requestType); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java new file mode 100644 index 0000000000..e5e76af0b7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2; + +public interface GreetingCallback { + + void greetMeCallback(String greetMeResponse); +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java new file mode 100644 index 0000000000..4e7c1b0539 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java @@ -0,0 +1,34 @@ +/*
+ * 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.binding.ws.axis2.itests;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Account {
+
+ CustomerProfileData getCustomerProfile(String loginID);
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java new file mode 100644 index 0000000000..5edb4ddc5a --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java @@ -0,0 +1,33 @@ +/*
+ * 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.binding.ws.axis2.itests;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class AccountService implements Account {
+
+ public CustomerProfileData getCustomerProfile(String loginID) {
+ return new CustomerProfileData(loginID);
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java new file mode 100644 index 0000000000..2dc7d8dee4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java @@ -0,0 +1,58 @@ +/* + * 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.binding.ws.axis2.itests; + +import java.io.Serializable; + +public class Bar implements Serializable { + private static final long serialVersionUID = 1249963611910502668L; + + private String s; + private int x; + private Integer y; + + private Boolean b; + + public Boolean getB() { + return b; + } + public void setB(Boolean b) { + this.b = b; + } + public String getS() { + return s; + } + public void setS(String s) { + this.s = s; + } + public int getX() { + return x; + } + public void setX(int x) { + this.x = x; + } + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java new file mode 100644 index 0000000000..5c1ee6a435 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.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.binding.ws.axis2.itests;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class CustomerProfileData {
+
+ private String firstName;
+ private String lastName;
+ private String address;
+ private String email;
+ private String loginID;
+ private String password;
+ private int id;
+
+ public CustomerProfileData(String loginID) {
+ firstName = "John";
+ lastName = "Doe";
+ address = "345 Main Street";
+ email = "john@doe.org";
+ this.loginID = loginID;
+ password = "hello";
+ id = 1234;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String firstName) {
+ this.lastName = lastName;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getLoginID() {
+ return loginID;
+ }
+
+ public void setLoginID(String loginID) {
+ this.loginID = loginID;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java new file mode 100644 index 0000000000..6fccbcfd00 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java @@ -0,0 +1,29 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Echo { + + Foo echoFoo(Foo foo); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java new file mode 100644 index 0000000000..5e1a4cf259 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java @@ -0,0 +1,33 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Reference; + +public class EchoComponent implements Echo { + + @Reference + public Echo echoWS; + + public Foo echoFoo(Foo foo) { + return echoWS.echoFoo(foo); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java new file mode 100644 index 0000000000..d028ced69e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java @@ -0,0 +1,29 @@ +/* + * 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.binding.ws.axis2.itests; + + +public class EchoImpl implements Echo { + + public Foo echoFoo(Foo foo) { + return foo; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java new file mode 100644 index 0000000000..c7b503af17 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java @@ -0,0 +1,36 @@ +/* + * 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.binding.ws.axis2.itests; + +import java.io.Serializable; + +public class Foo implements Serializable { + private static final long serialVersionUID = 4879476066850018458L; + + private Bar[] bars; + + public Bar[] getBars() { + return bars; + } + + public void setBars(Bar[] bars) { + this.bars = bars; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java new file mode 100644 index 0000000000..f474c12af3 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java @@ -0,0 +1,29 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorld { + + String getGreetings(String s); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java new file mode 100644 index 0000000000..88705c1a95 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java @@ -0,0 +1,33 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldComponent implements HelloWorld { + + @Reference + public HelloWorld helloWorldWS; + + public String getGreetings(String s) { + return helloWorldWS.getGreetings(s); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java new file mode 100644 index 0000000000..f30286feea --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java @@ -0,0 +1,51 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +public class HelloWorldMultiService implements HelloWorldOM, HelloWorldOM2 { + + public OMElement getGreetings(OMElement requestOM) { + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello " + name)); + + return responseOM; + } + + public OMElement getGreetings2(OMElement requestOM) { + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello2 " + name)); + + return responseOM; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java new file mode 100644 index 0000000000..7ee48d4451 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java @@ -0,0 +1,77 @@ +/* + * 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.binding.ws.axis2.itests ; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldNoWSDLTestCase extends TestCase { + + private SCADomain domain; + + public void testHelloWorld() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + /** + * Test a a WS call with a complex type + */ + public void testEchoFoo() throws Exception { + Echo echo = domain.getService(Echo.class, "EchoComponent"); + + Foo f = new Foo(); + Bar b1 = new Bar(); + b1.setS("petra"); + b1.setX(1); + b1.setY(new Integer(2)); + b1.setB(Boolean.TRUE); + Bar b2 = new Bar(); + b2.setS("beate"); + b2.setX(3); + b2.setY(new Integer(4)); + b2.setB(Boolean.FALSE); + f.setBars(new Bar[] { b1, b2} ); + + Foo f2 = echo.echoFoo(f); + + assertEquals("petra", f2.getBars()[0].getS()); + assertEquals(1, f2.getBars()[0].getX()); + assertEquals(2, f2.getBars()[0].getY().intValue()); + assertTrue(f2.getBars()[0].getB().booleanValue()); + assertEquals("beate", f2.getBars()[1].getS()); + assertEquals(3, f2.getBars()[1].getX()); + assertEquals(4, f2.getBars()[1].getY().intValue()); + assertFalse(f2.getBars()[1].getB().booleanValue()); + + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java new file mode 100644 index 0000000000..274f6c8d28 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java @@ -0,0 +1,30 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldOM { + + OMElement getGreetings(OMElement parmE); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java new file mode 100644 index 0000000000..bf371430a1 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java @@ -0,0 +1,30 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldOM2 { + + OMElement getGreetings2(OMElement parmE); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java new file mode 100644 index 0000000000..d1cbfb88fd --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java @@ -0,0 +1,34 @@ +/* + * 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.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Reference; + +public class HelloWorldOMComponent implements HelloWorldOM { + + @Reference + public HelloWorldOM helloWorldWS; + + public OMElement getGreetings(OMElement om) { + return helloWorldWS.getGreetings(om); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java new file mode 100644 index 0000000000..71d7bf68fb --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +public class HelloWorldOMService implements HelloWorldOM { + + public OMElement getGreetings(OMElement requestOM) { + System.out.println(" **** getGreetings **** "); + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello " + name)); + + return responseOM; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java new file mode 100644 index 0000000000..e7511027c2 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java @@ -0,0 +1,58 @@ +/* + * 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.binding.ws.axis2.itests; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite"); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java new file mode 100644 index 0000000000..017d9bb478 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java @@ -0,0 +1,28 @@ +/* + * 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.binding.ws.axis2.itests; + +public class HelloWorldService implements HelloWorld { + + public String getGreetings(String s) { + return "Hello " + s; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java new file mode 100644 index 0000000000..a3a43d032f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java @@ -0,0 +1,46 @@ +/* + * 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.binding.ws.axis2.itests; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldTestCase extends TestCase { + + private SCADomain domain; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite"); + helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java new file mode 100644 index 0000000000..8e17b89f33 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java @@ -0,0 +1,58 @@ +/*
+ * 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.binding.ws.axis2.itests;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class HelloWorldWSDLMergedTestCase extends TestCase {
+
+ private SCADomain domain;
+ private HelloWorldOM helloWorld;
+
+ public void testHelloWorld() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite");
+ helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldWSDLMergedComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java new file mode 100644 index 0000000000..b276d8210f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java @@ -0,0 +1,96 @@ +/*
+ * 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.binding.ws.axis2.itests;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.transport.http.server.HttpUtils;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class QuestionMarkWSDLImportTestCase extends TestCase {
+
+ private SCADomain domain;
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from the WSDL
+ */
+ public void testWSDLImportPortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8086/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments", true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8086/AccountService?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://account2/AccountService/$promoted$ep1", "AccountService"));
+ Port port = service.getPort("AccountSoapPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8086/AccountService", endpoint);
+ }
+
+ private String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java new file mode 100644 index 0000000000..59eb6164fa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java @@ -0,0 +1,96 @@ +/*
+ * 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.binding.ws.axis2.itests;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.transport.http.server.HttpUtils;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $
+ */
+public class QuestionMarkWSDLIncludeTestCase extends TestCase {
+
+ private SCADomain domain;
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from the WSDL
+ */
+ public void testWSDLIncludePortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments", true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$ep1", "AccountService"));
+ Port port = service.getPort("AccountSoapPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8085/AccountService", endpoint);
+ }
+
+ private String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java new file mode 100644 index 0000000000..0508f28e11 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.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.binding.ws.axis2.itests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class QuestionMarkWSDLTestCase extends TestCase { + + private SCADomain domain; + + /** + * Tests ?wsdl works and returns the correct port endpoint from the WSDL + */ + public void testWSDLPortEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/services/HelloWorldWebService?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/services/HelloWorldWebService?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://helloworld/HelloWorldService/$promoted$ep1", + "HelloWorldService")); + Port port = service.getPort("HelloWorldSoapPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/services/HelloWorldWebService", endpoint); + } + + /** + * Tests ?wsdl works and returns the correct port endpoint from binding.ws with a custom URI + */ + public void testCustomEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/foo/bar?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/foo/bar?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://itests.axis2.ws.binding.sca.tuscany.apache.org/", + "HelloWorldService")); + Port port = service.getPort("HelloWorldPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/foo/bar", endpoint); + } + + protected String getEndpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java new file mode 100644 index 0000000000..5efbedba4c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java @@ -0,0 +1,68 @@ +/* + * 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.binding.ws.axis2.itests; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.ServiceRuntimeException; + +/** + * This test verifies that the Endpoint URI specified in the wsdl takes precedence over the URI specified + * in binding. Ref: WS Binding Specification V1.00 - Section 2.1.1 + * + * @version $Rev$ $Date$ + */ +public class UriPrecedenceTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testUriPrecedence() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-prec", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-prec", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + try { + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } catch (ServiceRuntimeException e) { + fail("Endpoint URI from wsdl did not take precedence over URI in binding."); + } + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite"); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..56d0537a44 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/* + * 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.binding.ws.axis2.itests.endpoints; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractHelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testCalculator() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java new file mode 100644 index 0000000000..661afdddad --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2.itests.endpoints; + +public class DefaultMultiServiceTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java new file mode 100644 index 0000000000..9b2e0eafa0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2.itests.endpoints; + +public class DefaultSingleServiceTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java new file mode 100644 index 0000000000..98d9a73926 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2.itests.endpoints; + +public class WSDLExplicitURITestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java new file mode 100644 index 0000000000..201d11a79f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2.itests.endpoints; + +public class WSDLRelativeURITestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java new file mode 100644 index 0000000000..f5d87cdcee --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java @@ -0,0 +1,47 @@ +/* + * 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.binding.ws.axis2.itests.epr; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldTestCase extends TestCase { + + private SCADomain domain; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite"); + helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java new file mode 100644 index 0000000000..82f6ff4c5d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java @@ -0,0 +1,36 @@ +/*
+ * 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.binding.ws.axis2.itests.mtom;
+
+import javax.activation.DataHandler;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the FileTransfer service and invoke it.
+ */
+public class FileTransferClient implements FileTransferService {
+
+ @Reference
+ public FileTransferService fileTransferWS;
+
+ public String uploadFile(DataHandler attachment) throws Exception {
+ return fileTransferWS.uploadFile(attachment);
+ }
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java new file mode 100644 index 0000000000..e592134037 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java @@ -0,0 +1,49 @@ +/*
+ * 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.binding.ws.axis2.itests.mtom;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import junit.framework.TestCase;
+import org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferService;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class FileTransferMTOMTestCase extends TestCase {
+
+ private SCADomain domain;
+
+ public void testFileTransfer() throws Exception {
+ // For testing purpose lets try uploading FileTransferClient.java file.
+ DataHandler dataHandler = new DataHandler(new FileDataSource("FileTransferClient.java"));
+ FileTransferService filetransfer = domain.getService(FileTransferService.class, "FileTransferServiceComponent");
+ assertEquals("File uploaded Sucessfully", filetransfer.uploadFile(dataHandler));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java new file mode 100644 index 0000000000..ce79b47b86 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java @@ -0,0 +1,32 @@ +/*
+ * 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.binding.ws.axis2.itests.mtom;
+
+import org.osoa.sca.annotations.Remotable;
+import javax.activation.DataHandler;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface FileTransferService {
+
+ public String uploadFile(DataHandler attachment) throws Exception;
+}
+
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java new file mode 100644 index 0000000000..8d4a020560 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java @@ -0,0 +1,51 @@ +/*
+ * 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.binding.ws.axis2.itests.mtom;
+
+import org.osoa.sca.annotations.Service;
+import javax.activation.DataHandler;
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(FileTransferService.class)
+public class FileTransferServiceImpl implements FileTransferService {
+
+ public String uploadFile(DataHandler attachment) throws Exception {
+
+ //OMText binaryNode = (OMText) (attachment.getFirstElement()).getFirstOMChild();
+ //DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
+
+ // Use this code to save the file we have received.
+ /*DataHandler dataHandler = attachment;
+
+ File file = new File("transferedfile.java");
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ dataHandler.writeTo(fileOutputStream);
+ fileOutputStream.flush();
+ fileOutputStream.close();*/
+
+ System.out.println(attachment.getContentType());
+
+ return "File uploaded Sucessfully";
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..6cdb12c221 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public abstract class AbstractHelloWorldOMTestCase extends TestCase {
+
+ private SCADomain domain;
+ private HelloWorldOM helloWorld;
+
+ public void testHelloWorld() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance(getCompositeName());
+ helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java new file mode 100644 index 0000000000..67d6f1c56e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Client UserId/Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..45c5472100 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntegrityPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Integrity Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java new file mode 100644 index 0000000000..7a4b50cc2c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler....");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java new file mode 100644 index 0000000000..18a713a243 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java @@ -0,0 +1,24 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+public class WSSecurityAuthenticationTestCaseFIXME extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java new file mode 100644 index 0000000000..1fd1b8d48e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java @@ -0,0 +1,42 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+import java.security.Provider;
+import java.security.Security;
+
+public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCase {
+
+ /**
+ * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ // Workaround an issue with IBM JDK
+ Provider jce = Security.getProvider("IBMJCE");
+ if (jce != null) {
+ // Make sure IBMJCE is used first
+ Security.removeProvider("IBMJCE");
+ Security.insertProviderAt(jce, 1);
+ }
+ super.setUp();
+ }
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java new file mode 100644 index 0000000000..824132161c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java @@ -0,0 +1,24 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.configparams;
+
+public class WSSecurityIntegrityTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..458a472479 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.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.binding.ws.axis2.itests.policy.mixed; + +import junit.framework.Assert; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public abstract class AbstractHelloWorldOMTestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + @Test + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @After + public void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java new file mode 100644 index 0000000000..88fc0d63fa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java @@ -0,0 +1,50 @@ +/* + * 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.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..0d8914156f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java @@ -0,0 +1,50 @@ +/* + * 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.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class IntegrityPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Integrity Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java new file mode 100644 index 0000000000..5840f71057 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java @@ -0,0 +1,49 @@ +/* + * 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.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java new file mode 100644 index 0000000000..db5b88f9ac --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java @@ -0,0 +1,24 @@ +/* + * 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.binding.ws.axis2.itests.policy.mixed; + +public class WSSecurityMixedTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..04de589fb1 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public abstract class AbstractHelloWorldOMTestCase extends TestCase {
+
+ private SCADomain domain;
+ private HelloWorldOM helloWorld;
+
+ public void testHelloWorld() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance(getCompositeName());
+ helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java new file mode 100644 index 0000000000..cf342653c7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Client UserId/Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..84b64d3902 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntegrityPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Integrity Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java new file mode 100644 index 0000000000..04825b6b56 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java @@ -0,0 +1,45 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler....");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java new file mode 100644 index 0000000000..a439ff4c8f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java @@ -0,0 +1,24 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+public class WSSecurityAuthenticationTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java new file mode 100644 index 0000000000..f37a8deeb7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java @@ -0,0 +1,42 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+import java.security.Provider;
+import java.security.Security;
+
+public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCase {
+
+ /**
+ * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ // Workaround an issue with IBM JDK
+ Provider jce = Security.getProvider("IBMJCE");
+ if (jce != null) {
+ // Make sure IBMJCE is used first
+ Security.removeProvider("IBMJCE");
+ Security.insertProviderAt(jce, 1);
+ }
+ super.setUp();
+ }
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java new file mode 100644 index 0000000000..18bbf98628 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java @@ -0,0 +1,24 @@ +/*
+ * 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.binding.ws.axis2.itests.policy.wspolicy;
+
+public class WSSecurityIntegrityTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java new file mode 100644 index 0000000000..b2ccd7f97d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java @@ -0,0 +1,58 @@ +/* + * 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.binding.ws.axis2.itests.soap12 ; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldSOAP12TestCase extends TestCase { + + private SCADomain domain; + + public void testHelloWorld() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClient"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP11() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP11"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP12() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP12"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java new file mode 100644 index 0000000000..8d378565d4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java @@ -0,0 +1,138 @@ +/* + * 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.binding.ws.axis2.itests.soap12; + +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class QuestionMarkWSDLTestCase extends TestCase { + + private static boolean newGenerator = true; + private SCADomain domain; + + /** + * Tests ?wsdl returns a soap 1.1 port by default + */ + public void testSOAPDefault() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep1?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); + + String endpoint = getSOAP11Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep1", endpoint); + } + + /** + * Tests ?wsdl returns a soap 1.1 port when binding uses requires="SOAP.1_1" + */ + public void testSOAP11Endpoint() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep2?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); + + String endpoint = getSOAP11Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep2", endpoint); + } + + /** + * Tests ?wsdl returns a soap 1.2 port when binding uses requires="SOAP.1_2" + */ + public void testSOAP12Endpoint() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep3?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP12port_http"); + + String endpoint = getSOAP12Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep3", endpoint); + } + + protected String getSOAP11Endpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + protected String getSOAP12Endpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAP12Address) { + return ((SOAP12Address) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler new file mode 100644 index 0000000000..32b042402b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler @@ -0,0 +1,20 @@ +# 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.
+#
+# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures
+# handler classname;qname=<policy intent addressed>;model=<policy model class>
+org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyHandler;intent=http://tuscany.apache.org/xmlns/sca/1.0#wsAuthentication,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite new file mode 100644 index 0000000000..5cea469e3d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorld">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <!-- interface.java interface="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld" / -->
+ <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/services/HelloWorldWebService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <!-- interface.java interface="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld" / -->
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite new file mode 100644 index 0000000000..b11c50b00c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldNoWSDL">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <!-- interface.java interface="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld" / -->
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <!-- interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" / -->
+ <!-- interface.java interface="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld" / -->
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </reference>
+
+ <service name="Echo" promote="EchoService">
+ <binding.ws uri="http://localhost:8085/Echo"/>
+ </service>
+
+ <component name="EchoService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.EchoImpl"/>
+ </component>
+
+ <component name="EchoComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent"/>
+ <reference name="echoWS" />
+ </component>
+
+ <reference name="echoWS" promote="EchoComponent/echoWS">
+ <binding.ws uri="http://localhost:8085/Echo"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd new file mode 100644 index 0000000000..f09ed09b6a --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="CustomerProfileData">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ <xsd:element name="address" type="xsd:string" />
+ <xsd:element name="email" type="xsd:string" />
+ <xsd:element name="loginID" type="xsd:string" />
+ <xsd:element name="password" type="xsd:string" />
+ <xsd:element name="id" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd new file mode 100644 index 0000000000..ec67b84851 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:include schemaLocation="customerdata.xsd" />
+ <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd" />
+
+</xsd:schema>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd new file mode 100644 index 0000000000..7c903c6394 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="CustomerProfileInfo">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite new file mode 100644 index 0000000000..394bf05506 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint1">
+
+ <!--
+ exposing a component which has multiple services with a WS binding,
+ endpoint should be <componentURI>/<serviceName> so for this composite:
+ http://localhost:8085/HelloWorldService/service1
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService/HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" + wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldMultiService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite new file mode 100644 index 0000000000..c7081b9a72 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint1">
+
+ <!--
+ exposing a component with a WS binding, endpoint should be <componentURI>/<serviceName>
+ unless the component has just a single service in which case its just <componentURI>
+ so for this composite: http://localhost:8085/HelloWorldService
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" + wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite new file mode 100644 index 0000000000..7d3e1d1327 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite new file mode 100644 index 0000000000..c2cd598508 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint4">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with a relative URL
+ so for this composite the service is: http://localhost:8085/HelloWorldService/myRelativeURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld-om-relative-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-relative-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-relative-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-relative-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld/myRelativeURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl new file mode 100644 index 0000000000..fe68755c47 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld-om-relative-uri" xmlns:tns="http://helloworld-om-relative-uri" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld-om"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-relative-uri" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8085/HelloWorldService/helloWorld/myRelativeURI"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite new file mode 100644 index 0000000000..38a7c045be --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorld">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws>
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/myService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <binding.ws>
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/myService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl new file mode 100644 index 0000000000..7bf47bc412 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld-om-merged" xmlns:tns="http://helloworld-om-merged" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld-om-bindings"> + + <wsdl:import namespace="http://helloworld-om-merged" + location="helloworld-om-porttype.wsdl"/> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://endpoint.not.used"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite new file mode 100644 index 0000000000..dee0effd99 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldOM-Merged">
+
+ <service name="helloWorld" promote="HelloWorldMergedService">
+ <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+
+ <component name="HelloWorldMergedService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldWSDLMergedComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ </component>
+
+ <reference name="mergedHelloWorldWS" promote="HelloWorldWSDLMergedComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl new file mode 100644 index 0000000000..c66fa51c34 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://helloworld-om-merged" xmlns:tns="http://helloworld-om-merged" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld-om-porttype">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-merged" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl new file mode 100644 index 0000000000..baa223f41c --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld-om-uri" xmlns:tns="http://helloworld-om-uri" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld-om"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-uri" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8085/myExplicitURI"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite new file mode 100644 index 0000000000..8fcbdef33d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldOM">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl new file mode 100644 index 0000000000..73ca02246d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld-om" xmlns:tns="http://helloworld-om" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld-om"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://endpoint.not.used"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite new file mode 100644 index 0000000000..c506b09bb2 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldPrec">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <interface.wsdl interface="http://helloworld-prec#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+ <interface.wsdl interface="http://helloworld-prec#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-prec#wsdl.port(HelloWorldService/HelloWorldSoapPort)"
+ uri="http://INVALID.END.POINT" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl new file mode 100644 index 0000000000..5908c43e7d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> + +<!-- $Rev$ $Date$ --> + +<wsdl:definitions targetNamespace="http://helloworld-prec" xmlns:tns="http://helloworld-prec" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld-prec"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld-prec" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8085/HelloWorldService/helloWorld"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl new file mode 100644 index 0000000000..1a2272d7ee --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService"/> + </wsdl:port> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2"> + <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/> + </wsdl:port> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3"> + <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl new file mode 100644 index 0000000000..1c67a1b26a --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions
+ targetNamespace="http://filetransfer"
+ xmlns:tns="http://filetransfer"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="filetransfer">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://filetransfer" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="uploadFile">
+ <complexType>
+ <sequence>
+ <element name="attachment" type="xsd:base64Binary"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="uploadFileResponse">
+ <complexType>
+ <sequence>
+ <element name="uploadFileReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="uploadFileRequest">
+ <wsdl:part element="tns:uploadFile" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="uploadFileResponse">
+ <wsdl:part element="tns:uploadFileResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="FileTransfer">
+ <wsdl:operation name="uploadFile">
+ <wsdl:input message="tns:uploadFileRequest" name="uploadFileRequest"/>
+ <wsdl:output message="tns:uploadFileResponse" name="uploadFileResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="FileTransferSoapBinding" type="tns:FileTransfer">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="uploadFile">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="uploadFileRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="uploadFileResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="FileTransferService">
+ <wsdl:port binding="tns:FileTransferSoapBinding" name="FileTransferSoapPort">
+ <wsdlsoap:address location="http://localhost:8085/FileTransferServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite new file mode 100644 index 0000000000..03a16d9433 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://filetransfer"
+ xmlns:hw="http://filetransfer"
+ name="filetransferws">
+
+ <component name="FileTransferServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferServiceImpl" />
+ <service name="FileTransferService">
+ <interface.wsdl interface="http://filetransfer#wsdl.interface(FileTransfer)" />
+ <binding.ws uri="http://localhost:8085/FileTransferService"/>
+ </service>
+ </component>
+
+ <component name="FileTransferClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferClient"/>
+ <reference name="fileTransferWS" />
+ </component>
+
+ <reference name="fileTransferWS" promote="FileTransferClientComponent/fileTransferWS">
+ <binding.ws uri="http://localhost:8085/FileTransferService"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite new file mode 100644 index 0000000000..da5bab45e8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="authentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsClientAuthenticationPolicy">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite new file mode 100644 index 0000000000..13e002be1b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="confidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" requires="confidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite new file mode 100644 index 0000000000..2f6fab0d07 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="integrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" requires="integrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml new file mode 100644 index 0000000000..8fa2d3b8c0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <!-- WS Security POLICY SETS -->
+ <sca:policySet name="wsAuthenticationPolicy"
+ provides="sca:authentication"
+ appliesTo="//sca:binding.ws"
+ >
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ServerPWCBHandler</passwordCallbackClass>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsClientAuthenticationPolicy"
+ provides="tuscany:wsAuthentication"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <user>TuscanyWsUser</user>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ClientPWCBHandler</passwordCallbackClass>" +
+ <passwordType>PasswordText</passwordType>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsIntegrityPolicy"
+ provides="sca:integrity"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <user>TuscanyWsUser</user>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>" +
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsConfidentialityPolicy"
+ provides="sca:confidentiality"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Timestamp Signature Encrypt</items>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp Signature Encrypt</items>
+ <user>TuscanyWsUser</user>
+ <encryptionUser>TuscanyWsUser</encryptionUser>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ <encryptionKeyIdentifier>SKIKeyIdentifier</encryptionKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+ </sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties new file mode 100644 index 0000000000..592edf183b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties @@ -0,0 +1,20 @@ +## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd
+org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks Binary files differnew file mode 100644 index 0000000000..307edb9b37 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml new file mode 100644 index 0000000000..65f8cb67d8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <sca:intent name="wsAuthentication"
+ constrains="sca:binding.ws">
+ <description>
+ Communitcation thro this binding required Authentication.
+ </description>
+ </sca:intent>
+
+ </sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite new file mode 100644 index 0000000000..12b2b18e55 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + name="endpoint3"> + + <!-- + exposing a component with a WS binding using a WSDL port with an explicit URL + so for this composite the service is: http://localhost:8085/myExplicitURI + --> + + <service name="helloWorld" promote="HelloWorldService" + policySets="tuscany:serverWsPolicyForAuthentication"> + <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" /> + </service> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/> + </component> + + <component name="HelloWorldComponent"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/> + <reference name="helloWorldWS" /> + </component> + + <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" + policySets="tuscany:clientWsPolicyForAuthentication"> + <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)" + uri="http://localhost:8085/myExplicitURI"/> + </reference> + +</composite> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml new file mode 100644 index 0000000000..871e889835 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml @@ -0,0 +1,323 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> + + <!-- WS Security POLICY SETS --> + <sca:policySet name="wsAuthenticationPolicy" + provides="sca:authentication" + appliesTo="//sca:binding.ws" + > + <tuscany:wsConfigParam> + <parameter name="InflowSecurity"> + <action> + <items>UsernameToken</items> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsClientAuthenticationPolicy" + provides="tuscany:wsAuthentication" + appliesTo="//sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="OutflowSecurity"> + <action> + <items>UsernameToken</items> + <user>TuscanyWsUser</user> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler</passwordCallbackClass>" + + <passwordType>PasswordText</passwordType> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsMixedReceiverIntegrityPolicy" + provides="sca:integrity" + appliesTo="//sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="InflowSecurity"> + <action> + <items>Signature</items> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsMixedSenderIntegrityPolicy" + provides="sca:integrity" + appliesTo="//sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="OutflowSecurity"> + <action> + <items>Signature</items> + <user>TuscanyWsUser</user> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler</passwordCallbackClass> + <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsServerAuthenticationIntegrityPolicy" + provides="sca:authentication sca:integrity" + appliesTo="//sca:binding.ws" + > + <tuscany:wsConfigParam> + <parameter name="InflowSecurity"> + <action> + <items>UsernameToken Signature</items> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass> + </action> + </parameter> + <parameter name="OutflowSecurity"> + <action> + <items>Signature</items> + <user>TuscanyWsUser</user> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass> + <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="wsClientAuthenticationIntegrityPolicy" + provides="tuscany:wsAuthentication" + appliesTo="//sca:binding.ws"> + <tuscany:wsConfigParam> + <parameter name="InflowSecurity"> + <action> + <items>Signature</items> + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + </action> + </parameter> + <parameter name="OutflowSecurity"> + <action> + <items>UsernameToken Signature</items> + <user>TuscanyWsUser</user> + <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler</passwordCallbackClass>" + + <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile> + <passwordType>PasswordText</passwordType> + <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier> + </action> + </parameter> + </tuscany:wsConfigParam> + </sca:policySet> + + <sca:policySet name="clientWsPolicyForAuthentication" + provides="sca:authentication" + appliesTo="//sca:binding.ws" + > + <wsp:Policy wsu:Id="UTOverTransport" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" /> + </wsp:Policy> + </sp:SignedSupportingTokens> + + <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> + <ramp:user>TuscanyWsUser</ramp:user> + <!-- ramp:passwordType>PasswordText</ramp:passwordType--> + <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler</ramp:passwordCallbackClass> + </ramp:RampartConfig> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + </sca:policySet> + + <sca:policySet name="serverWsPolicyForAuthentication" + provides="sca:authentication" + appliesTo="//sca:binding.ws" + > + <wsp:Policy wsu:Id="UTOverTransport" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" /> + </wsp:Policy> + </sp:SignedSupportingTokens> + + <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> + <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</ramp:passwordCallbackClass> + </ramp:RampartConfig> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + </sca:policySet> + + <!-- A policyset that uses WS Policy --> + <sca:policySet name="serverWsPolicyForIntegrity" + provides="sca:integrity" + appliesTo="//sca:binding.ws"> + <wsp:Policy wsu:Id="SignOnly" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:InitiatorToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:InitiatorToken> + <sp:RecipientToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:RecipientToken> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:TripleDesRsa15/> + </wsp:Policy> + </sp:AlgorithmSuite> + <sp:Layout> + <wsp:Policy> + <sp:Strict/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + </wsp:Policy> + </sp:AsymmetricBinding> + <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:MustSupportRefKeyIdentifier/> + <sp:MustSupportRefIssuerSerial/> + </wsp:Policy> + </sp:Wss10> + <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <sp:Body/> + </sp:SignedParts> + + <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> + <ramp:user>TuscanyWsUser</ramp:user> + <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser> + <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass> + + <ramp:signatureCrypto> + <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"> + <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property> + <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property> + <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property> + </ramp:crypto> + </ramp:signatureCrypto> + </ramp:RampartConfig> + + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + </sca:policySet> + + + <!-- A policyset that uses WS Policy --> + <!-- sca:policySet name="tuscany:wsSecurityPolicyForIntegritys" + provides="sca:integrity" + appliesTo="sca:binding.ws"> + <wsp:Policy wsu:Id="SignOnly" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:InitiatorToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:InitiatorToken> + <sp:RecipientToken> + <wsp:Policy> + <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10/> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:RecipientToken> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:TripleDesRsa15/> + </wsp:Policy> + </sp:AlgorithmSuite> + <sp:Layout> + <wsp:Policy> + <sp:Strict/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + </wsp:Policy> + </sp:AsymmetricBinding> + <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <wsp:Policy> + <sp:MustSupportRefKeyIdentifier/> + <sp:MustSupportRefIssuerSerial/> + </wsp:Policy> + </sp:Wss10> + <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> + <sp:Body/> + </sp:SignedParts> + + <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> + <ramp:user>TuscanyWsUser</ramp:user> + <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser> + <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler</ramp:passwordCallbackClass> + + <ramp:signatureCrypto> + <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"> + <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property> + <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks</ramp:property> + <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property> + </ramp:crypto> + </ramp:signatureCrypto> + </ramp:RampartConfig> + + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> + </sca:policySet--> + </sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties new file mode 100644 index 0000000000..cb188e6676 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd +org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks Binary files differnew file mode 100644 index 0000000000..307edb9b37 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite new file mode 100644 index 0000000000..2a22a0905d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsSecurityPolicyForAuthentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsSecurityPolicyForAuthentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite new file mode 100644 index 0000000000..e6f999aad7 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="wsSecurityPolicyForConfidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="wsSecurityPolicyForConfidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite new file mode 100644 index 0000000000..d9e889768b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsSecurityPolicyForIntegrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsSecurityPolicyForIntegrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml new file mode 100644 index 0000000000..d7f40ccf0e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+
+ <!-- WS Security POLICY SETS -->
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForAuthentication"
+ provides="sca:authentication"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="UTOverTransport"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" />
+ </wsp:Policy>
+ </sp:SignedSupportingTokens>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:passwordType>PasswordText</ramp:passwordType>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.ClientPWCBHandler</ramp:passwordCallbackClass>
+ </ramp:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForIntegrity"
+ provides="sca:integrity"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="SignOnly"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForConfidentiality"
+ provides="sca:confidentiality"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="SigEncr" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+ <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:EncryptedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+
+ <ramp:encryptionCypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:encryptionCypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
+ </sca:policySet>
+
+ </sca:definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks Binary files differnew file mode 100644 index 0000000000..307edb9b37 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl new file mode 100644 index 0000000000..41a491361f --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://account3"
+ xmlns:tns="http://account3"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="questionmark-import-nested">
+
+ <wsdl:types>
+ <xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://account3"
+ xmlns:account="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:import namespace="http://accounts" schemaLocation="customerdefs.xsd" />
+
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="tns:getCustomerProfile" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Account">
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
+ <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl new file mode 100644 index 0000000000..99a8c6d81d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://account2" + xmlns:tns="http://account2" + xmlns:account3="http://account3" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="questionmark-import"> + + <wsdl:import namespace="http://account3" location="/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl" /> + + <wsdl:binding name="AccountSoapBinding" type="account3:Account"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getCustomerProfile"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="getCustomerProfileRequest"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="getCustomerProfileResponse"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort"> + <wsdlsoap:address location="http://localhost:8086/AccountService" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl new file mode 100644 index 0000000000..80e4b62801 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://accounts" + xmlns:tns="http://accounts" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="questionmark-include"> + + <wsdl:types> + <xsd:schema elementFormDefault="qualified" + targetNamespace="http://accounts" + xmlns:account="http://accounts" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd" /> + + <xsd:element name="getCustomerProfile"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="loginID" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getCustomerProfileResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerProfile" + type="xsd:string" /> + <!-- + <xsd:element name="customerProfile" + type="account:CustomerProfileData" /> + --> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="getCustomerProfileRequest"> + <wsdl:part element="tns:getCustomerProfile" name="parameters" /> + </wsdl:message> + + <wsdl:message name="getCustomerProfileResponse"> + <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="Account"> + <wsdl:operation name="getCustomerProfile"> + <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" /> + <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" /> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="AccountSoapBinding" type="tns:Account"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getCustomerProfile"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="getCustomerProfileRequest"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="getCustomerProfileResponse"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + + </wsdl:binding> + + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort"> + <wsdlsoap:address location="http://localhost:8085/AccountService" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite new file mode 100644 index 0000000000..008d42d03d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="QuestionMarkWSDLImport">
+
+ <service name="ep1" promote="AccountService">
+ <binding.ws wsdlElement="http://account2#wsdl.port(AccountService/AccountSoapPort)" />
+ </service>
+
+ <component name="AccountService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.AccountService" />
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite new file mode 100644 index 0000000000..7fff56377b --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="QuestionMarkWSDLInclude">
+
+ <service name="ep1" promote="AccountService">
+ <binding.ws wsdlElement="http://accounts#wsdl.port(AccountService/AccountSoapPort)" />
+ </service>
+
+ <component name="AccountService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.AccountService" />
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite new file mode 100644 index 0000000000..c042ae5675 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + name="QuestionMarkWSDLTests"> + + <service name="ep1" promote="HelloWorldService"> + <binding.ws wsdlElement="http://helloworld#wsdl.service(HelloWorldService)"/> + <!-- + <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/> + --> + </service> + + <service name="ep2" promote="HelloWorldService"> + <binding.ws uri="http://localhost:8085/foo/bar" /> + </service> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/> + </component> + +</composite> diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite new file mode 100644 index 0000000000..fbd4c66c45 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorld">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </service>
+ <service name="helloWorldSOAP" promote="HelloWorldService">
+ <binding.ws requires="SOAP" uri="http://localhost:8085/helloWorldSOAP"/>
+ </service>
+ <service name="helloWorldSOAP11" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_1" uri="http://localhost:8085/helloWorldSOAP11"/>
+ </service>
+ <service name="helloWorldSOAP12" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_2" uri="http://localhost:8085/helloWorldSOAP12"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP11">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP12">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldClient/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP" requires="SOAP"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP11/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP11" requires="SOAP.1_1"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP12/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP12" requires="SOAP.1_2"/>
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite new file mode 100644 index 0000000000..033a77eea6 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="QuestionMarkWSDLTests">
+
+ <service name="ep1" promote="HelloWorldService">
+ <binding.ws uri="http://localhost:8085/ep1"/>
+ </service>
+
+ <service name="ep2" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_1" uri="http://localhost:8085/ep2"/>
+ </service>
+
+ <service name="ep3" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_2" uri="http://localhost:8085/ep3"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/LICENSE b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/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/branches/sca-java-1.4/modules/binding-ws-wsdlgen/NOTICE b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/pom.xml b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/pom.xml new file mode 100644 index 0000000000..3afa296bc1 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/pom.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-ws-wsdlgen</artifactId> + <name>Apache Tuscany SCA Web Service binding WSDL Generator</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java-jaxws</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-xsd</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-xsd-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-databinding</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.binding.ws.wsdlgen</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.binding.ws.wsdlgen*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java new file mode 100644 index 0000000000..de1cab15d8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java @@ -0,0 +1,345 @@ +/* + * 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.binding.ws.wsdlgen; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.wsdl.Definition; +import javax.wsdl.PortType; +import javax.wsdl.WSDLException; +import javax.wsdl.xml.WSDLWriter; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ResolverExtension; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +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.impl.InvalidWSDLException; +import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPoint; +import org.apache.tuscany.sca.xsd.XSDFactory; + +/** + * @version $Rev$ $Date$ + */ +public class BindingWSDLGenerator { + private static final Logger logger = Logger.getLogger(BindingWSDLGenerator.class.getName()); + private static final QName SOAP12_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0", "SOAP.1_2"); + + public static boolean printWSDL; // external code sets this to print generated WSDL + + private BindingWSDLGenerator() { + // this class has static methods only and cannot be instantiated + } + + /** + * Log a warning message. + * @param problem + */ + private static void logWarning(Problem problem) { + Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getBundleName()); + if (problemLogger != null){ + problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams()); + } else { + logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getBundleName()); + } + } + + /** + * Report a warning. + * @param message + * @param binding + * @param parameters + */ + private static void warning(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) { + Problem problem = new ProblemImpl(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.WARNING, wsBinding, message, (Object[])messageParameters); + if (monitor != null) { + monitor.problem(problem); + } else { + logWarning(problem); + } + } + + /** + * Report an error. + * @param message + * @param binding + * @param parameters + */ + private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) { + Problem problem = new ProblemImpl(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, (Object[])messageParameters); + if (monitor != null) { + monitor.problem(problem); + } else { + throw new WSDLGenerationException(problem.toString(), null, problem); + } + } + + /** + * Report an exception error. + * @param message + * @param binding + * @param exception + */ + private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, Exception ex) { + Problem problem = new ProblemImpl(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, ex); + if (monitor != null) { + monitor.problem(problem); + } else { + throw new WSDLGenerationException(problem.toString(), ex, problem); + } + } + + /** + * Report a fatal error. + * @param message + * @param binding + * @param exception + */ + private static void fatal(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) { + Problem problem = new ProblemImpl(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR,wsBinding, message, (Object[])messageParameters); + throw new WSDLGenerationException(problem.toString(), null, problem); + } + + /** + * Report a fatal exception error. + * @param message + * @param binding + * @param exception + */ + private static void fatal(Monitor monitor, String message, WebServiceBinding wsBinding, Exception ex) { + Problem problem = new ProblemImpl(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, ex); + throw new WSDLGenerationException(problem.toString(), ex, problem); + } + + /** + * This method can be called from the binding builder or from the runtime. + * Report problems and exceptions in the most appropriate way for both + * of these cases. + */ + public static void generateWSDL(Component component, + AbstractContract contract, + WebServiceBinding wsBinding, + ExtensionPointRegistry extensionPoints, + Monitor monitor) { + try { + createWSDLDocument(component, contract, wsBinding, extensionPoints, monitor); + } catch (WSDLGenerationException ex) { + if (ex.getProblem() != null) { + warning(monitor, "WsdlGenProblem", wsBinding, component.getName(), contract.getName()); + if (monitor != null) { + monitor.problem(ex.getProblem()); + } else { + throw ex; + } + } else if (ex.getCause() instanceof Exception) { + warning(monitor, "WsdlGenException", wsBinding, component.getName(), contract.getName()); + error(monitor, "UnexpectedException", wsBinding, (Exception)ex.getCause()); + } else { // should never happen + throw new IllegalStateException(ex); + } + } catch (RuntimeException ex) { + warning(monitor, "WsdlGenException", wsBinding, component.getName(), contract.getName()); + error(monitor, "UnexpectedException", wsBinding, ex); + } + } + + private static void createWSDLDocument(Component component, + AbstractContract contract, + WebServiceBinding wsBinding, + ExtensionPointRegistry extensionPoints, + Monitor monitor) { + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); + WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); + + if (((Contract)contract).getInterfaceContract(wsBinding) == null) { + // can happen if incorrect component service name + fatal(monitor, "MissingInterfaceContract", wsBinding, component.getName(), contract.getName()); + } + + InterfaceContract icontract = wsBinding.getBindingInterfaceContract(); + if (icontract == null) { + icontract = ((Contract)contract).getInterfaceContract(wsBinding).makeUnidirectional(false); + if (icontract instanceof JavaInterfaceContract) { + ModelResolver resolver = component instanceof ResolverExtension ? + ((ResolverExtension)component).getModelResolver() : null; + icontract = createWSDLInterfaceContract( + (JavaInterfaceContract)icontract, + requiresSOAP12(wsBinding), + resolver, + dataBindings, + wsdlFactory, + xsdFactory, + monitor); + } else { + try { + //TUSCANY-2316 Cloning the Interface Contract to avoid overriding data binding information + icontract = (InterfaceContract)icontract.clone(); + } catch (Exception e) { + //ignore + } + } + wsBinding.setBindingInterfaceContract(icontract); + } + + // TODO - fix up the conversational flag and operation sequences in case the contract has come from WSDL + // as we don't yet support requires="conversational" or sca:endConversation annotations + // in WSDL interface descriptions (see section 1.5.4 of the Assembly Specification V1.0) + if (contract.getInterfaceContract().getInterface() != null ) { + icontract.getInterface().setConversational(contract.getInterfaceContract().getInterface().isConversational()); + + for (Operation operation : icontract.getInterface().getOperations()){ + Operation serviceOperation = null; + + for (Operation tmpOp : contract.getInterfaceContract().getInterface().getOperations()){ + if (operation.getName().equals(tmpOp.getName())) { + serviceOperation = tmpOp; + break; + } + } + + if (serviceOperation != null ){ + operation.setConversationSequence(serviceOperation.getConversationSequence()); + } + } + } + + /* + // Look at all the Web Service bindings of the SCA service to see if any + // of them have an existing generated WSDL definitions document. If found, + // use it for this binding as well. If not found, generate a new document. + Definition definition = null; + for (Binding binding : contract.getBindings()) { + if (binding instanceof WebServiceBinding) { + definition = ((WebServiceBinding)binding).getWSDLDocument(); + if (definition != null) { + wsBinding.setWSDLDocument(definition); + break; + } + } + } + */ + // The above code is currently not used. Instead, we only look + // for a WSDL definitions document in this binding and don't + // attempt to share the same document across multiple bindings. + + // generate a WSDL definitions document if needed + Definition definition = wsBinding.getWSDLDocument(); + if (definition == null) { + definition = WSDLServiceGenerator.configureWSDLDefinition(wsBinding, component, contract, monitor); + wsBinding.setWSDLDocument(definition); + } + } + + protected static boolean requiresSOAP12(WebServiceBinding wsBinding) { + if (wsBinding instanceof IntentAttachPoint) { + List<Intent> intents = ((IntentAttachPoint)wsBinding).getRequiredIntents(); + for (Intent intent : intents) { + if (SOAP12_INTENT.equals(intent.getName())) { + return true; + } + } + } + return false; + } + + /** + * Create a WSDLInterfaceContract from a JavaInterfaceContract + */ + protected static WSDLInterfaceContract createWSDLInterfaceContract(JavaInterfaceContract contract, + boolean requiresSOAP12, + ModelResolver resolver, + DataBindingExtensionPoint dataBindings, + WSDLFactory wsdlFactory, + XSDFactory xsdFactory, + Monitor monitor) { + + WSDLInterfaceContract wsdlContract = wsdlFactory.createWSDLInterfaceContract(); + WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface(); + wsdlContract.setInterface(wsdlInterface); + + WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); + JavaInterface iface = (JavaInterface)contract.getInterface(); + + Definition def = null; + try { + Interface2WSDLGenerator wsdlGenerator = + new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, monitor); + def = wsdlGenerator.generate(iface, wsdlDefinition); + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + + // for debugging + if (printWSDL) { + try { + System.out.println("Generated WSDL for Java interface " + iface.getName() + " class " + iface.getJavaClass().getName()); + WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter(); + writer.writeWSDL(def, System.out); + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + wsdlDefinition.setDefinition(def); + wsdlInterface.setWsdlDefinition(wsdlDefinition); + wsdlInterface.setRemotable(true); + wsdlInterface.setConversational(contract.getInterface().isConversational()); + wsdlInterface.setUnresolved(false); + wsdlInterface.setRemotable(true); + PortType portType = (PortType)def.getAllPortTypes().values().iterator().next(); + wsdlInterface.setPortType(portType); + + try { + for (Operation op : iface.getOperations()) { + javax.wsdl.Operation wsdlOp = portType.getOperation(op.getName(), null, null); + wsdlInterface.getOperations().add(WSDLInterfaceIntrospectorImpl.getOperation( + wsdlOp, wsdlDefinition, resolver, xsdFactory)); + } + } catch (InvalidWSDLException e) { + throw new WSDLGenerationException(e); + } + + return wsdlContract; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java new file mode 100644 index 0000000000..933534cc79 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -0,0 +1,842 @@ +/* + * 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.binding.ws.wsdlgen; + +import java.lang.reflect.Method; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Message; +import javax.wsdl.OperationType; +import javax.wsdl.Output; +import javax.wsdl.Part; +import javax.wsdl.PortType; +import javax.wsdl.Types; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.schema.Schema; +import javax.wsdl.factory.WSDLFactory; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.databinding.DataBinding; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.databinding.XMLTypeHelper; +import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.interfacedef.util.ElementInfo; +import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; +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.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.xsd.XSDFactory; +import org.apache.tuscany.sca.xsd.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.ws.commons.schema.XmlSchemaException; +import org.apache.ws.commons.schema.utils.NamespaceMap; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * @version $Rev: 670103 $ $Date: 2008-06-21 01:35:00 +0100 (Sat, 21 Jun 2008) $ + */ +public class Interface2WSDLGenerator { + private static final Logger logger = Logger.getLogger(Interface2WSDLGenerator.class.getName()); + private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"; + private static final String SCHEMA_NAME = "schema"; + private static final QName SCHEMA_QNAME = new QName(SCHEMA_NS, SCHEMA_NAME); + private static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/"; + + private static final String ANYTYPE_NAME = "anyType"; + private static final QName ANYTYPE_QNAME = new QName(SCHEMA_NS, ANYTYPE_NAME); + + + private WSDLFactory factory; + private DataBindingExtensionPoint dataBindings; + private WSDLDefinitionGenerator definitionGenerator; + private boolean requiresSOAP12; + private ModelResolver resolver; + private XSDFactory xsdFactory; + private Monitor monitor; + + public Interface2WSDLGenerator(boolean requiresSOAP12, + ModelResolver resolver, + DataBindingExtensionPoint dataBindings, + XSDFactory xsdFactory, + Monitor monitor) throws WSDLException { + super(); + this.requiresSOAP12 = requiresSOAP12; + this.resolver = resolver; + definitionGenerator = new WSDLDefinitionGenerator(requiresSOAP12); + this.dataBindings = dataBindings; + this.xsdFactory = xsdFactory; + this.monitor = monitor; + this.factory = WSDLFactory.newInstance(); + } + + /** + * Log a warning message. + * @param problem + */ + private static void logWarning(Problem problem) { + Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getBundleName()); + if (problemLogger != null){ + problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams()); + } else { + logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getBundleName()); + } + } + + /** + * Report a warning. + * @param message + * @param binding + * @param parameters + */ + private void warning(String message, Interface interfaze, String... messageParameters) { + Problem problem = new ProblemImpl(this.getClass().getName(), "wsdlgen-validation-messages", Severity.WARNING, interfaze, message, (Object[])messageParameters); + if (monitor != null) { + monitor.problem(problem); + } else { + logWarning(problem); + } + } + + /** + * Report a fatal error. + * @param message + * @param binding + * @param parameters + */ + private void fatal(String message, Interface interfaze, String... messageParameters) { + Problem problem = new ProblemImpl(this.getClass().getName(), "wsdlgen-validation-messages", Severity.ERROR, interfaze, message, (Object[])messageParameters); + throw new WSDLGenerationException(problem.toString(), null, problem); + } + + private XMLTypeHelper getTypeHelper(DataType type, Map<String, XMLTypeHelper> helpers) { + if (type == null) { + return null; + } + String db = type.getDataBinding(); + if (db == null) { + return null; + } + if ("java:array".equals(db)) { + DataType dt = (DataType)type.getLogical(); + db = dt.getDataBinding(); + } + return helpers.get(db); + } + + private boolean inputTypesCompatible(DataType wrapperType, DataType<List<DataType>> inputType, Map<String, XMLTypeHelper> helpers) { + XMLTypeHelper wrapperHelper = getTypeHelper(wrapperType, helpers); + for (DataType dt : inputType.getLogical()) { + if (getTypeHelper(dt, helpers) != wrapperHelper) { + return false; + } + } + return true; + } + + private boolean outputTypeCompatible(DataType wrapperType, DataType outputType, Map<String, XMLTypeHelper> helpers) { + if (getTypeHelper(outputType, helpers) != getTypeHelper(wrapperType, helpers)) { + return false; + } else { + return true; + } + } + + private void addDataType(Map<XMLTypeHelper, List<DataType>> map, DataType type, Map<String, XMLTypeHelper> helpers) { + if (type == null) { + return; + } + String db = type.getDataBinding(); + if (db == null) { + return; + } + if ("java:array".equals(db)) { + DataType dt = (DataType)type.getLogical(); + db = dt.getDataBinding(); + } + XMLTypeHelper helper = helpers.get(db); + List<DataType> types = map.get(helper); + if (types == null) { + types = new ArrayList<DataType>(); + map.put(helper, types); + } + types.add(type); + } + + private Map<XMLTypeHelper, List<DataType>> getDataTypes(Interface intf, boolean useWrapper, Map<String, XMLTypeHelper> helpers) { + Map<XMLTypeHelper, List<DataType>> dataTypes = new HashMap<XMLTypeHelper, List<DataType>>(); + for (Operation op : intf.getOperations()) { + WrapperInfo wrapper = op.getWrapper(); + DataType dt1 = null; + boolean useInputWrapper = useWrapper & wrapper != null; + if (useInputWrapper) { + dt1 = wrapper.getInputWrapperType(); + useInputWrapper &= inputTypesCompatible(dt1, op.getInputType(), helpers); + } + if (useInputWrapper) { + addDataType(dataTypes, dt1, helpers); + } else { + for (DataType dt : op.getInputType().getLogical()) { + addDataType(dataTypes, dt, helpers); + } + } + + DataType dt2 = null; + boolean useOutputWrapper = useWrapper & wrapper != null; + if (useOutputWrapper) { + dt2 = wrapper.getOutputWrapperType(); + useOutputWrapper &= outputTypeCompatible(dt2, op.getOutputType(), helpers); + } + if (useOutputWrapper) { + addDataType(dataTypes, dt2, helpers); + } else { + dt2 = op.getOutputType(); + addDataType(dataTypes, dt2, helpers); + } + + for (DataType<DataType> dt3 : op.getFaultTypes()) { + DataType dt4 = dt3.getLogical(); + addDataType(dataTypes, dt4, helpers); + } + } + return dataTypes; + } + + + public Definition generate(Interface interfaze, WSDLDefinition wsdlDefinition) throws WSDLException { + if (interfaze == null) { + return null; + } + if (interfaze instanceof WSDLInterface) { + return ((WSDLInterface)interfaze).getWsdlDefinition().getDefinition(); + } + JavaInterface iface = (JavaInterface)interfaze; + if (!interfaze.isRemotable()) { + fatal("InterfaceNotRemotable", interfaze, iface.getName()); + } + QName name = getQName(iface); + Definition definition = factory.newDefinition(); + if (requiresSOAP12) { + definition.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/"); + } else { + definition.addNamespace("SOAP", "http://schemas.xmlsoap.org/wsdl/soap/"); + } + definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); + definition.addNamespace("xs", SCHEMA_NS); + + String namespaceURI = name.getNamespaceURI(); + definition.setTargetNamespace(namespaceURI); + definition.setQName(new QName(namespaceURI, name.getLocalPart() + "Service", name.getPrefix())); + definition.addNamespace(name.getPrefix(), namespaceURI); + + PortType portType = definition.createPortType(); + portType.setQName(name); + Binding binding = definitionGenerator.createBinding(definition, portType); + Map<String, XMLTypeHelper> helpers = new HashMap<String, XMLTypeHelper>(); + Map<QName, List<ElementInfo>> wrappers = new HashMap<QName, List<ElementInfo>>(); + for (Operation op : interfaze.getOperations()) { + javax.wsdl.Operation operation = generateOperation(definition, op, helpers, wrappers); + portType.addOperation(operation); + String action = ((JavaOperation)op).getAction(); + if ((action == null || "".equals(action)) && !op.isWrapperStyle() && op.getWrapper() == null) { + // Bare style + action = "urn:" + op.getName(); + } + BindingOperation bindingOp = definitionGenerator.createBindingOperation(definition, operation, action); + binding.addBindingOperation(bindingOp); + } + portType.setUndefined(false); + definition.addPortType(portType); + binding.setUndefined(false); + definition.addBinding(binding); + wsdlDefinition.setBinding(binding); + + // call each helper in turn to populate the wsdl.types element + XmlSchemaCollection schemaCollection = new XmlSchemaCollection(); + + for (Map.Entry<XMLTypeHelper, List<DataType>> en: getDataTypes(interfaze, false, helpers).entrySet()) { + XMLTypeHelper helper = en.getKey(); + if (helper == null) { + continue; + } + List<XSDefinition> xsDefinitions = helper.getSchemaDefinitions(xsdFactory, resolver, en.getValue()); + for (XSDefinition xsDef: xsDefinitions) { + addSchemaExtension(xsDef, schemaCollection, wsdlDefinition, definition); + } + } + + // remove global wrapper elements with schema definitions from generation list + for (QName wrapperName: new HashSet<QName>(wrappers.keySet())) { + if (wsdlDefinition.getXmlSchemaElement(wrapperName) != null) { + wrappers.remove(wrapperName); + } + } + + // generate schema elements for wrappers that aren't defined in the schemas + if (wrappers.size() > 0) { + int i = 0; + int index = 0; + Map<String, XSDefinition> wrapperXSDs = new HashMap<String, XSDefinition>(); + Map<Element, Map<String, String>> prefixMaps = new HashMap<Element, Map<String, String>>(); + for (Map.Entry<QName, List<ElementInfo>> entry: wrappers.entrySet()) { + String targetNS = entry.getKey().getNamespaceURI(); + Document schemaDoc = null; + Element schema = null; + XSDefinition xsDef = wrapperXSDs.get(targetNS); + if (xsDef != null) { + schemaDoc = xsDef.getDocument(); + schema = schemaDoc.getDocumentElement(); + } else { + schemaDoc = createDocument(); + schema = schemaDoc.createElementNS(SCHEMA_NS, "xs:schema"); + // The elementFormDefault should be set to unqualified, see TUSCANY-2388 + schema.setAttribute("elementFormDefault", "unqualified"); + schema.setAttribute("attributeFormDefault", "qualified"); + schema.setAttribute("targetNamespace", targetNS); + schema.setAttributeNS(XMLNS_NS, "xmlns:xs", SCHEMA_NS); + schemaDoc.appendChild(schema); + Schema schemaExt = createSchemaExt(definition); + schemaExt.setElement(schema); + prefixMaps.put(schema, new HashMap<String, String>()); + xsDef = xsdFactory.createXSDefinition(); + xsDef.setUnresolved(true); + xsDef.setNamespace(targetNS); + xsDef.setDocument(schemaDoc); + // TUSCANY-2465: Set the system id to avoid schema conflict + xsDef.setLocation(URI.create("xsd_" + index + ".xsd")); + index++; + wrapperXSDs.put(targetNS, xsDef); + } + Element wrapper = schemaDoc.createElementNS(SCHEMA_NS, "xs:element"); + schema.appendChild(wrapper); + wrapper.setAttribute("name", entry.getKey().getLocalPart()); + if (entry.getValue().size() == 1 && entry.getValue().get(0).getQName() == null) { + // special case for global fault element + QName typeName = entry.getValue().get(0).getType().getQName(); + String nsURI = typeName.getNamespaceURI(); + if ("".equals(nsURI)) { + wrapper.setAttribute("type", typeName.getLocalPart()); + addSchemaImport(schema, "", schemaDoc); + } else if (targetNS.equals(nsURI)) { + wrapper.setAttribute("type", typeName.getLocalPart()); + } else if (SCHEMA_NS.equals(nsURI)) { + wrapper.setAttribute("type", "xs:" + typeName.getLocalPart()); + } else { + Map<String, String> prefixMap = prefixMaps.get(schema); + String prefix = prefixMap.get(nsURI); + if (prefix == null) { + prefix = "ns" + i++; + prefixMap.put(nsURI, prefix); + schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI); + addSchemaImport(schema, nsURI, schemaDoc); + } + wrapper.setAttribute("type", prefix + ":" + typeName.getLocalPart()); + } + } else { + // normal wrapper containing type definition inline + Element complexType = schemaDoc.createElementNS(SCHEMA_NS, "xs:complexType"); + wrapper.appendChild(complexType); + if (entry.getValue().size() > 0) { + Element sequence = schemaDoc.createElementNS(SCHEMA_NS, "xs:sequence"); + complexType.appendChild(sequence); + for (ElementInfo element: entry.getValue()) { + Element xsElement = schemaDoc.createElementNS(SCHEMA_NS, "xs:element"); + if (element.isMany()) { + xsElement.setAttribute("maxOccurs", "unbounded"); + } + xsElement.setAttribute("minOccurs", "0"); + xsElement.setAttribute("name", element.getQName().getLocalPart()); + if (element.isNillable()) { + xsElement.setAttribute("nillable", "true"); + } + QName typeName = element.getType().getQName(); + String nsURI = typeName.getNamespaceURI(); + if ("".equals(nsURI)) { + xsElement.setAttribute("type", typeName.getLocalPart()); + addSchemaImport(schema, "", schemaDoc); + } else if (SCHEMA_NS.equals(nsURI)) { + xsElement.setAttribute("type", "xs:" + typeName.getLocalPart()); + } else { + Map<String, String> prefixMap = prefixMaps.get(schema); + String prefix = prefixMap.get(nsURI); + if (prefix == null) { + if (targetNS.equals(nsURI)) { + prefix = "tns"; + } else { + prefix = "ns" + i++; + addSchemaImport(schema, nsURI, schemaDoc); + } + prefixMap.put(nsURI, prefix); + schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI); + } + xsElement.setAttribute("type", prefix + ":" + typeName.getLocalPart()); + } + sequence.appendChild(xsElement); + } + } + } + } + + // resolve XSDefinitions containing generated wrappers + for (XSDefinition xsDef: wrapperXSDs.values()) { + loadXSD(schemaCollection, xsDef); + wsdlDefinition.getXmlSchemas().add(xsDef); + } + } + + return definition; + } + + private static void addSchemaImport(Element schema, String nsURI, Document schemaDoc) { + Element imp = schemaDoc.createElementNS(SCHEMA_NS, "xs:import"); + if (!"".equals(nsURI)) { + imp.setAttribute("namespace", nsURI); + } + NodeList childNodes = schema.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node childNode = childNodes.item(i); + if (childNode instanceof Element) { + schema.insertBefore(imp, childNode); + imp = null; + break; + } + } + if (imp != null) { + schema.appendChild(imp); + } + } + + private void addSchemaExtension(XSDefinition xsDef, + XmlSchemaCollection schemaCollection, + WSDLDefinition wsdlDefinition, + Definition definition) throws WSDLException { + if (xsDef.getAggregatedDefinitions() != null) { + for (XSDefinition xsd: xsDef.getAggregatedDefinitions()) { + addSchemaExtension(xsd, schemaCollection, wsdlDefinition, definition); + } + } else { + String nsURI = xsDef.getNamespace(); + Document document = xsDef.getDocument(); + if (document == null) { + try { + NamespaceMap prefixMap = new NamespaceMap(); + prefixMap.add("xs", SCHEMA_NS); + prefixMap.add("tns", nsURI); + XmlSchema schemaDef = xsDef.getSchema(); + schemaDef.setNamespaceContext(prefixMap); + Document[] docs = schemaDef.getAllSchemas(); + document = docs[docs.length-1]; + document.setDocumentURI(xsDef.getLocation().toString()); + xsDef.setDocument(document); + } catch (XmlSchemaException e) { + throw new RuntimeException(e); + } + } + loadXSD(schemaCollection, xsDef); + wsdlDefinition.getXmlSchemas().add(xsDef); + Element schema = document.getDocumentElement(); + Schema schemaExt = createSchemaExt(definition); + schemaExt.setDocumentBaseURI(document.getDocumentURI()); + schemaExt.setElement(schema); + } + } + + private static void loadXSD(XmlSchemaCollection schemaCollection, XSDefinition definition) { + if (definition.getSchema() != null) { + return; + } + if (definition.getDocument() != null) { + String uri = null; + if (definition.getLocation() != null) { + uri = definition.getLocation().toString(); + } + XmlSchema schema = schemaCollection.read(definition.getDocument(), uri, null); + if (definition.getSchemaCollection() == null) { + definition.setSchemaCollection(schemaCollection); + } + if (definition.getSchema() == null) { + definition.setSchema(schema); + } + } + } + + public Schema createSchemaExt(Definition definition) throws WSDLException { + Types types = definition.getTypes(); + if (types == null) { + types = definition.createTypes(); + definition.setTypes(types); + } + + Schema schemaExt = createSchema(definition); + types.addExtensibilityElement(schemaExt); + + return schemaExt; + } + + public Schema createSchema(Definition definition) throws WSDLException { + return (Schema)definition.getExtensionRegistry().createExtension(Types.class, SCHEMA_QNAME); + } + + private DocumentBuilderFactory documentBuilderFactory; + + public Document createDocument() { + Document document; + try { + if (documentBuilderFactory == null) { + documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + } + document = documentBuilderFactory.newDocumentBuilder().newDocument(); + } catch (ParserConfigurationException ex) { + throw new WSDLGenerationException(ex); + } + // document.setDocumentURI("http://"); + return document; + } + + protected QName getQName(Interface interfaze) { + JavaInterface iface = (JavaInterface)interfaze; + QName qname = iface.getQName(); + if (qname != null) { + return qname; + } else { + Class<?> javaClass = iface.getJavaClass(); + return new QName(JavaXMLMapper.getNamespace(javaClass), javaClass.getSimpleName(), "tns"); + } + } + + public javax.wsdl.Operation generateOperation(Definition definition, + Operation op, + Map<String, XMLTypeHelper> helpers, + Map<QName, List<ElementInfo>> wrappers) + throws WSDLException { + javax.wsdl.Operation operation = definition.createOperation(); + operation.setName(op.getName()); + operation.setUndefined(false); + + Input input = definition.createInput(); + Message inputMsg = definition.createMessage(); + String namespaceURI = definition.getQName().getNamespaceURI(); + QName inputMsgName = new QName(namespaceURI, op.getName()); + inputMsg.setQName(inputMsgName); + inputMsg.setUndefined(false); + definition.addMessage(inputMsg); + + List<ElementInfo> elements = null; + // FIXME: By default, java interface is mapped to doc-lit-wrapper style WSDL + if (op.getWrapper() != null) { + // Generate doc-lit-wrapper style + inputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, true)); + } else { + // Bare style + int i = 0; + for (DataType d : op.getInputType().getLogical()) { + inputMsg.addPart(generatePart(definition, d, "arg" + i)); + elements = new ArrayList<ElementInfo>(); + ElementInfo element = getElementInfo(d.getPhysical(), d, null, helpers); + elements.add(element); + QName elementName = ((XMLType)d.getLogical()).getElementName(); + wrappers.put(elementName, elements); + i++; + } + } + input.setMessage(inputMsg); + operation.setInput(input); + + if (!op.isNonBlocking()) { + Output output = definition.createOutput(); + Message outputMsg = definition.createMessage(); + QName outputMsgName = new QName(namespaceURI, op.getName() + "Response"); + outputMsg.setQName(outputMsgName); + outputMsg.setUndefined(false); + definition.addMessage(outputMsg); + + if (op.getWrapper() != null) { + outputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, false)); + } else { + DataType outputType = op.getOutputType(); + outputMsg.addPart(generatePart(definition, outputType, "return")); + if (outputType != null) { + elements = new ArrayList<ElementInfo>(); + ElementInfo element = getElementInfo(outputType.getPhysical(), outputType, null, helpers); + elements.add(element); + QName elementName = ((XMLType)outputType.getLogical()).getElementName(); + wrappers.put(elementName, elements); + } + } + output.setMessage(outputMsg); + + operation.setOutput(output); + operation.setStyle(OperationType.REQUEST_RESPONSE); + } else { + operation.setStyle(OperationType.ONE_WAY); + } + + for (DataType<DataType> faultType: op.getFaultTypes()) { + Fault fault = definition.createFault(); + QName faultName = ((XMLType)faultType.getLogical().getLogical()).getElementName(); + fault.setName(faultName.getLocalPart()); + Message faultMsg = definition.getMessage(faultName); + if (faultMsg == null) { + faultMsg = definition.createMessage(); + faultMsg.setQName(faultName); + faultMsg.setUndefined(false); + definition.addMessage(faultMsg); + faultMsg.addPart(generatePart(definition, faultType.getLogical(), faultName.getLocalPart())); + } + fault.setMessage(faultMsg); + operation.addFault(fault); + if (faultType.getLogical().getPhysical() != faultType.getPhysical()) { + // create special wrapper for type indirection to real fault bean + DataType logical = faultType.getLogical(); + elements = new ArrayList<ElementInfo>(); + elements.add(getElementInfo(logical.getPhysical(), logical, null, helpers)); + } else { + // convert synthesized fault bean to a wrapper type + for (DataType<XMLType> propDT: op.getFaultBeans().get(faultName)) { + XMLType logical = propDT.getLogical(); + elements = new ArrayList<ElementInfo>(); + elements.add(getElementInfo(propDT.getPhysical(), propDT, logical.getElementName(), helpers)); + } + } + wrappers.put(faultName, elements); + } + + operation.setUndefined(false); + return operation; + } + + public Part generatePart(Definition definition, DataType arg, String partName) { + Part part = definition.createPart(); + part.setName(partName); + if (arg != null && arg.getLogical() instanceof XMLType) { + XMLType xmlType = (XMLType)arg.getLogical(); + QName elementName = xmlType.getElementName(); + part.setElementName(elementName); + addNamespace(definition, elementName); + if (xmlType.getElementName() == null) { + QName typeName = xmlType.getTypeName(); + part.setTypeName(typeName); + addNamespace(definition, typeName); + } + } + return part; + } + + public Part generateWrapperPart(Definition definition, + Operation operation, + Map<String, XMLTypeHelper> helpers, + Map<QName, List<ElementInfo>> wrappers, + boolean input) throws WSDLException { + Part part = definition.createPart(); + String partName = input ? operation.getName() : (operation.getName() + "Response"); + part.setName(partName); + WrapperInfo opWrapper = operation.getWrapper(); + if (opWrapper != null) { + ElementInfo elementInfo = + input ? opWrapper.getInputWrapperElement() : opWrapper.getOutputWrapperElement(); + List<ElementInfo> elements = + input ? opWrapper.getInputChildElements() : opWrapper.getOutputChildElements(); + QName wrapperName = elementInfo.getQName(); + part.setElementName(wrapperName); + addNamespace(definition, wrapperName); + wrappers.put(wrapperName, elements); + + // FIXME: [rfeng] Ideally, we should try to register the wrappers only. But we are + // expriencing the problem that we cannot handle XSD imports + /* + Class<?> wrapperClass = input ? opWrapper.getInputWrapperClass() : opWrapper.getOutputWrapperClass(); + DataType wrapperDT = input ? opWrapper.getInputWrapperType() : opWrapper.getOutputWrapperType(); + if (wrapperClass != null) { + getElementInfo(wrapperClass, wrapperDT, wrapperName, helpers); + return part; + } + */ + + Method method = ((JavaOperation)operation).getJavaMethod(); + if (input) { + Class<?>[] paramTypes = method.getParameterTypes(); + for (int i = 0; i < paramTypes.length; i++) { + DataType dataType = operation.getInputType().getLogical().get(i); + elements.set(i, getElementInfo(paramTypes[i], dataType, elements.get(i).getQName(), helpers)); + } + } else { + Class<?> returnType = method.getReturnType(); + if (returnType != Void.TYPE) { + DataType dataType = operation.getOutputType(); + elements.set(0, getElementInfo(returnType, dataType, elements.get(0).getQName(), helpers)); + } + } + } + return part; + } + + private ElementInfo getElementInfo(Class javaType, + DataType dataType, + QName name, + Map<String, XMLTypeHelper> helpers) { + String db = dataType.getDataBinding(); + while ("java:array".equals(db)) { + dataType = (DataType)dataType.getLogical(); + db = dataType.getDataBinding(); + } + XMLTypeHelper helper = helpers.get(db); + if (helper == null) { + DataBinding dataBinding = dataBindings.getDataBinding(db); + if (dataBinding == null) { + QName element = name; + if (element == null || dataType.getLogical() instanceof XMLType) { + XMLType xmlType = (XMLType)dataType.getLogical(); + if (xmlType.getElementName() != null) { + element = xmlType.getElementName(); + } + } + return new ElementInfo(element, new TypeInfo(ANYTYPE_QNAME, false, null)); + // throw new ServiceRuntimeException("No data binding for " + db); + } + + helper = dataBinding.getXMLTypeHelper(); + if (helper == null) { + // Default to JAXB + helper = helpers.get(JAXBDataBinding.NAME); + if (helper == null) { + helper = dataBindings.getDataBinding(JAXBDataBinding.NAME).getXMLTypeHelper(); + helpers.put(JAXBDataBinding.NAME, helper); + } + } + helpers.put(db, helper); + } + TypeInfo typeInfo = helper.getTypeInfo(javaType.isArray() ? javaType.getComponentType() : javaType, + dataType.getLogical()); + ElementInfo element = new ElementInfo(name, typeInfo); + element.setMany(byte[].class != javaType && javaType.isArray()); + element.setNillable(!javaType.isPrimitive()); + return element; + } + + private static void addNamespace(Definition definition, QName name) { + String namespace = name.getNamespaceURI(); + if (definition.getPrefix(namespace) == null) { + definition.addNamespace("ns" + definition.getNamespaces().size(), namespace); + } + } + + /* + // currently not using the next three methods + public XmlSchemaType getXmlSchemaType(DataType type) { + return null; + } + + // FIXME: WE need to add databinding-specific Java2XSD generation + public Element generateXSD(DataType dataType) { + DataBinding dataBinding = dataBindings.getDataBinding(dataType.getDataBinding()); + if (dataBinding != null) { + // return dataBinding.generateSchema(dataType); + } + return null; + } + + public void generateWrapperElements(Operation op) { + XmlSchemaCollection collection = new XmlSchemaCollection(); + String ns = getQName(op.getInterface()).getNamespaceURI(); + XmlSchema schema = new XmlSchema(ns, collection); + schema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED)); + schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED)); + + XmlSchemaElement inputElement = new XmlSchemaElement(); + inputElement.setQName(new QName(ns, op.getName())); + XmlSchemaComplexType inputType = new XmlSchemaComplexType(schema); + inputType.setName(""); + XmlSchemaSequence inputSeq = new XmlSchemaSequence(); + inputType.setParticle(inputSeq); + List<DataType> argTypes = op.getInputType().getLogical(); + for (DataType argType : argTypes) { + XmlSchemaElement child = new XmlSchemaElement(); + Object logical = argType.getLogical(); + if (logical instanceof XMLType) { + child.setName(((XMLType)logical).getElementName().getLocalPart()); + XmlSchemaType type = getXmlSchemaType(argType); + child.setType(type); + } + inputSeq.getItems().add(child); + } + inputElement.setType(inputType); + + XmlSchemaElement outputElement = new XmlSchemaElement(); + outputElement.setQName(new QName(ns, op.getName() + "Response")); + XmlSchemaComplexType outputType = new XmlSchemaComplexType(schema); + outputType.setName(""); + XmlSchemaSequence outputSeq = new XmlSchemaSequence(); + outputType.setParticle(outputSeq); + DataType returnType = op.getOutputType(); + XmlSchemaElement child = new XmlSchemaElement(); + Object logical = returnType.getLogical(); + if (logical instanceof XMLType) { + child.setName(((XMLType)logical).getElementName().getLocalPart()); + XmlSchemaType type = getXmlSchemaType(returnType); + child.setType(type); + } + outputSeq.getItems().add(child); + outputElement.setType(outputType); + + schema.getElements().add(inputElement.getQName(), inputElement); + schema.getElements().add(outputElement.getQName(), outputElement); + + } + */ + + public WSDLFactory getFactory() { + return factory; + } + + public void setFactory(WSDLFactory factory) { + this.factory = factory; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java new file mode 100644 index 0000000000..d0b79f9b0e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java @@ -0,0 +1,305 @@ +/* + * 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.binding.ws.wsdlgen; + +import java.util.Iterator; + +import javax.wsdl.Binding; +import javax.wsdl.BindingFault; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Fault; +import javax.wsdl.Input; +import javax.wsdl.Operation; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.Types; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.wsdl.extensions.soap.SOAPFault; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.extensions.soap12.SOAP12Binding; +import javax.wsdl.extensions.soap12.SOAP12Body; +import javax.wsdl.extensions.soap12.SOAP12Fault; +import javax.wsdl.extensions.soap12.SOAP12Operation; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import org.w3c.dom.Element; + +/** + * + * @version $Rev: 668025 $ $Date: 2008-06-16 01:06:34 +0100 (Mon, 16 Jun 2008) $ + */ +public class WSDLDefinitionGenerator { + private static final String SOAP_NS = "http://schemas.xmlsoap.org/wsdl/soap/"; + public static final QName SOAP_ADDRESS = new QName(SOAP_NS, "address"); + private static final QName SOAP_BINDING = new QName(SOAP_NS, "binding"); + private static final QName SOAP_BODY = new QName(SOAP_NS, "body"); + private static final QName SOAP_FAULT = new QName(SOAP_NS, "fault"); + private static final QName SOAP_OPERATION = new QName(SOAP_NS, "operation"); + private static final String SOAP12_NS = "http://schemas.xmlsoap.org/wsdl/soap12/"; + public static final QName SOAP12_ADDRESS = new QName(SOAP12_NS, "address"); + private static final QName SOAP12_BINDING = new QName(SOAP12_NS, "binding"); + private static final QName SOAP12_BODY = new QName(SOAP12_NS, "body"); + private static final QName SOAP12_FAULT = new QName(SOAP12_NS, "fault"); + private static final QName SOAP12_OPERATION = new QName(SOAP12_NS, "operation"); + + private static final String BINDING_SUFFIX = "Binding"; + private static final String SERVICE_SUFFIX = "Service"; + private static final String PORT_SUFFIX = "Port"; + + private boolean requiresSOAP12; + private QName soapAddress; + private QName soapBinding; + private QName soapBody; + private QName soapFault; + private QName soapOperation; + + public WSDLDefinitionGenerator(boolean requiresSOAP12) { + super(); + this.requiresSOAP12 = requiresSOAP12; + soapAddress = requiresSOAP12 ? SOAP12_ADDRESS : SOAP_ADDRESS; + soapBinding = requiresSOAP12 ? SOAP12_BINDING : SOAP_BINDING; + soapBody = requiresSOAP12 ? SOAP12_BODY : SOAP_BODY; + soapFault = requiresSOAP12 ? SOAP12_FAULT : SOAP_FAULT; + soapOperation = requiresSOAP12 ? SOAP12_OPERATION : SOAP_OPERATION; + } + + public Definition cloneDefinition(WSDLFactory factory, Definition definition) throws WSDLException { + Element root = definition.getDocumentationElement(); + root = (Element)root.cloneNode(true); + WSDLReader reader = factory.newWSDLReader(); + return reader.readWSDL(definition.getDocumentBaseURI(), root); + } + + public Types createTypes(Definition definition) { + Types types = definition.createTypes(); + definition.setTypes(types); + return types; + } + + public Binding createBinding(Definition definition, PortType portType) { + try { + Binding binding = definition.createBinding(); + binding.setPortType(portType); + configureBinding(definition, binding, portType); + ExtensibilityElement bindingExtension = + definition.getExtensionRegistry().createExtension(Binding.class, soapBinding); + if (requiresSOAP12) { + ((SOAP12Binding)bindingExtension).setStyle("document"); + ((SOAP12Binding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http"); + } else { + ((SOAPBinding)bindingExtension).setStyle("document"); + ((SOAPBinding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http"); + } + binding.addExtensibilityElement(bindingExtension); + return binding; + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + protected void configureBinding(Definition definition, Binding binding, PortType portType) throws WSDLException { + QName portTypeName = portType.getQName(); + if (portTypeName != null) { + // Choose <porttype>Binding if available. If this name is in use, insert + // separating underscores until there is no clash. + for (String suffix = BINDING_SUFFIX; ; suffix = "_" + suffix) { + QName name = new QName(definition.getTargetNamespace(), portTypeName.getLocalPart() + suffix); + if (definition.getBinding(name) == null) { + binding.setQName(name); + break; + } + } + } + } + + @SuppressWarnings("unchecked") + public void createBindingOperations(Definition definition, Binding binding, PortType portType) { + try { + for (Iterator oi = portType.getOperations().iterator(); oi.hasNext();) { + Operation operation = (Operation)oi.next(); + BindingOperation bindingOperation = + createBindingOperation(definition, operation, "urn:" + operation.getName()); + binding.addBindingOperation(bindingOperation); + } + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + @SuppressWarnings("unchecked") + public BindingOperation createBindingOperation(Definition definition, Operation operation, String action) + throws WSDLException { + BindingOperation bindingOperation = definition.createBindingOperation(); + bindingOperation.setOperation(operation); + configureBindingOperation(bindingOperation, operation); + ExtensibilityElement operationExtension = + definition.getExtensionRegistry().createExtension(BindingOperation.class, soapOperation); + if (requiresSOAP12) { + ((SOAP12Operation)operationExtension).setSoapActionURI(action); + } else { + ((SOAPOperation)operationExtension).setSoapActionURI(action); + } + bindingOperation.addExtensibilityElement(operationExtension); + if (operation.getInput() != null) { + BindingInput bindingInput = definition.createBindingInput(); + configureBindingInput(bindingInput, operation.getInput()); + ExtensibilityElement inputExtension = + definition.getExtensionRegistry().createExtension(BindingInput.class, soapBody); + if (requiresSOAP12) { + ((SOAP12Body)inputExtension).setUse("literal"); + } else { + ((SOAPBody)inputExtension).setUse("literal"); + } + bindingInput.addExtensibilityElement(inputExtension); + bindingOperation.setBindingInput(bindingInput); + } + if (operation.getOutput() != null) { + BindingOutput bindingOutput = definition.createBindingOutput(); + configureBindingOutput(bindingOutput, operation.getOutput()); + ExtensibilityElement outputExtension = + definition.getExtensionRegistry().createExtension(BindingOutput.class, soapBody); + if (requiresSOAP12) { + ((SOAP12Body)outputExtension).setUse("literal"); + } else { + ((SOAPBody)outputExtension).setUse("literal"); + } + bindingOutput.addExtensibilityElement(outputExtension); + bindingOperation.setBindingOutput(bindingOutput); + } + for (Iterator fi = operation.getFaults().values().iterator(); fi.hasNext();) { + Fault fault = (Fault)fi.next(); + BindingFault bindingFault = definition.createBindingFault(); + ExtensibilityElement faultExtension = + definition.getExtensionRegistry().createExtension(BindingFault.class, soapFault); + configureBindingFault(bindingFault, faultExtension, fault); + bindingFault.addExtensibilityElement(faultExtension); + bindingOperation.addBindingFault(bindingFault); + } + return bindingOperation; + } + + protected void configureBindingOperation(BindingOperation bindingOperation, Operation operation) + throws WSDLException { + bindingOperation.setName(operation.getName()); + } + + protected void configureBindingInput(BindingInput bindingInput, Input input) throws WSDLException { + bindingInput.setName(input.getName()); + } + + protected void configureBindingOutput(BindingOutput bindingOutput, Output output) throws WSDLException { + bindingOutput.setName(output.getName()); + } + + protected void configureBindingFault(BindingFault bindingFault, + ExtensibilityElement faultExtension, + Fault fault) + throws WSDLException { + String faultName = fault.getName(); + bindingFault.setName(faultName); + if (requiresSOAP12) { + ((SOAP12Fault)faultExtension).setName(faultName); + ((SOAP12Fault)faultExtension).setUse("literal"); + } else { + ((SOAPFault)faultExtension).setName(faultName); + ((SOAPFault)faultExtension).setUse("literal"); + } + } + + public Service createService(Definition definition, PortType portType) { + try { + Service service = definition.createService(); + configureService(definition, service, portType); + // createPort(definition, binding, service); + definition.addService(service); + return service; + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + public Service createService(Definition definition, Binding binding) { + try { + Service service = definition.createService(); + configureService(definition, service, binding.getPortType()); + // createPort(definition, binding, service); + definition.addService(service); + return service; + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + protected void configureService(Definition definition, Service service, PortType portType) throws WSDLException { + QName portTypeName = portType.getQName(); + if (portTypeName != null) { + // Choose <porttype>Service if available. If this name is in use, insert + // separating underscores until there is no clash. + for (String suffix = SERVICE_SUFFIX; ; suffix = "_" + suffix) { + QName name = new QName(definition.getTargetNamespace(), portTypeName.getLocalPart() + suffix); + if (definition.getService(name) == null) { + service.setQName(name); + break; + } + } + } + } + + public Port createPort(Definition definition, Binding binding, Service service, String uri) { + try { + Port port = definition.createPort(); + port.setBinding(binding); + configurePort(port, binding); + if (uri != null) { + ExtensibilityElement portExtension = + definition.getExtensionRegistry().createExtension(Port.class, soapAddress); + if (requiresSOAP12) { + ((SOAP12Address)portExtension).setLocationURI(uri); + } else { + ((SOAPAddress)portExtension).setLocationURI(uri); + } + port.addExtensibilityElement(portExtension); + } + service.addPort(port); + return port; + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + protected void configurePort(Port port, Binding binding) throws WSDLException { + if (binding.getPortType() != null && binding.getPortType().getQName() != null) { + port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX); + } + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java new file mode 100644 index 0000000000..bf9e22f645 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java @@ -0,0 +1,54 @@ +/* + * 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.binding.ws.wsdlgen; + +import org.apache.tuscany.sca.monitor.Problem; +import org.osoa.sca.ServiceRuntimeException; + +public class WSDLGenerationException extends ServiceRuntimeException { + private static final long serialVersionUID = 1L; + private Problem problem; + + public WSDLGenerationException() { + super(); + } + + public WSDLGenerationException(String message, Throwable cause) { + super(message, cause); + } + + public WSDLGenerationException(String message) { + super(message); + } + + public WSDLGenerationException(Throwable cause) { + super(cause); + } + + public WSDLGenerationException(String message, Throwable cause, Problem problem) { + super(message, cause); + this.problem = problem; + } + + public Problem getProblem() { + return problem; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java new file mode 100644 index 0000000000..bf3615c9f8 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java @@ -0,0 +1,513 @@ +/* + * 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.binding.ws.wsdlgen; + +//FIXME: trim the import list down to what's really needed + + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.wsdl.Binding; +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.extensions.soap12.SOAP12Binding; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLWriter; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +/** + * WSDLServiceGenerator generates a binding WSDL service document. + * + * @version $Rev$ $Date$ + */ +public class WSDLServiceGenerator { + // the following switch is temporary for debugging + public static boolean printWSDL; // external code sets this to print generated WSDL + + private static final Logger logger = Logger.getLogger(WSDLServiceGenerator.class.getName()); + private static final QName TRANSPORT_JMS_QUALIFIED_INTENT = + new QName("http://www.osoa.org/xmlns/sca/1.0", "transport.jms"); + private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory"; + private static final String ADDRESS = "Address"; + + private WSDLServiceGenerator() { + // this class has static methods only and cannot be instantiated + } + + /** + * Log a warning message. + * @param problem + */ + private static void logWarning(Problem problem) { + Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getBundleName()); + if (problemLogger != null){ + problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams()); + } else { + logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getBundleName()); + } + } + + /** + * Report a warning. + * @param message + * @param binding + * @param parameters + */ + private static void warning(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) { + Problem problem = new ProblemImpl(WSDLServiceGenerator.class.getName(), "wsdlgen-validation-messages", Severity.WARNING, wsBinding, message, (Object[])messageParameters); + if (monitor != null) { + monitor.problem(problem); + } else { + logWarning(problem); + } + } + + /** + * Report an error. + * @param message + * @param binding + * @param parameters + */ + private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) { + Problem problem = new ProblemImpl(WSDLServiceGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, (Object[])messageParameters); + if (monitor != null) { + monitor.problem(problem); + } else { + throw new WSDLGenerationException(problem.toString(), null, problem); + } + } + + /** + * Generate a suitably configured WSDL definition + */ + protected static Definition configureWSDLDefinition(WebServiceBinding wsBinding, + Component component, + AbstractContract contract, + Monitor monitor) { + + //[nash] changes to the builder sequence avoid calling this for a CompositeService + assert !(contract instanceof CompositeService); + /* + // For every promoted composite service, the underlying component + // gets a copy of the service with the name prefixed by "$promoted$." + String contractName = (contract instanceof CompositeService ? "$promoted$." : "") + contract.getName(); + */ + String contractName = contract.getName(); + + List<Port> ports = new ArrayList<Port>(); + WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition(); + if (wsdlDefinition == null) { + error(monitor, "NoWsdlInterface", wsBinding, component.getName(), contract.getName()); + return null; + } + Definition def = wsdlDefinition.getDefinition(); + if (wsdlDefinition.getBinding() == null) { + // The WSDL document was provided by the user. Generate a new + // WSDL document with imports from the user-provided document. + WSDLFactory factory = null; + try { + factory = WSDLFactory.newInstance(); + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + Definition newDef = factory.newDefinition(); + + // Construct a target namespace from the base URI of the user's + // WSDL document (is this what we should be using?) and a path + // computed according to the SCA Web Service binding spec. + String nsName = component.getName() + "/" + contractName; + String namespaceURI = null; + try { + URI userTNS = new URI(def.getTargetNamespace()); + namespaceURI = userTNS.resolve("/" + nsName).toString(); + } catch (URISyntaxException e1) { + throw new WSDLGenerationException(e1); + } catch (IllegalArgumentException e2) { + throw new WSDLGenerationException(e2); + } + + // set name and targetNamespace attributes on the definition + String defsName = component.getName() + "." + contractName; + newDef.setQName(new QName(namespaceURI, defsName)); + newDef.setTargetNamespace(namespaceURI); + newDef.addNamespace("tns", namespaceURI); + + // set wsdl namespace prefix on the definition + newDef.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); + + // import the service or reference interface portType + List<WSDLDefinition> imports = new ArrayList<WSDLDefinition>(); + Interface interfaze = wsBinding.getBindingInterfaceContract().getInterface(); + if (interfaze instanceof WSDLInterface) { + PortType portType = ((WSDLInterface)interfaze).getPortType(); + boolean ok = importPortType(portType, wsdlDefinition, newDef, imports); + if (!ok) { + error(monitor, "PortTypeNotFound", wsBinding, portType.getQName().toString(), + component.getName(), contract.getName()); + } + } + + // import an existing binding if specified + Binding binding = wsBinding.getBinding(); + if (binding != null) { + boolean ok = importBinding(binding, wsdlDefinition, newDef, imports); + if (ok) { + boolean ok2 = importPortType(binding.getPortType(), wsdlDefinition, newDef, imports); + if (!ok2) { + error(monitor, "PortTypeNotFound", wsBinding, binding.getPortType().getQName().toString(), + component.getName(), contract.getName()); + } + } else { + error(monitor, "BindingNotFound", wsBinding, binding.getQName().toString(), + component.getName(), contract.getName()); + } + } + + // import bindings and portTypes needed by services and ports + QName serviceQName = wsBinding.getServiceName(); + String portName = wsBinding.getPortName(); + if (serviceQName != null) { + Service service = def.getService(serviceQName); + if (portName != null) { + Port port = service.getPort(portName); + Port newPort = copyPort(newDef, port, wsBinding); + if (newPort != null) { + importBinding(port.getBinding(), wsdlDefinition, newDef, imports); + ports.add(newPort); + } else { + error(monitor, "InvalidPort", wsBinding, serviceQName.toString(), portName, + component.getName(), contract.getName()); + } + } else { + for (Object port : service.getPorts().values()) { + Port newPort = copyPort(newDef, (Port)port, wsBinding); + if (newPort != null) { + importBinding(((Port)port).getBinding(), wsdlDefinition, newDef, imports); + ports.add(newPort); + } else { + // not an error, just ignore the port + warning(monitor, "IgnoringPort", wsBinding, serviceQName.toString(), ((Port)port).getName(), + component.getName(), contract.getName()); + } + } + if (ports.size() == 0) { + error(monitor, "NoValidPorts", wsBinding, serviceQName.toString(), + component.getName(), contract.getName()); + } + } + } + + // replace original WSDL definition by the generated definition + def = newDef; + + } else { + // The WSDL definition was generated by Interface2WSDLGenerator. + // Reuse it instead of creating a new definition here. + } + + // add a service and ports to the generated definition + WSDLDefinitionGenerator helper = + new WSDLDefinitionGenerator(BindingWSDLGenerator.requiresSOAP12(wsBinding)); + WSDLInterface wi = (WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface(); + PortType portType = wi.getPortType(); + Service service = helper.createService(def, portType); + if (wsBinding.getBinding() == null && ports.size() == 0) { + Binding binding = helper.createBinding(def, portType); + if (BindingWSDLGenerator.requiresSOAP12(wsBinding)) { + def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/"); + } else { + def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/"); + } + helper.createBindingOperations(def, binding, portType); + binding.setUndefined(false); + def.addBinding(binding); + + String endpointURI = computeActualURI(wsBinding, null); + Port port = helper.createPort(def, binding, service, endpointURI); + wsBinding.setService(service); + wsBinding.setPort(port); + } else { + if (ports.size() > 0) { + // there are one or more user-specified valid ports + for (Port port : ports) { + service.addPort(port); + } + if (ports.size() == 1) { + // only one port, so use it + wsBinding.setPort(ports.get(0)); + } else { + // multiple ports, make them all available + wsBinding.setPort(null); + } + } else { + // no valid user-specified ports, so create a suitably configured port + String endpointURI = computeActualURI(wsBinding, null); + Port port = helper.createPort(def, wsBinding.getBinding(), service, endpointURI); + if (BindingWSDLGenerator.requiresSOAP12(wsBinding)) { + def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/"); + } else { + def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/"); + } + wsBinding.setPort(port); + } + wsBinding.setService(service); + } + + // for debugging + if (printWSDL) { + try { + System.out.println("Generated WSDL for " + component.getName() + "/" + contractName); + WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter(); + writer.writeWSDL(def, System.out); + } catch (WSDLException e) { + throw new WSDLGenerationException(e); + } + } + + return def; + } + + private static boolean importPortType(PortType portType, + WSDLDefinition wsdlDef, + Definition newDef, + List<WSDLDefinition> imports) { + return addImport(portType.getQName(), PortType.class, wsdlDef, newDef, imports); + } + + private static boolean importBinding(Binding binding, + WSDLDefinition wsdlDef, + Definition newDef, + List<WSDLDefinition> imports) { + boolean ok = addImport(binding.getQName(), Binding.class, wsdlDef, newDef, imports); + if (ok) { + List bindingExtensions = binding.getExtensibilityElements(); + for (final Object extension : bindingExtensions) { + if (extension instanceof SOAPBinding) { + newDef.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/"); + } + if (extension instanceof SOAP12Binding) { + newDef.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/"); + } + } + } + return ok; + } + + private static boolean addImport(QName name, + Class type, + WSDLDefinition wsdlDef, + Definition newDef, + List<WSDLDefinition> imports) { + String namespace = name.getNamespaceURI(); + if (newDef.getImports(namespace) == null) { + WSDLDefinition impDef = findDefinition(wsdlDef, name, type); + if (impDef != null) { + Import imp = newDef.createImport(); + imp.setNamespaceURI(namespace); + imp.setLocationURI(impDef.getURI().toString()); + imp.setDefinition(impDef.getDefinition()); + newDef.addNamespace("ns" + imports.size(), namespace); + newDef.addImport(imp); + imports.add(impDef); + return true; + } else { + // import was not added because element not found + return false; + } + } + return true; + } + + private static WSDLDefinition findDefinition(WSDLDefinition wsdlDef, QName name, Class type) { + if (wsdlDef == null || name == null) { + return wsdlDef; + } + if (wsdlDef.getURI() != null) { // not a facade + Definition def = wsdlDef.getDefinition(); + Map types = type == PortType.class ? def.getPortTypes() : def.getBindings(); + if (types.get(name) != null) { + return wsdlDef; + } + } + for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) { + WSDLDefinition d = findDefinition(impDef, name, type); + if (d != null) { + return d; + } + } + return null; + } + + private static Port copyPort(Definition def, Port port, WebServiceBinding wsBinding) { + Port newPort = def.createPort(); + newPort.setName(port.getName()); + newPort.setBinding(port.getBinding()); + List portExtensions = port.getExtensibilityElements(); + for (final Object extension : portExtensions) { + ExtensibilityElement newExt = null; + if (extension instanceof SOAPAddress) { + def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/"); + try { + newExt = def.getExtensionRegistry().createExtension( + Port.class, WSDLDefinitionGenerator.SOAP_ADDRESS); + } catch (WSDLException e) { + } + String uri = computeActualURI(wsBinding, port); + ((SOAPAddress)newExt).setLocationURI(uri); + newPort.addExtensibilityElement(newExt); + } else if (extension instanceof SOAP12Address) { + def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/"); + try { + newExt = def.getExtensionRegistry().createExtension( + Port.class, WSDLDefinitionGenerator.SOAP12_ADDRESS); + } catch (WSDLException e) { + } + String uri = computeActualURI(wsBinding, port); + ((SOAP12Address)newExt).setLocationURI(uri); + newPort.addExtensibilityElement(newExt); + } else { + // we don't support ports with other extensibility elements such as HTTPAddress + return null; + } + } + return newPort; + } + + /** + * Compute the endpoint URI based on section 2.1.1 of the WS binding Specification 1. + * The URIs in the endpoint(s) of the referenced WSDL, which may be relative + * 2. The URI specified by the wsa:Address element of the + * wsa:EndpointReference, which may be relative 3. The explicitly stated URI + * in the "uri" attribute of the binding.ws element, which may be relative, + * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly Specification + * If the <binding.ws> has no wsdlElement but does have a uri attribute then + * the uri takes precedence over any implicitly used WSDL. + * + */ + private static String computeActualURI(WebServiceBinding wsBinding, Port port) { + + URI eprURI = null; + if (wsBinding.getEndPointReference() != null) { + eprURI = getEPR(wsBinding); + } + + URI wsdlURI = null; + if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) { + // <binding.ws> explicitly points at a WSDL port, may be a relative URI + wsdlURI = getEndpoint(port); + } + + // if the WSDL port/endpoint has an absolute URI use that + if (wsdlURI != null && wsdlURI.isAbsolute()) { + return wsdlURI.toString(); + } + + // if the wsa:EndpointReference has an address element with an absolute URI use that + if (eprURI != null && eprURI.isAbsolute()) { + return eprURI.toString(); + } + + // either there is no WSDL port endpoint URI or that URI is relative + String actualURI = wsBinding.getURI(); + if (eprURI != null && eprURI.toString().length() != 0) { + // there is a relative URI in the binding EPR + actualURI = actualURI + "/" + eprURI; + } + + if (wsdlURI != null && wsdlURI.toString().length() != 0) { + // there is a relative URI in the WSDL port + actualURI = actualURI + "/" + wsdlURI; + } + + if (actualURI != null) { + actualURI = URI.create(actualURI).normalize().toString(); + } + + return actualURI; + } + + private static URI getEPR(WebServiceBinding wsBinding) { + NodeList nodeList = wsBinding.getEndPointReference().getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node childNode = nodeList.item(i); + if (childNode instanceof Element && ADDRESS.equals(childNode.getLocalName())) { + NodeList addrNodes = childNode.getChildNodes(); + for (int j = 0; j < addrNodes.getLength(); j++) { + Node addrNode = addrNodes.item(j); + if (addrNode instanceof Text) { + return URI.create(((Text)addrNode).getWholeText()); + } + } + } + } + return null; + } + + /** + * Returns the endpoint of a given port. + */ + private static URI getEndpoint(Port wsdlPort) { + if (wsdlPort != null) { + List<?> wsdlPortExtensions = wsdlPort.getExtensibilityElements(); + for (Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + String uri = ((SOAPAddress)extension).getLocationURI(); + return (uri == null || "".equals(uri)) ? null : URI.create(uri); + } + if (extension instanceof SOAP12Address) { + SOAP12Address address = (SOAP12Address)extension; + String uri = address.getLocationURI(); + return (uri == null || "".equals(uri)) ? null : URI.create(uri); + } + } + } + return null; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties new file mode 100644 index 0000000000..4bfbdd2901 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties @@ -0,0 +1,31 @@ +# +# +# 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. +# +# +WsdlGenProblem = Unable to generate WSDL for {0}/{1} +WsdlGenException = Exception while generating WSDL for {0}/{1} +UnexpectedException = Exception thrown was: {0} +MissingInterfaceContract = No interface contract for {0}/{1} +InterfaceNotRemotable = Interface not remotable: {0} +IgnoringPort = Port {0}/{1} in {2}/{3} is not supported and was ignored +PortTypeNotFound = PortType {0} in {1}/{2} was not found +BindingNotFound = Binding {0} in {1}/{2} was not found +InvalidPort = Port {0}/{1} in {2}/{3} is not supported +NoValidPorts = No valid ports for service {0} in {1}/{2} +NoWsdlInterface = No WSDL interface definition for {1}/{2} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java new file mode 100644 index 0000000000..7e6a1de546 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java @@ -0,0 +1,34 @@ +/* + * 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.binding.ws.other; + +/** + * + * @version $Rev$ $Date$ + */ +public class Other { + private String name; + + public String getName() { + return name; + } + public void setName(String name ) { + this.name = name; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java new file mode 100644 index 0000000000..f10a2286e6 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://other.ws.binding.sca.tuscany.apache.org/") +package org.apache.tuscany.sca.binding.ws.other; + diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java new file mode 100644 index 0000000000..e474c7a318 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java @@ -0,0 +1,86 @@ +/* + * 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.binding.ws.wsdlgen; + +import java.util.List; +import java.util.Map; + +import javax.wsdl.Definition; +import javax.wsdl.Operation; +import javax.wsdl.PortType; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; +import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper; +import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor; +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.xsd.XSDFactory; +import org.apache.tuscany.sca.xsd.xml.XSDModelResolver; +import org.osoa.sca.annotations.Remotable; + +/** + * + * @version $Rev$ $Date$ + */ +public class BindingWSDLGeneratorTestCase extends TestCase { + + public void testCreateWSDLInterfaceContract() throws InvalidInterfaceException { + DefaultModelFactoryExtensionPoint modelFactories = new DefaultModelFactoryExtensionPoint(); + WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); + DefaultJavaInterfaceFactory factory = new DefaultJavaInterfaceFactory(); + JavaInterfaceContract javaIC = factory.createJavaInterfaceContract(); + JavaInterface iface = factory.createJavaInterface(HelloWorld.class); + DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(); + JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null); + new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface); + new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); + javaIC.setInterface(iface); + WSDLInterfaceContract wsdlIC = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, null); + assertNotNull(wsdlIC); + WSDLInterface wsdlInterface = (WSDLInterface)wsdlIC.getInterface(); + assertNotNull(wsdlInterface); + assertEquals(1, wsdlInterface.getOperations().size()); + assertEquals("sayHello", wsdlInterface.getOperations().get(0).getName()); + assertNotNull(wsdlInterface.getPortType()); + + JavaInterfaceContract javaIC2 = factory.createJavaInterfaceContract(); + JavaInterface iface2 = factory.createJavaInterface(TestJavaInterface.class); + new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface2); + new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface2); + javaIC2.setInterface(iface2); + WSDLInterfaceContract wsdlIC2 = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC2, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, null); + assertNotNull(wsdlIC2); + } + +} + +@Remotable +interface HelloWorld { + String sayHello(String s); +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java new file mode 100644 index 0000000000..f1e12f8ce0 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.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.binding.ws.wsdlgen; + +import java.io.StringWriter; + +import javax.wsdl.Definition; +import javax.wsdl.xml.WSDLWriter; + +import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor; +import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint; +import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper; +import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor; +import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.xsd.DefaultXSDFactory; +import org.apache.tuscany.sca.xsd.xml.XSDModelResolver; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + */ +public class Interface2WSDLGeneratorTestCase { + + @Test + public void testGenerate() throws Exception { + DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(); + JavaInterface iface = iFactory.createJavaInterface(TestJavaInterface.class); + DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(); + JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null); + new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface); + new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); + DefaultModelFactoryExtensionPoint modelFactories = new DefaultModelFactoryExtensionPoint(); + WSDLDefinition wsdlDefinition = new DefaultWSDLFactory(modelFactories).createWSDLDefinition(); + DefaultXSDFactory factory = new DefaultXSDFactory(); + Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, null); + Definition definition = generator.generate(iface, wsdlDefinition); + + // print the generated WSDL file and inline schemas + WSDLWriter writer = generator.getFactory().newWSDLWriter(); + StringWriter sw = new StringWriter(); + writer.writeWSDL(definition, sw); + System.out.println(sw.toString()); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java new file mode 100644 index 0000000000..1e4f802e01 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java @@ -0,0 +1,47 @@ +/* + * 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.binding.ws.wsdlgen; + +/** + * + * @version $Rev$ $Date$ + */ +public class TestException extends Exception { + + private String userdata; + + public TestException(String message) { + super(message); + } + + public TestException(String message, String userdata) { + super(message); + this.userdata = userdata; + } + + public String getUserdata() { + return userdata; + } + + public void setUserdata(String userdata) { + this.userdata = userdata; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java new file mode 100644 index 0000000000..da2c285bac --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java @@ -0,0 +1,46 @@ +/* + * 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.binding.ws.wsdlgen; + +import javax.xml.ws.WebFault; + +/** + * + * @version $Rev$ $Date$ + */ +@WebFault(faultBean="org.apache.tuscany.sca.binding.ws.wsdlgen.TestFaultBean") +public class TestFault extends Exception { + + private TestFaultBean bean; + + public TestFault(TestFaultBean bean, String message) { + super(message); + this.bean = bean; + } + + public TestFault(TestFaultBean bean, String message, Throwable cause) { + super(message, cause); + this.bean = bean; + } + + public TestFaultBean getFaultInfo() { + return bean; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java new file mode 100644 index 0000000000..64cce0e49d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java @@ -0,0 +1,54 @@ +/* + * 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.binding.ws.wsdlgen; + +/** + * + * @version $Rev$ $Date$ + */ +public class TestFaultBean { + private String lastName; + private String firstName; + private float age; + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public float getAge() { + return age; + } + + public void setAge(float age) { + this.age = age; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java new file mode 100644 index 0000000000..3fd7361ae1 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java @@ -0,0 +1,32 @@ +/* + * 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.binding.ws.wsdlgen; +import org.apache.tuscany.sca.binding.ws.other.Other; + +/** + * + * @version $Rev$ $Date$ + */ +public class TestJavaClass { + public Other other; + public String name; + public int number; + public float balance; +} diff --git a/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java new file mode 100644 index 0000000000..9635d65f99 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java @@ -0,0 +1,57 @@ +/* + * 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.binding.ws.wsdlgen; + +import javax.jws.WebMethod; +import javax.jws.WebService; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * + * @version $Rev$ $Date$ + */ +@Remotable +@WebService +public interface TestJavaInterface { + String m1(String str); + + @OneWay + @WebMethod + void m2(int i); + + @WebMethod + String m3(); + + void m4(); + + @WebMethod + String m5(String str, int i); + + @WebMethod(exclude = true) + void dummy(); + + @WebMethod + void m6(TestJavaClass info) throws TestException; + + @WebMethod + void m7(TestJavaClass info) throws TestFault; +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/LICENSE b/branches/sca-java-1.4/modules/binding-ws-xml/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-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/branches/sca-java-1.4/modules/binding-ws-xml/NOTICE b/branches/sca-java-1.4/modules/binding-ws-xml/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/pom.xml b/branches/sca-java-1.4/modules/binding-ws-xml/pom.xml new file mode 100644 index 0000000000..6a3151cd04 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/pom.xml @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-ws-xml</artifactId> + <name>Apache Tuscany SCA WS Binding XML Model</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-impl</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-wsdlgen</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-sca</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl-xml</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.binding.ws.xml</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.binding.ws.xml*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java new file mode 100644 index 0000000000..f2376231ab --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java @@ -0,0 +1,51 @@ +/* + * 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.binding.ws.xml; + +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.builder.BindingBuilder; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * A factory for the calculated WSDL document needed by Web Service bindings. + * + * @version $Rev$ $Date$ + */ +public class BindingBuilderImpl implements BindingBuilder { + + private ExtensionPointRegistry extensionPoints; + + public BindingBuilderImpl(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + } + + /** + * Create a calculated WSDL document and save it in the Web Service binding. + */ + public void build(Component component, AbstractContract contract, Binding binding, Monitor monitor) { + BindingWSDLGenerator.generateWSDL(component, contract, (WebServiceBinding)binding, extensionPoints, monitor); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java new file mode 100644 index 0000000000..ad2540e5fe --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java @@ -0,0 +1,230 @@ +/* + * 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.binding.ws.xml; + +import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + +import java.io.StringWriter; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.Source; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Helper methods to read and write a wsa:endpointReference + * TODO: almost direct copy of code for Assembly properties + * must be able to move to a common utility + * + * @version $Rev$ $Date$ + */ +public class EndPointReferenceHelper { + + /** + * Read a wsa:endpointReference into a DOM Element + */ + public static Element readEndPointReference(XMLStreamReader reader) { + try { + + return loadElement(reader); + + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + } + + /** + * Write a wsa:endpointReference from a DOM Element + */ + public static void writeEndPointReference(Element element, XMLStreamWriter writer) { + try { + + saveElement(element, writer); + + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } + } + + private static Element loadElement(XMLStreamReader reader) throws XMLStreamException, ParserConfigurationException { + Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Node root = document; + Node current = root; + while (true) { + switch (reader.getEventType()) { + case XMLStreamConstants.START_ELEMENT: + QName name = reader.getName(); + Element child = createElement(document, name); + + // push the new element and make it the current one + current.appendChild(child); + current = child; + + int count = reader.getNamespaceCount(); + for (int i = 0; i < count; i++) { + String prefix = reader.getNamespacePrefix(i); + String ns = reader.getNamespaceURI(i); + declareNamespace(child, prefix, ns); + } + + if(!"".equals(name.getNamespaceURI())) + declareNamespace(child, name.getPrefix(), name.getNamespaceURI()); + + // add the attributes for this element + count = reader.getAttributeCount(); + for (int i = 0; i < count; i++) { + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + if (prefix != null && prefix.length() != 0) { + qname = prefix + ":" + qname; + } + child.setAttributeNS(ns, qname, value); + if (ns != null) { + declareNamespace(child, prefix, ns); + } + } + + break; + case XMLStreamConstants.CDATA: + current.appendChild(document.createCDATASection(reader.getText())); + break; + case XMLStreamConstants.CHARACTERS: + current.appendChild(document.createTextNode(reader.getText())); + break; + case XMLStreamConstants.END_ELEMENT: + // if we are back at the root then we are done + if ("EndpointReference".equals(reader.getName().getLocalPart())) { + return document.getDocumentElement(); + } + + // pop the element off the stack + current = current.getParentNode(); + } + if ( reader.hasNext()) reader.next(); + } + } + + private static Element createElement(Document document, QName name) { + String prefix = name.getPrefix(); + String qname = + (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart(); + return document.createElementNS(name.getNamespaceURI(), qname); + } + + private static void declareNamespace(Element element, String prefix, String ns) { + if (ns == null) { + ns = ""; + } + if (prefix == null) { + prefix = ""; + } + String qname = null; + if ("".equals(prefix)) { + qname = "xmlns"; + } else { + qname = "xmlns:" + prefix; + } + Node node = element; + boolean declared = false; + while (node != null && node.getNodeType() == Node.ELEMENT_NODE) { + NamedNodeMap attrs = node.getAttributes(); + if (attrs == null) { + break; + } + Node attr = attrs.getNamedItem(qname); + if (attr != null) { + declared = ns.equals(attr.getNodeValue()); + break; + } + node = node.getParentNode(); + } + if (!declared) { + org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname); + attr.setValue(ns); + element.setAttributeNodeNS(attr); + } + } + + private static void saveElement(Element element, XMLStreamWriter writer) throws XMLStreamException{ + + XMLStreamReader reader = + XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(element)); + + while (reader.hasNext()) { + switch (reader.next()) { + case XMLStreamConstants.START_ELEMENT: + QName name = reader.getName(); + writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI()); + + int namespaces = reader.getNamespaceCount(); + for (int i = 0; i < namespaces; i++) { + String prefix = reader.getNamespacePrefix(i); + String ns = reader.getNamespaceURI(i); + writer.writeNamespace(prefix, ns); + } + + if (!"".equals(name.getNamespaceURI())) { + writer.writeNamespace(name.getPrefix(), name.getNamespaceURI()); + } + + // add the attributes for this element + namespaces = reader.getAttributeCount(); + for (int i = 0; i < namespaces; i++) { + String ns = reader.getAttributeNamespace(i); + String prefix = reader.getAttributePrefix(i); + String qname = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + + writer.writeAttribute(prefix, ns, qname, value); + } + + break; + case XMLStreamConstants.CDATA: + writer.writeCData(reader.getText()); + break; + case XMLStreamConstants.CHARACTERS: + writer.writeCharacters(reader.getText()); + break; + case XMLStreamConstants.END_ELEMENT: + writer.writeEndElement(); + break; + } + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java new file mode 100644 index 0000000000..860daa647d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java @@ -0,0 +1,432 @@ +/* + * 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.binding.ws.xml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import java.util.Map; +import javax.wsdl.Binding; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +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.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.OperationsConfigurator; +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +import org.apache.tuscany.sca.binding.ws.DefaultWebServiceBindingFactory; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +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.ContributionRuntimeException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +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.WSDLObject; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * This is the StAXArtifactProcessor for the Web Services Binding. + * + * @version $Rev$ $Date$ + */ +public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServiceBinding>, WebServiceConstants { + + private ExtensionPointRegistry extensionPoints; + private WSDLFactory wsdlFactory; + private WebServiceBindingFactory wsFactory; + private PolicyFactory policyFactory; + private PolicyAttachPointProcessor policyProcessor; + private IntentAttachPointTypeFactory intentAttachPointTypeFactory; + private ConfiguredOperationProcessor configuredOperationProcessor; + private Monitor monitor; + + public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.wsFactory = new DefaultWebServiceBindingFactory(); + this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); + this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + if (monitorFactory != null) { + this.monitor = monitorFactory.createMonitor(); + } + this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor); + } + + /** + * Report a warning. + * + * @param problem + * @param model + * @param message data + */ + private void warning(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + /** + * Report an error. + * + * @param problem + * @param model + * @param message data + */ + private void error(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + /** + * Report an exception. + * + * @param problem + * @param model + * @param exception + */ + private void error(String message, Object model, Exception ex) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } + } + + public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + + // Read a <binding.ws> + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + /*IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType(); + bindingType.setName(getArtifactType()); + bindingType.setUnresolved(true); + ((PolicySetAttachPoint)wsBinding).setType(bindingType);*/ + wsBinding.setUnresolved(true); + wsBinding.setBuilder(new BindingBuilderImpl(extensionPoints)); + + // Read policies + policyProcessor.readPolicies(wsBinding, reader); + + // Read the binding name + String name = reader.getAttributeValue(null, NAME); + if (name != null) { + wsBinding.setName(name); + } + + // Read URI + String uri = reader.getAttributeValue(null, URI); + if (uri != null) { + wsBinding.setURI(uri); + } + + // Read a qname in the form: + // namespace#wsdl.???(name) + Boolean wsdlElementIsBinding = null; + String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT); + if (wsdlElement != null) { + int index = wsdlElement.indexOf('#'); + if (index == -1) { + error("InvalidWsdlElementAttr", reader, wsdlElement); + //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement); + return wsBinding; + } + String namespace = wsdlElement.substring(0, index); + wsBinding.setNamespace(namespace); + String localName = wsdlElement.substring(index + 1); + if (localName.startsWith("wsdl.service")) { + + // Read a wsdl.service + localName = localName.substring("wsdl.service(".length(), localName.length() - 1); + wsBinding.setServiceName(new QName(namespace, localName)); + + } else if (localName.startsWith("wsdl.port")) { + + // Read a wsdl.port + localName = localName.substring("wsdl.port(".length(), localName.length() - 1); + int s = localName.indexOf('/'); + if (s == -1) { + error("InvalidWsdlElementAttr", reader, wsdlElement); + //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement); + } else { + wsBinding.setServiceName(new QName(namespace, localName.substring(0, s))); + wsBinding.setPortName(localName.substring(s + 1)); + } + } else if (localName.startsWith("wsdl.endpoint")) { + + // Read a wsdl.endpoint + localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1); + int s = localName.indexOf('/'); + if (s == -1) { + error("InvalidWsdlElementAttr", reader, wsdlElement); + //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement); + } else { + wsBinding.setServiceName(new QName(namespace, localName.substring(0, s))); + wsBinding.setEndpointName(localName.substring(s + 1)); + } + } else if (localName.startsWith("wsdl.binding")) { + + // Read a wsdl.binding + localName = localName.substring("wsdl.binding(".length(), localName.length() - 1); + wsBinding.setBindingName(new QName(namespace, localName)); + + wsdlElementIsBinding = true; + + } else { + error("InvalidWsdlElementAttr", reader, wsdlElement); + //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement); + } + } + + // Read wsdlLocation + wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION)); + + ConfiguredOperation confOp = null; + // Skip to end element + while (reader.hasNext()) { + int event = reader.next(); + switch (event) { + case START_ELEMENT: { + if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) { + if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) { + error("MustUseWsdlBinding", reader, wsdlElement); + throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference"); + } + wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader)); + } else if (Constants.OPERATION_QNAME.equals(reader.getName())) { + confOp = configuredOperationProcessor.read(reader); + if (confOp != null) { + ((OperationsConfigurator)wsBinding).getConfiguredOperations().add(confOp); + } + } + } + break; + + } + + if (event == END_ELEMENT && BINDING_WS_QNAME.equals(reader.getName())) { + break; + } + } + return wsBinding; + } + + protected void processEndPointReference(XMLStreamReader reader, WebServiceBinding wsBinding) { + } + + public void write(WebServiceBinding wsBinding, XMLStreamWriter writer) throws ContributionWriteException, + XMLStreamException { + + // Write a <binding.ws> + policyProcessor.writePolicyPrefixes(wsBinding, writer); + writer.writeStartElement(Constants.SCA10_NS, BINDING_WS); + policyProcessor.writePolicyAttributes(wsBinding, writer); + + // Write binding name + if (wsBinding.getName() != null) { + writer.writeAttribute(NAME, wsBinding.getName()); + } + + // Write binding URI + if (wsBinding.getURI() != null) { + writer.writeAttribute(URI, wsBinding.getURI()); + } + + // Write wsdlElement attribute + if (wsBinding.getPortName() != null) { + + // Write namespace#wsdl.port(service/port) + String wsdlElement = + wsBinding.getServiceName().getNamespaceURI() + "#wsdl.port(" + + wsBinding.getServiceName().getLocalPart() + + "/" + + wsBinding.getPortName() + + ")"; + writer.writeAttribute(WSDL_ELEMENT, wsdlElement); + + } else if (wsBinding.getEndpointName() != null) { + + // Write namespace#wsdl.endpoint(service/endpoint) + String wsdlElement = + wsBinding.getServiceName().getNamespaceURI() + "#wsdl.endpoint(" + + wsBinding.getServiceName().getLocalPart() + + "/" + + wsBinding.getEndpointName() + + ")"; + writer.writeAttribute(WSDL_ELEMENT, wsdlElement); + + } else if (wsBinding.getBindingName() != null) { + + // Write namespace#wsdl.binding(binding) + String wsdlElement = + wsBinding.getBindingName().getNamespaceURI() + "#wsdl.binding(" + + wsBinding.getBindingName().getLocalPart() + + ")"; + writer.writeAttribute(WSDL_ELEMENT, wsdlElement); + + } else if (wsBinding.getServiceName() != null) { + + // Write namespace#wsdl.service(service) + String wsdlElement = + wsBinding.getServiceName().getNamespaceURI() + "#wsdl.service(" + + wsBinding.getServiceName().getLocalPart() + + ")"; + writer.writeAttribute(WSDL_ELEMENT, wsdlElement); + } + + // Write location + if (wsBinding.getLocation() != null) { + writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsBinding.getLocation()); + } + + if (wsBinding.getEndPointReference() != null) { + EndPointReferenceHelper.writeEndPointReference(wsBinding.getEndPointReference(), writer); + } + + writer.writeEndElement(); + } + + public void resolve(WebServiceBinding model, ModelResolver resolver) throws ContributionResolveException { + + if (model == null || !model.isUnresolved()) + return; + + WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); + wsdlDefinition.setUnresolved(true); + wsdlDefinition.setNamespace(model.getNamespace()); + WSDLDefinition resolved = null; + try { + resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition); + } catch (ContributionRuntimeException e) { + ContributionResolveException ce = new ContributionResolveException(e.getCause()); + error("ContributionResolveException", wsdlDefinition, ce); + throw ce; + } + + if (!resolved.isUnresolved()) { + wsdlDefinition.setDefinition(resolved.getDefinition()); + wsdlDefinition.setLocation(resolved.getLocation()); + wsdlDefinition.setURI(resolved.getURI()); + wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions()); + wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas()); + wsdlDefinition.setUnresolved(false); + model.setDefinition(wsdlDefinition); + if (model.getBindingName() != null) { + WSDLObject<Binding> binding = wsdlDefinition.getWSDLObject(Binding.class, model.getBindingName()); + if (binding != null) { + wsdlDefinition.setDefinition(binding.getDefinition()); + model.setBinding(binding.getElement()); + } else { + warning("WsdlBindingDoesNotMatch", wsdlDefinition, model.getBindingName()); + } + } + if (model.getServiceName() != null) { + WSDLObject<Service> service = wsdlDefinition.getWSDLObject(Service.class, model.getServiceName()); + if (service != null) { + wsdlDefinition.setDefinition(service.getDefinition()); + model.setService(service.getElement()); + if (model.getPortName() != null) { + Port port = service.getElement().getPort(model.getPortName()); + if (port != null) { + model.setPort(port); + model.setBinding(port.getBinding()); + } else { + warning("WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName()); + } + } + } else { + warning("WsdlServiceDoesNotMatch", wsdlDefinition, model.getServiceName()); + } + } + + PortType portType = getPortType(model); + if (portType != null) { + WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract(); + WSDLInterface wsdlInterface = null; + try { + wsdlInterface = wsdlFactory.createWSDLInterface(portType, wsdlDefinition, resolver); + } catch (InvalidInterfaceException e) { + warning("InvalidInterfaceException", wsdlFactory, model.getName()); + } + interfaceContract.setInterface(wsdlInterface); + model.setBindingInterfaceContract(interfaceContract); + } + } + policyProcessor.resolvePolicies(model, resolver); + OperationsConfigurator opCongigurator = (OperationsConfigurator)model; + for (ConfiguredOperation confOp : opCongigurator.getConfiguredOperations()) { + policyProcessor.resolvePolicies(confOp, resolver); + } + } + + private PortType getPortType(WebServiceBinding model) { + PortType portType = null; + if (model.getPort() != null) { + portType = model.getPort().getBinding().getPortType(); + } else if (model.getEndpoint() != null) { + portType = model.getPort().getBinding().getPortType(); + } else if (model.getBinding() != null) { + portType = model.getBinding().getPortType(); + } else if (model.getService() != null) { + // FIXME: How to find the compatible port? + Map ports = model.getService().getPorts(); + if (!ports.isEmpty()) { + Port port = (Port)ports.values().iterator().next(); + portType = port.getBinding().getPortType(); + } + } + return portType; + } + + public QName getArtifactType() { + return WebServiceConstants.BINDING_WS_QNAME; + } + + public Class<WebServiceBinding> getModelType() { + return WebServiceBinding.class; + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java new file mode 100644 index 0000000000..03c84a6b41 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java @@ -0,0 +1,44 @@ +/* + * 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.binding.ws.xml; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; + +/** + * Constants for the Web Services Binding. + * + * @version $Rev$ $Date$ + */ +public interface WebServiceConstants { + + String BINDING_WS = "binding.ws"; + QName BINDING_WS_QNAME = new QName(Constants.SCA10_NS, BINDING_WS); + String WSDL_ELEMENT = "wsdlElement"; + QName WSDL_ELEMENT_QNAME = new QName(Constants.SCA10_NS, WSDL_ELEMENT); + 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); + String NAME = "name"; + String URI = "uri"; + String END_POINT_REFERENCE = "EndpointReference"; + + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..cb982e8647 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.binding.ws.xml.WebServiceBindingProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#binding.ws,model=org.apache.tuscany.sca.binding.ws.WebServiceBinding diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties new file mode 100644 index 0000000000..9e2ff5830d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties @@ -0,0 +1,27 @@ +# +# +# 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. +# +# +InvalidWsdlElementAttr = Invalid WebService binding wsdlElement attribute: {0} +MustUseWsdlBinding = {0} must use wsdl.binding when using wsa:EndpointReference +InvalidInterfaceException = Exception creating interface from WSDL for binding: {0} +WsdlBindingDoesNotMatch = The #wsdl.binding({0}) does not match with the WSDL Definitions +WsdlServiceDoesNotMatch = The #wsdl.service({0}) does not match with the WSDL Definitions +WsdlPortTypeDoesNotMatch = The #wsdl.port({0}) does not match with the WSDL Definitions +ContributionResolveException = Error in contribution: {0} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java new file mode 100644 index 0000000000..ef955254c1 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.xml; + +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +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.OperationsConfigurator; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; + +/** + * Test reading WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class ReadTestCase extends TestCase { + + private XMLInputFactory inputFactory; + private StAXArtifactProcessor<Object> staxProcessor; + private CompositeBuilder compositeBuilder; + + @Override + public void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); + + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); + + IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, null); + } + + @Override + public void tearDown() throws Exception { + } + + public void testReadComponentType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + ComponentType componentType = (ComponentType)staxProcessor.read(reader); + assertNotNull(componentType); + } + + public void testReadComposite() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = (Composite)staxProcessor.read(reader); + assertNotNull(composite); + + compositeBuilder.build(composite); + } + + public void testReadPolicies() throws Exception { + InputStream is = getClass().getResourceAsStream("PoliciedCalculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = (Composite)staxProcessor.read(reader); + assertNotNull(composite); + + compositeBuilder.build(composite); + + assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)) + .getConfiguredOperations().get(0).getRequiredIntents().size(), 2); + } + + /** + * This test makes sure that an exception is thrown when a bad wsdlElement is present along with EndpointReference. + * + * Ref: Web Service Binding Specification v1.0 - Sec 2.1 - Lines 61 to 65. + * When an EndpointReference is present along with the wsdlElement attribute on the parent element, the wsdlElement attribute value MUST + * be of the 'Binding' form. + */ + public void testReadBadWsdlElement() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator-bad-wsdlElement.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + try { + staxProcessor.read(reader); + fail("ContributionReadException expected."); + } catch(ContributionReadException e) { + // Expected + assertNotSame(-1, e.getMessage().indexOf("must use wsdl.binding when using wsa:EndpointReference")); + } + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java new file mode 100644 index 0000000000..0e519af9d3 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java @@ -0,0 +1,76 @@ +/* + * 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.binding.ws.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.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; + +/** + * Test reading/write WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class WriteTestCase extends TestCase { + + private XMLInputFactory inputFactory; + private XMLOutputFactory outputFactory; + private StAXArtifactProcessor<Object> staxProcessor; + + @Override + public void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); + } +/* + public void testReadWriteComponentType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is)); + assertNotNull(componentType); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos)); + } +*/ + + public void testReadWriteComposite() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is)); + assertNotNull(composite); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + System.out.println(bos.toString()); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite new file mode 100644 index 0000000000..d8d1b3401e --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator-bad-wsdlElement">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/Calculator</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite new file mode 100644 index 0000000000..f7460813cd --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:calc="http://sample.calculator" + targetNamespace="http://calc" + xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance" + name="Calculator"> + + <service name="CalculatorService" promote="CalculatorServiceComponent"> + <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/> + <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)"/> + <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/> + <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/> + <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/> + <binding.ws wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"> + <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing"> + <wsa:Address>http://localhost:8085/services/HelloWorldWebService</wsa:Address> + </wsa:EndpointReference> + </binding.ws> + </service> + + <component name="CalculatorServiceComponent"> + <implementation.java class="calculator.CalculatorServiceImpl"/> + <reference name="addService" target="AddServiceComponent"/> + <reference name="subtractService" target="SubtractServiceComponent"/> + <reference name="multiplyService" target="MultiplyServiceComponent"/> + <reference name="divideService" target="DivideServiceComponent"/> + </component> + + <component name="AddServiceComponent"> + <implementation.java class="calculator.AddServiceImpl"/> + </component> + + <component name="SubtractServiceComponent"> + <implementation.java class="calculator.SubtractServiceImpl"/> + </component> + + <component name="MultiplyServiceComponent"> + <implementation.java class="calculator.MultiplyServiceImpl"/> + </component> + + <component name="DivideServiceComponent"> + <implementation.java class="calculator.DivideServiceImpl"/> + </component> + +</composite> diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType new file mode 100644 index 0000000000..959802af43 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"> + + <service name="CalculatorService"> + <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/> + <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)"/> + <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/> + <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/> + <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/> + </service> + + <reference name="divideService"> + <interface.wsdl interface="http://sample/calculator#wsdl.interface(Divide)"/> + <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.service(DivideService)"/> + <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(DivideBinding)"/> + <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.port(DivideService/DividePort)"/> + <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.endpoint(DivideService/DivideEndpoint)"/> + <binding.ws> + <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing"> + <wsa:Address>myURI</wsa:Address> + </wsa:EndpointReference> + </binding.ws> + </reference> + +</componentType> +
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite new file mode 100644 index 0000000000..37c80aa910 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)">
+ <operation name="add" requires="IntentOne IntentTwo"/>
+ </binding.ws>
+ <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl new file mode 100644 index 0000000000..5e8e5dad0d --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://www.example.org" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + name="example"> + + <wsdl:portType name="HelloWorld"> + </wsdl:portType> +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl new file mode 100644 index 0000000000..ad81fc7867 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" + xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + + <types> + <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="getLastTradePrice1"> + <complexType> + <sequence> + <element name="tickerSymbol" type="string" /> + </sequence> + </complexType> + </element> + <element name="getLastTradePriceResponse"> + <complexType> + <sequence> + <element name="price" type="float" /> + </sequence> + </complexType> + </element> + </schema> + </types> + + <message name="GetLastTradePriceInput"> + <part name="body" element="xsd1:getLastTradePrice" /> + </message> + + <message name="GetLastTradePriceOutput"> + <part name="body" element="xsd1:getLastTradePriceResponse" /> + </message> + + <portType name="StockQuotePortType"> + <operation name="getLastTradePrice"> + <input message="tns:GetLastTradePriceInput" /> + <output message="tns:GetLastTradePriceOutput" /> + </operation> + </portType> + +</definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd new file mode 100644 index 0000000000..241ec15d36 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd @@ -0,0 +1,136 @@ +<!-- + * 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. +--> +<schema targetNamespace="http://www.example.com/IPO" + xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:ipo="http://www.example.com/IPO"> + + <annotation> + <documentation xml:lang="en"> + International Purchase order schema for Example.com + Copyright 2000 Example.com. All rights reserved. + </documentation> + </annotation> + + + <element name="purchaseOrder" type="ipo:PurchaseOrderType" /> + + <element name="comment" type="string" /> + + <complexType name="PurchaseOrderType"> + <sequence> + <element name="shipTo" type="ipo:Address" /> + <element name="billTo" type="ipo:Address" /> + <element ref="ipo:comment" minOccurs="0" /> + <element name="items" type="ipo:Items" /> + </sequence> + <attribute name="orderDate" type="date" /> + </complexType> + + <complexType name="Items"> + <sequence> + <element name="item" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="productName" type="string" /> + <element name="quantity"> + <simpleType> + <restriction base="positiveInteger"> + <maxExclusive value="100" /> + </restriction> + </simpleType> + </element> + <element name="USPrice" type="decimal" /> + <element ref="ipo:comment" minOccurs="0" /> + <element name="shipDate" type="date" + minOccurs="0" /> + </sequence> + <attribute name="partNum" type="ipo:SKU" + use="required" /> + </complexType> + </element> + </sequence> + </complexType> + + <simpleType name="SKU"> + <restriction base="string"> + <pattern value="\d{3}-[A-Z]{2}" /> + </restriction> + </simpleType> + + <complexType name="Address"> + <sequence> + <element name="name" type="string" /> + <element name="street" type="string" /> + <element name="city" type="string" /> + </sequence> + </complexType> + + <complexType name="USAddress"> + <complexContent> + <extension base="ipo:Address"> + <sequence> + <element name="state" type="ipo:USState" /> + <element name="zip" type="positiveInteger" /> + </sequence> + </extension> + </complexContent> + </complexType> + + <complexType name="UKAddress"> + <complexContent> + <extension base="ipo:Address"> + <sequence> + <element name="postcode" type="ipo:UKPostcode" /> + </sequence> + <attribute name="exportCode" type="positiveInteger" + fixed="1" /> + </extension> + </complexContent> + </complexType> + + <!-- other Address derivations for more countries --> + + <simpleType name="USState"> + <restriction base="string"> + <enumeration value="AK" /> + <enumeration value="AL" /> + <enumeration value="AR" /> + <enumeration value="CA" /> + <enumeration value="PA" /> + <!-- and so on ... --> + </restriction> + </simpleType> + + <simpleType name="Postcode"> + <restriction base="string"> + <length value="7" fixed="true" /> + </restriction> + </simpleType> + + + <simpleType name="UKPostcode"> + <restriction base="ipo:Postcode"> + <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" /> + </restriction> + </simpleType> + + + +</schema> + diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl new file mode 100644 index 0000000000..39cd5547d9 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" + xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + + <types> + <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="getLastTradePrice"> + <complexType> + <sequence> + <element name="tickerSymbol" type="string" /> + </sequence> + </complexType> + </element> + <element name="getLastTradePriceResponse"> + <complexType> + <sequence> + <element name="price" type="float" /> + </sequence> + </complexType> + </element> + </schema> + </types> + + <message name="GetLastTradePriceInput"> + <part name="body" element="xsd1:getLastTradePrice" /> + </message> + + <message name="GetLastTradePriceOutput"> + <part name="body" element="xsd1:getLastTradePriceResponse" /> + </message> + + <portType name="StockQuotePortType"> + <operation name="getLastTradePrice"> + <input message="tns:GetLastTradePriceInput" /> + <output message="tns:GetLastTradePriceOutput" /> + </operation> + </portType> + +</definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl new file mode 100644 index 0000000000..8e26f7b4b5 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="helloworld"> + + <wsdl:import location="test2.wsdl" namespace="http://helloworld"></wsdl:import> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8085/sample-helloworldws-1.0-SNAPSHOT/services/HelloWorldWebService" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd new file mode 100644 index 0000000000..c2210f4a94 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd @@ -0,0 +1,33 @@ +<!-- + * 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. +--> +<schema targetNamespace="http://www.example.com/Customer" xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:ipo="http://www.example.com/IPO" xmlns:tns="http://www.example.com/Customer"> + <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" /> + + <complexType name="Customer"> + <sequence> + <element name="customerID" type="string"></element> + <element name="name" type="string"></element> + <element name="order" type="ipo:PurchaseOrderType" /> + </sequence> + </complexType> + <element name="customer" type="tns:Customer"></element> + +</schema> + diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl new file mode 100644 index 0000000000..529b395fd5 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="helloworld"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema"> + + <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" /> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string" /> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string" /> + </sequence> + </complexType> + </element> + + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters" /> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest" /> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse" /> + </wsdl:operation> + </wsdl:portType> + +</wsdl:definitions> diff --git a/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl new file mode 100644 index 0000000000..666a7e4069 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" + xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + + <types> + <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema"> + <element name="getLastTradePrice"> + <complexType> + <sequence> + <element name="tickerSymbol" type="string" /> + </sequence> + </complexType> + </element> + <element name="getLastTradePriceResponse"> + <complexType> + <sequence> + <element name="price" type="float" /> + </sequence> + </complexType> + </element> + </schema> + </types> + + <message name="GetLastTradePriceInput1"> + <part name="body" element="xsd1:getLastTradePrice" /> + </message> + + <message name="GetLastTradePriceOutput1"> + <part name="body" element="xsd1:getLastTradePriceResponse" /> + </message> + + <message name="GetLastTradePriceInput2"> + <part name="body" element="xsd1:getLastTradePrice" /> + <part name="other" type="xsd:string"/> + </message> + + <message name="GetLastTradePriceOutput2"> + <part name="body" element="xsd1:getLastTradePriceResponse" /> + </message> + + <portType name="StockQuotePortType"> + <operation name="getLastTradePrice"> + <input message="tns:GetLastTradePriceInput1" /> + <output message="tns:GetLastTradePriceOutput1" /> + </operation> + <operation name="getLastTradePrice1"> + <input message="tns:GetLastTradePriceInput1" /> + <output message="tns:GetLastTradePriceOutput1" /> + </operation> + <operation name="getLastTradePrice2"> + <input message="tns:GetLastTradePriceInput2" /> + <output message="tns:GetLastTradePriceOutput2" /> + </operation> + </portType> + +</definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.4/modules/binding-ws/LICENSE b/branches/sca-java-1.4/modules/binding-ws/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/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/branches/sca-java-1.4/modules/binding-ws/NOTICE b/branches/sca-java-1.4/modules/binding-ws/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/branches/sca-java-1.4/modules/binding-ws/pom.xml b/branches/sca-java-1.4/modules/binding-ws/pom.xml new file mode 100644 index 0000000000..8a6ade06eb --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/pom.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-ws</artifactId> + <name>Apache Tuscany SCA WS Binding Model</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>wsdl4j</groupId> + <artifactId>wsdl4j</artifactId> + <version>1.6.2</version> + </dependency> + </dependencies> + + <repositories> + <!-- Apache repository for Web Services artifacts --> + <repository> + <id>apache.ws.zone</id> + <name>Apache WS Zone Repository</name> + <url>http://ws.zones.apache.org/repository2</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.binding.ws</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.binding.ws*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/DefaultWebServiceBindingFactory.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/DefaultWebServiceBindingFactory.java new file mode 100644 index 0000000000..2ccaa5dc58 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/DefaultWebServiceBindingFactory.java @@ -0,0 +1,31 @@ +/* + * 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.binding.ws; + +import org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingFactoryImpl; + +/** + * A factory for the Web Service binding model. + * + * @version $Rev$ $Date$ + */ +@Deprecated +public class DefaultWebServiceBindingFactory extends WebServiceBindingFactoryImpl implements WebServiceBindingFactory { + +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java new file mode 100644 index 0000000000..0d07a55a14 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java @@ -0,0 +1,214 @@ +/* + * 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.binding.ws; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.w3c.dom.Element; + + +/** + * Represents a WebService binding. + * + * @version $Rev$ $Date$ + */ +public interface WebServiceBinding extends Binding, BindingBuilderExtension { + + /** + * Sets the WSDL location. + * @param location the WSDL location + */ + void setLocation(String location); + + /** + * Returns the WSDL location + * @return the WSDL location + */ + String getLocation(); + + /** + * Returns the name of the WSDL service. + * + * @return the name of the WSDL service + */ + QName getServiceName(); + + /** + * Sets the name of the WSDL service. + * + * @param serviceName the name of the WSDL service + */ + void setServiceName(QName serviceName); + + /** + * Returns the name of the WSDL port. + * + * @return the name of the WSDL port + */ + String getPortName(); + + /** + * Sets the name of the WSDL port. + * + * @param portName the name of the WSDL port + */ + void setPortName(String portName); + + /** + * Returns the name of the WSDL binding. + * + * @return the name of the WSDL binding + */ + QName getBindingName(); + + /** + * Sets the name of the WSDL binding. + * + * @param bindingName the name of the WSDL binding + */ + void setBindingName(QName bindingName); + + /** + * Returns the name of the WSDL endpoint. + * + * @return the name of the WSDL endpoint + */ + String getEndpointName(); + + /** + * Sets the name of the WSDL endpoint. + * + * @param endpointName the name of the WSDL endpoint + */ + void setEndpointName(String endpointName); + + /** + * Returns the WSDL service + * @return the WSDL service + */ + Service getService(); + + /** + * Sets the WSDL service. + * @param service the WSDL service + */ + void setService(Service service); + + /** + * Returns the WSDL port + * @return the WSDL port + */ + Port getPort(); + + /** + * Sets the WSDL endpoint + * @param endpoint the WSDL endpoint + */ + void setEndpoint(Port endpoint); + + /** + * Returns the WSDL endpoint + * @return the WSDL endpoint + */ + Port getEndpoint(); + + /** + * Sets the WSDL port + * @param port the WSDL port + */ + void setPort(Port port); + + /** + * Returns the WSDL binding. + * @return the WSDL binding + */ + javax.wsdl.Binding getBinding(); + + /** + * Sets the WSDL binding + * @param binding the WSDL binding + */ + void setBinding(javax.wsdl.Binding binding); + + /** + * Returns the WSDL definition. + * @return the WSDL definition + */ + WSDLDefinition getWSDLDefinition(); + + /** + * Sets the WSDL definition. + * @param wsdlDefinition the WSDL definition + */ + void setDefinition(WSDLDefinition wsdlDefinition); + + /** + * Returns the WSDL namespace. + * @return the WSDL namespace + */ + String getNamespace(); + + /** + * Sets the WSDL namespace + * @param namespace the WSDL namespace + */ + void setNamespace(String namespace); + + /** + * Returns true if the model element is unresolved. + * + * @return true if the model element is unresolved. + */ + boolean isUnresolved(); + + /** + * Sets whether the model element is unresolved. + * + * @param unresolved whether the model element is unresolved + */ + void setUnresolved(boolean unresolved); + + InterfaceContract getBindingInterfaceContract(); + + void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract); + + Element getEndPointReference(); + + void setEndPointReference(Element element); + + /** + * Returns the generated WSDL definitions document. + * @return the generated WSDL definitions document + */ + Definition getWSDLDocument(); + + /** + * Sets the generated WSDL definitions document. + * @param definition the generated WSDL definitions document + */ + void setWSDLDocument(Definition definition); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java new file mode 100644 index 0000000000..1ad38c69e4 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.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.binding.ws; + +/** + * Factory for the Web Service binding model. + * + * @version $Rev$ $Date$ + */ +public interface WebServiceBindingFactory { + + /** + * Creates a new WebService binding. + * + * @return a new WebService binding + */ + WebServiceBinding createWebServiceBinding(); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java new file mode 100644 index 0000000000..a13584a3c2 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java @@ -0,0 +1,62 @@ +/* + * 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.binding.ws.addressing; + +import java.net.URI; +import java.util.List; + +import javax.xml.namespace.QName; + +/** + * Defines a model for WS-Addressing + * <wsa:EndpointReference> + * <wsa:Address>xs:anyURI</wsa:Address> + * <wsa:ReferenceProperties>... </wsa:ReferenceProperties> ? + * <wsa:ReferenceParameters>... </wsa:ReferenceParameters> ? + * <wsa:PortType>xs:QName</wsa:PortType> ? + * <wsa:ServiceName PortName="xs:NCName"?>xs:QName</wsa:ServiceName> ? + * <wsp:Policy> ... </wsp:Policy>* + * </wsa:EndpointReference> + * @version $Rev$ $Date$ + */ +public interface EndPointReference { + URI getAddress(); + + void setAddress(URI address); + + QName getPortType(); + + void setPortType(QName portType); + + QName getServiceName(); + + void setServiceName(QName serviceName); + + QName getPortName(); + + void setPortName(QName portName); + + List<Object> getReferenceProperties(); + + List<Object> getReferenceParameters(); + + List<Object> getPolicies(); + +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java new file mode 100644 index 0000000000..055e2012dc --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.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.binding.ws.impl; + +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; + +/** + * A factory for the WSDL model. + * + * @version $Rev$ $Date$ + */ +public class WebServiceBindingFactoryImpl implements WebServiceBindingFactory { + + public WebServiceBinding createWebServiceBinding() { + return new WebServiceBindingImpl(); + } + +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java new file mode 100644 index 0000000000..d816c2c9c6 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java @@ -0,0 +1,316 @@ +/* + * 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.binding.ws.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.wsdl.Binding; +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.OperationsConfigurator; +import org.apache.tuscany.sca.assembly.builder.BindingBuilder; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.w3c.dom.Element; + +/** + * Represents a WebService binding. + * + * @version $Rev$ $Date$ + */ +class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint, Extensible, OperationsConfigurator { + private String name; + private String uri; + private boolean unresolved; + private List<Object> extensions = new ArrayList<Object>(); + private List<Intent> requiredIntents = new ArrayList<Intent>(); + private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private IntentAttachPointType intentAttachPointType; + private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>(); + private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); + private String location; + private Binding binding; + private Service service; + private Port port; + private Port endpoint; + private QName bindingName; + private String portName; + private QName serviceName; + private String endpointName; + private WSDLDefinition wsdlDefinition; + private String wsdlNamespace; + private InterfaceContract bindingInterfaceContract; + private Element endPointReference; + private Definition generatedWSDLDocument; + private BindingBuilder builder; + + protected WebServiceBindingImpl() { + } + + public String getName() { + return name; + } + + public String getURI() { + return uri; + } + + public void setName(String name) { + this.name = name; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public List<Object> getExtensions() { + return extensions; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Binding getBinding() { + if (binding == null) { + if (getWSDLDefinition() != null && wsdlDefinition.getBinding() != null) { + binding = wsdlDefinition.getBinding(); + } + } + return binding; + } + + public QName getBindingName() { + if (isUnresolved()) { + return bindingName; + } else if (binding != null) { + return binding.getQName(); + } else { + return null; + } + } + + public String getEndpointName() { + if (isUnresolved()) { + return endpointName; + } else if (endpoint != null) { + //TODO support WSDL 2.0 + return endpoint.getName(); + } else { + return null; + } + } + + public Port getEndpoint() { + return endpoint; + } + + public Port getPort() { + return port; + } + + public String getPortName() { + if (isUnresolved()) { + return portName; + } else if (port != null) { + return port.getName(); + } else { + return null; + } + } + + public Service getService() { + return service; + } + + public QName getServiceName() { + if (isUnresolved()) { + return serviceName; + } else if (service != null) { + return service.getQName(); + } else { + return null; + } + } + + public void setBinding(Binding binding) { + this.binding = binding; + } + + public void setBindingName(QName bindingName) { + if (!isUnresolved()) { + throw new IllegalStateException(); + } + this.bindingName = bindingName; + } + + public void setEndpoint(Port endpoint) { + this.endpoint = endpoint; + } + + public void setEndpointName(String endpointName) { + if (!isUnresolved()) { + throw new IllegalStateException(); + } + this.endpointName = endpointName; + } + + public void setPort(Port port) { + this.port = port; + } + + public void setPortName(String portName) { + if (!isUnresolved()) { + throw new IllegalStateException(); + } + this.portName = portName; + } + + public void setService(Service service) { + this.service = service; + } + + public void setServiceName(QName serviceName) { + if (!isUnresolved()) { + throw new IllegalStateException(); + } + this.serviceName = serviceName; + } + + public WSDLDefinition getWSDLDefinition() { + if (wsdlDefinition == null) { + Interface iface = bindingInterfaceContract.getInterface(); + if (iface instanceof WSDLInterface) { + wsdlDefinition = ((WSDLInterface) iface).getWsdlDefinition(); + } + } + return wsdlDefinition; + } + + public void setDefinition(WSDLDefinition wsdlDefinition) { + this.wsdlDefinition = wsdlDefinition; + } + + public String getNamespace() { + return wsdlNamespace; + } + + public void setNamespace(String namespace) { + this.wsdlNamespace = namespace; + } + + public InterfaceContract getBindingInterfaceContract() { + return bindingInterfaceContract; + } + + public void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract) { + this.bindingInterfaceContract = bindingInterfaceContract; + } + + public List<PolicySet> getPolicySets() { + return policySets; + } + + public List<Intent> getRequiredIntents() { + return requiredIntents; + } + + public IntentAttachPointType getType() { + return intentAttachPointType; + } + + public void setType(IntentAttachPointType intentAttachPointType) { + this.intentAttachPointType = intentAttachPointType; + } + + public Element getEndPointReference() { + return endPointReference; + } + + public void setEndPointReference(Element epr) { + this.endPointReference = epr; + } + + public Definition getWSDLDocument() { + return generatedWSDLDocument; + } + + public void setWSDLDocument(Definition definition) { + this.generatedWSDLDocument = definition; + } + + public BindingBuilder getBuilder() { + return builder; + } + + public void setBuilder(BindingBuilder builder) { + this.builder = builder; + } + + public void setPolicySets(List<PolicySet> policySets) { + this.policySets = policySets; + } + + public void setRequiredIntents(List<Intent> intents) { + this.requiredIntents = intents; + } + + public List<ConfiguredOperation> getConfiguredOperations() { + return configuredOperations; + } + + public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) { + this.configuredOperations = configuredOperations; + } + + public List<PolicySet> getApplicablePolicySets() { + return applicablePolicySets; + } +} diff --git a/branches/sca-java-1.4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory b/branches/sca-java-1.4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory new file mode 100644 index 0000000000..6d50a24b93 --- /dev/null +++ b/branches/sca-java-1.4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the model factory +org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingFactoryImpl
\ No newline at end of file |