diff options
Diffstat (limited to '')
47 files changed, 5408 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/LICENSE b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..cfa5f0fd2b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF @@ -0,0 +1,134 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ws.axis2;version="2.0.0";
+ uses:="org.apache.axis2.deployment.util,
+ org.apache.tuscany.sca.definitions,
+ org.apache.ws.security.handler,
+ javax.xml.namespace,
+ org.apache.axiom.om,
+ org.xml.sax,
+ org.apache.commons.httpclient,
+ org.apache.axiom.soap,
+ org.apache.axis2.util,
+ javax.servlet,
+ javax.xml.stream,
+ org.apache.tuscany.sca.core.assembly,
+ org.apache.axis2.transport.http.server,
+ org.oasisopen.sca,
+ org.apache.axis2.i18n,
+ org.apache.axis2.transport,
+ org.apache.axis2.client,
+ org.apache.axis2.context,
+ org.apache.axiom.om.impl.builder,
+ org.apache.tuscany.sca.interfacedef.java,
+ org.w3c.dom,
+ javax.wsdl,
+ org.apache.tuscany.sca.xsd.xml,
+ org.apache.tuscany.sca.binding.ws,
+ org.apache.axis2.engine,
+ org.apache.axis2.receivers,
+ org.apache.commons.httpclient.params,
+ org.apache.tuscany.sca.interfacedef.wsdl,
+ org.apache.tuscany.sca.xsd,
+ org.apache.tuscany.sca.databinding,
+ org.apache.axis2.addressing,
+ org.apache.axis2.deployment,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.transport.local,
+ org.apache.tuscany.sca.runtime,
+ org.apache.commons.logging,
+ org.apache.tuscany.sca.interfacedef.util,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,
+ javax.xml.transform.dom,
+ org.apache.tuscany.sca.policy,
+ org.apache.axis2.description,
+ javax.wsdl.extensions,
+ org.apache.tuscany.sca.host.http,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.axis2.util.threadpool,
+ org.apache.ws.security,
+ org.apache.axis2,
+ org.apache.ws.commons.schema,
+ org.apache.tuscany.sca.assembly,
+ org.apache.ws.commons.schema.resolver,
+ javax.wsdl.extensions.soap,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.invocation,
+ javax.xml.transform,
+ javax.wsdl.extensions.soap12,
+ org.apache.tuscany.sca.contribution.processor,
+ javax.servlet.http"
+Private-Package:
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Axis2-based WS Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Axis2-based WS Binding Extension
+Eclipse-RegisterBuddy: org.apache.axis2.kernel
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform.dom,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.soap,
+ org.apache.axiom.util.base64,
+ org.apache.axis2,
+ org.apache.axis2.addressing,
+ org.apache.axis2.addressing.wsdl,
+ org.apache.axis2.client,
+ org.apache.axis2.context,
+ org.apache.axis2.deployment,
+ org.apache.axis2.deployment.util,
+ org.apache.axis2.description,
+ org.apache.axis2.engine,
+ org.apache.axis2.handlers,
+ org.apache.axis2.receivers,
+ org.apache.axis2.transport,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.util.threadpool,
+ org.apache.commons.httpclient,
+ org.apache.commons.httpclient.params,
+ org.apache.commons.logging;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.policy.security.http.ssl;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.axis2
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ JavaSE-1.6
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/NOTICE b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/NOTICE new file mode 100644 index 0000000000..ad2ba40961 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2010 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/pom.xml b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/pom.xml new file mode 100644 index 0000000000..357fd5c30d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/pom.xml @@ -0,0 +1,187 @@ +<?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>2.0-Beta2-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-binding-ws-runtime-axis2</artifactId> + <name>Apache Tuscany SCA Axis2-1.5-based WS Binding Runtime</name> + + + <dependencies> + <!-- Compile dependencies --> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-runtime-pom</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <type>pom</type> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-policy-security</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <scope>provided</scope> <!-- it's in base --> + </dependency> + + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>org.apache.axis2.osgi</artifactId> + <version>1.5.3</version> + <exclusions> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-kernel</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-http</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-local</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-api</artifactId> + <version>1.2.10</version> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-activation_1.1_spec</artifactId> + </exclusion> + <!-- exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-javamail_1.4_spec</artifactId> + </exclusion --> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> + <exclusion> + <groupId>jaxen</groupId> + <artifactId>jaxen</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-impl</artifactId> + <version>1.2.10</version> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-activation_1.1_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-javamail_1.4_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</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>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + + <!-- Runtime dependencies --> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-axiom</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-jaxb-axiom</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <!-- Test dependencies --> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime-pom</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <type>pom</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>2.0-Beta2-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java new file mode 100644 index 0000000000..699846ead2 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.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.axis2.policy.authentication.basic; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * @version $Rev$ $Date$ + */ +public class BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> { + private ExtensionPointRegistry registry; + + public BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { + return null; + } + + public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { + return new BasicAuthenticationReferencePolicyProvider(endpointReference); + } + + public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { + return new BasicAuthenticationServicePolicyProvider(endpoint); + } + + public Class<BasicAuthenticationPolicy> getModelType() { + return BasicAuthenticationPolicy.class; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java new file mode 100644 index 0000000000..04b46485d8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java @@ -0,0 +1,129 @@ +/* + * 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.basic; + +import java.util.ArrayList; +import java.util.List; + +import javax.security.auth.Subject; +import javax.xml.namespace.QName; + +import org.apache.axis2.client.OperationClient; +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.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicyExpression; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; +import org.apache.tuscany.sca.policy.security.SecurityUtil; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * + * @version $Rev$ $Date$ + */ +public class BasicAuthenticationReferencePolicyInterceptor implements PhasedInterceptor { + private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); + + private Invoker next; + private PolicySet policySet = null; + private String context; + private BasicAuthenticationPolicy policy; + + public BasicAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet) { + super(); + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + // TODO - how to get the appropriate expression out of the + // policy set. Need WS Policy help here + if (policySet != null) { + for (PolicyExpression policyExpression : policySet.getPolicies()){ + if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){ + policy = (BasicAuthenticationPolicy)policyExpression.getPolicy(); + break; + } + } + } + } + + public Message invoke(Message msg) { + + OperationClient operationClient = msg.getBindingContext(); + + 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(); + } else if (policy != null ){ + username = policy.getUserName(); + password = policy.getPassword(); + + principal = new BasicAuthenticationPrincipal(username, + password); + subject.getPrincipals().add(principal); + } + + if (username == null || password == null ){ + throw new ServiceRuntimeException("Basic authentication username and/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); + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } + + public String getPhase() { + return Phase.REFERENCE_BINDING_POLICY; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java new file mode 100644 index 0000000000..d4b3851d97 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java @@ -0,0 +1,48 @@ +/* + * 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.basic; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.provider.BasePolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class BasicAuthenticationReferencePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> { + + public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) { + super(BasicAuthenticationPolicy.class, endpointReference); + } + + public PhasedInterceptor createBindingInterceptor() { + PolicySet ps = findPolicySet(); + return ps == null ? null : new BasicAuthenticationReferencePolicyInterceptor(getContext(), ps); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java new file mode 100644 index 0000000000..5365754fb3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java @@ -0,0 +1,123 @@ +/* + * 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.basic; + + +import java.util.Map; + +import javax.security.auth.Subject; +import javax.xml.namespace.QName; + +import org.apache.axiom.util.base64.Base64Utils; +import org.apache.axis2.context.MessageContext; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicyExpression; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; +import org.apache.tuscany.sca.policy.security.SecurityUtil; + + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class BasicAuthenticationServicePolicyInterceptor implements PhasedInterceptor { + private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); + + private Invoker next; + private PolicySet policySet = null; + private String context; + private BasicAuthenticationPolicy policy; + + public BasicAuthenticationServicePolicyInterceptor(String context, PolicySet policySet) { + super(); + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + // TODO - how to get the appropriate expression out of the + // policy set. Need WS Policy help here + if (policySet != null) { + for (PolicyExpression policyExpression : policySet.getPolicies()){ + if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){ + policy = (BasicAuthenticationPolicy)policyExpression.getPolicy(); + break; + } + } + } + } + + public Message invoke(Message msg) { + + MessageContext messageContext = msg.getBindingContext(); + 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(Base64Utils.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); + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } + + public String getPhase() { + return Phase.SERVICE_BINDING_POLICY; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java new file mode 100644 index 0000000000..ec4536c309 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.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.policy.authentication.basic; + + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.provider.BasePolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class BasicAuthenticationServicePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> { + + public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) { + super(BasicAuthenticationPolicy.class, endpoint); + } + + public PhasedInterceptor createBindingInterceptor() { + PolicySet ps = findPolicySet(); + return ps == null ? null : new BasicAuthenticationServicePolicyInterceptor(getContext(), ps); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java new file mode 100644 index 0000000000..ded09392ec --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicy { + private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + public static final QName NAME = new QName(SCA11_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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java new file mode 100644 index 0000000000..c13c009edf --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java @@ -0,0 +1,156 @@ +/* + * 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.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; + +/** + * + * @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(FactoryExtensionPoint modelFactories) { + } + + public Axis2ConfigParamPolicy read(XMLStreamReader reader, ProcessorContext context) 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, "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, ProcessorContext context) throws ContributionWriteException, + XMLStreamException { + } + + public Class<Axis2ConfigParamPolicy> getModelType() { + return Axis2ConfigParamPolicy.class; + } + + public void resolve(Axis2ConfigParamPolicy arg0, ModelResolver arg1, ProcessorContext context) 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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java new file mode 100644 index 0000000000..a77f71b734 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.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 org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.Parameter; +import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider; +import org.apache.tuscany.sca.policy.PolicySubject; +import org.apache.tuscany.sca.provider.BasePolicyProvider; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicyProvider extends BasePolicyProvider<Axis2ConfigParamPolicy> { + + public Axis2ConfigParamPolicyProvider(PolicySubject subject) { + super(Axis2ConfigParamPolicy.class, subject); + } + + public void configureBinding(Object context) { + ConfigurationContext configurationContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext(); + Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; + Parameter configParam = null; + for (Object policy : findPolicies()) { + 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 { + configurationContext.getAxisConfiguration().addParameter(configParam); + } catch (AxisFault e) { + throw new ServiceRuntimeException(e); + } + } + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java new file mode 100644 index 0000000000..c4c93cd33d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.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 org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +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; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2ConfigParamPolicyProviderFactory implements PolicyProviderFactory<Axis2ConfigParamPolicy> { + + public Axis2ConfigParamPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { + return null; + } + + public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { + return new Axis2ConfigParamPolicyProvider(endpointReference); + } + + public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { + return new Axis2ConfigParamPolicyProvider(endpoint); + } + + public Class<Axis2ConfigParamPolicy> getModelType() { + return Axis2ConfigParamPolicy.class; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java new file mode 100644 index 0000000000..e27da2bbd1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.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.axis2.policy.mtom; + +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.tuscany.sca.policy.PolicySubject; +import org.apache.tuscany.sca.provider.BasePolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2MTOMPolicyProvider extends BasePolicyProvider<Object> { + + public Axis2MTOMPolicyProvider(PolicySubject subject) { + super(Object.class, subject); + } + + public void configureBinding(Object configuration) { + + if (configuration instanceof ConfigurationContext){ + ConfigurationContext configurationContext = (ConfigurationContext)configuration; + configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false); + configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true"); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java new file mode 100644 index 0000000000..8355c0fa4e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.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.policy.security.http.ssl; + +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider; +import org.apache.tuscany.sca.host.http.SecurityContext; +import org.apache.tuscany.sca.policy.PolicySubject; +import org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy; +import org.apache.tuscany.sca.provider.BasePolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class HTTPSPolicyProvider extends BasePolicyProvider<HTTPSPolicy> { + private final Logger logger = Logger.getLogger(HTTPSPolicyProvider.class.getName()); + + public HTTPSPolicyProvider(PolicySubject subject) { + super(HTTPSPolicy.class, subject); + } + + public void configureBinding(Object context) { + SecurityContext securityContext = ((Axis2BaseBindingProvider)context).getHttpSecurityContext(); + + for (Object policy : findPolicies()) { + if (policy instanceof HTTPSPolicy) { + HTTPSPolicy httpsPolicy = (HTTPSPolicy)policy; + + securityContext.setSSLEnabled(true); + securityContext.setSSLProperties(httpsPolicy.toProperties()); + + // TODO - what is the right way to set trust/key store on client side? + + logger.info("HTTPSPolicyProvider: Setting JVM trust store to " + httpsPolicy.getTrustStore()); + System.setProperty("javax.net.ssl.trustStore", httpsPolicy.getTrustStore()); + System.setProperty("javax.net.ssl.trustStorePassword", httpsPolicy.getTrustStorePassword()); + System.setProperty("javax.net.ssl.trustStoreType", httpsPolicy.getTrustStoreType()); + + logger.info("HTTPSPolicyProvider: Setting JVM key store to " + httpsPolicy.getKeyStore()); + System.setProperty("javax.net.ssl.keyStore", httpsPolicy.getKeyStore()); + System.setProperty("javax.net.ssl.keyStorePassword", httpsPolicy.getKeyStorePassword()); + System.setProperty("javax.net.ssl.keyStoreType", httpsPolicy.getKeyStoreType()); + + return; + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java new file mode 100644 index 0000000000..592300aaa3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.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.axis2.policy.security.http.ssl; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * @version $Rev$ $Date$ + */ +public class HTTPSPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> { + private ExtensionPointRegistry registry; + + public HTTPSPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { + return null; + } + + public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { + return new HTTPSPolicyProvider(endpointReference); + } + + public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { + return new HTTPSPolicyProvider(endpoint); + } + + public Class<BasicAuthenticationPolicy> getModelType() { + return BasicAuthenticationPolicy.class; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java new file mode 100644 index 0000000000..dbefbf4a2d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.provider; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.host.http.SecurityContext; +import org.apache.tuscany.sca.invocation.MessageFactory; + +public class Axis2BaseBindingProvider { + + // Tuscany extensions + protected ExtensionPointRegistry extensionPoints; + protected FactoryExtensionPoint modelFactories; + protected MessageFactory messageFactory; + + // derived policy configuration + protected boolean isSOAP12Required = false; + protected boolean isSOAP11Required = false; + protected boolean isRampartRequired = false; + protected boolean isMTOMRequired = false; + protected boolean isJMSRequired = false; + + // The Axis2 configuration that the binding creates + protected ConfigurationContext configContext; + protected SecurityContext httpSecurityContext; + + public Axis2BaseBindingProvider(ExtensionPointRegistry extensionPoints) { + + this.extensionPoints = extensionPoints; + + this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); + this.messageFactory = modelFactories.getFactory(MessageFactory.class); + + this.httpSecurityContext = new SecurityContext(); + } + + public ConfigurationContext getAxisConfigurationContext() { + return configContext; + } + + public SecurityContext getHttpSecurityContext() { + return httpSecurityContext; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java new file mode 100644 index 0000000000..bd9b177c39 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.provider; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.host.http.ServletHostHelper; +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.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; + +/** + * Axis2BindingProviderFactory + * + * @version $Rev$ $Date$ + */ + +public class Axis2BindingProviderFactory implements BindingProviderFactory<WebServiceBinding> { + + public static final QName MTOM_INTENT = new QName(Constants.SCA11_TUSCANY_NS, "MTOM"); + + private ExtensionPointRegistry extensionPoints; + private ServletHost servletHost; + + public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + this.servletHost = ServletHostHelper.getServletHost(extensionPoints); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { + return new Axis2ReferenceBindingProvider(extensionPoints, endpointReference); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { + return new Axis2ServiceBindingProvider(extensionPoints, endpoint, servletHost); + } + + public Class<WebServiceBinding> getModelType() { + return WebServiceBinding.class; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java new file mode 100644 index 0000000000..9827f62abb --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java @@ -0,0 +1,538 @@ +/* + * 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.provider; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +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 javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.stream.XMLInputFactory; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.addressing.AddressingConstants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.deployment.URLBasedAxisConfigurator; +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.WSDL11ToAxisServiceBuilder; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.description.WSDLToAxisServiceBuilder; +import org.apache.axis2.engine.MessageReceiver; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.common.xml.XMLDocumentHelper; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.extensibility.ClassLoaderContext; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; +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.runtime.RuntimeEndpoint; +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.commons.schema.resolver.URIResolver; +import org.oasisopen.sca.ServiceRuntimeException; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + + +public class Axis2EngineIntegration { + + //========================================================= + // most of the following is related to rewriting WSDL imports + // I'd like to move this but don't know where to yet. + + public static final String IMPORT_TAG = "import"; + public static final String INCLUDE_TAG = "include"; + + 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); + + //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}); + + //========================================================= + + /* + * Create the whole configuration context for the Axis engine + */ + private static class Axis2Config { + private ClassLoaderContext classLoaderContext; + private URL axis2xmlURL; + private URL repositoryURL; + } + + // Cache the discovered axis2 configuration but we need to create a new instance of ConfigurationContext every time + private static Axis2Config axis2Config; + + public synchronized static ConfigurationContext getAxisConfigurationContext(final ServiceDiscovery serviceDiscovery) { + + // get the axis configuration context from the Tuscany axis2.xml file + // Allow privileged access to read properties. Requires PropertyPermission read in + // security policy. + if (axis2Config == null) { + try { + axis2Config = AccessController.doPrivileged(new PrivilegedExceptionAction<Axis2Config>() { + public Axis2Config run() throws AxisFault, MalformedURLException { + // collect together the classloaders that Axis2 requireds in order to load + // pluggable items such as the Tuscany MessageReceivers and the xerces + // document builder. + ClassLoader wsBindingCL = getClass().getClassLoader(); + ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader(); + ClassLoaderContext classLoaderContext = + new ClassLoaderContext(wsBindingCL, axis2CL); + + classLoaderContext = + new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery, + XMLInputFactory.class, DocumentBuilderFactory.class); + + URL axis2xmlURL = + wsBindingCL + .getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml"); + if (axis2xmlURL != null) { + URL repositoryURL = new URL(axis2xmlURL, "../repository/"); + Axis2Config config = new Axis2Config(); + config.classLoaderContext = classLoaderContext; + config.axis2xmlURL = axis2xmlURL; + config.repositoryURL = repositoryURL; + return config; + } else { + return null; + } + } + }); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } + } + + if (axis2Config == null) { + return null; + } + + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() { + public ConfigurationContext run() throws AxisFault { + ClassLoader oldTCCL = axis2Config.classLoaderContext.setContextClassLoader(); + try { + ConfigurationContext configurationContext = + ConfigurationContextFactory.createConfigurationContextFromURIs(axis2Config.axis2xmlURL, + axis2Config.repositoryURL); + return configurationContext; + } finally { + if (oldTCCL != null) { + Thread.currentThread().setContextClassLoader(oldTCCL); + } + } + } + }); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } + + } + + //========================================================= + + /** + * Create an AxisService from the Java interface class of the SCA service interface + */ + public static AxisService createJavaAxisService(String endpointURL, + ConfigurationContext configContext, + AbstractContract contract) 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; + } + + //========================================================= + + /** + * Create an AxisService from the WSDL doc used by ws binding + */ + public static AxisService createWSDLAxisService(String endpointURL, + Port port, + WebServiceBinding wsBinding) throws AxisFault { + + Definition definition = wsBinding.getGeneratedWSDLDocument(); + 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 + // TODO - 228 is resolved, is this still required + 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); + + // TODO - again, do we ever have more than one endpoint + // on the service side? + for (Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext();) { + AxisEndpoint ae = (AxisEndpoint)i.next(); + if (endpointURL.startsWith("jms")) { +// not in Axis2 1.5.1 +// 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.getUserSpecifiedWSDLDefinition(), axisService); + + // Use the existing WSDL + Parameter wsdlParam = new Parameter("wsdl4jDefinition", 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; + } + + + /** + * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 + */ + 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; + } + + private static 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 static 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 static 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 static 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 static 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); + } + } + } + } + + //========================================================= + + /* + * Create the service message receivers and the service provider that will push + * messages out onto the binding wire + */ + public static void createAxisServiceProviders(AxisService axisService, + RuntimeEndpoint endpoint, + WebServiceBinding wsBinding, + ExtensionPointRegistry extensionPoints) { + for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { + AxisOperation axisOp = (AxisOperation)i.next(); + Operation op = getOperation(axisOp, wsBinding); + if (op != null) { + + if (op.isNonBlocking()) { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY); + } else { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT); + } + + MessageReceiver msgrec = null; + TuscanyServiceProvider serviceProvider = new TuscanyServiceProvider(extensionPoints, endpoint, wsBinding, op); + if (op.isNonBlocking()) { + msgrec = new Axis2ServiceInMessageReceiver(serviceProvider); + } else { + msgrec = new Axis2ServiceInOutSyncMessageReceiver(serviceProvider); + } + axisOp.setMessageReceiver(msgrec); + } + } + } + + private static Operation getOperation(AxisOperation axisOp,WebServiceBinding wsBinding) { + String operationName = axisOp.getName().getLocalPart(); + Interface iface = wsBinding.getBindingInterfaceContract().getInterface(); + for (Operation op : iface.getOperations()) { + if (op.getName().equalsIgnoreCase(operationName)) { + return op; + } + } + return null; + } + + //========================================================= + + public 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; + } + + public 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); + } + } + + /** + * 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; + } + + /** + * 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; + } + } + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java new file mode 100644 index 0000000000..32f6ee9ca5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java @@ -0,0 +1,380 @@ +/* + * 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.provider; + +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.wsdl.BindingOperation; +import javax.wsdl.Operation; +import javax.wsdl.PortType; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNode; +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.addressing.wsdl.WSDL11ActionHelper; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.context.MessageContext; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.oasisopen.sca.ServiceRuntimeException; + + +/** + * Axis2BindingInvoker creates an Axis2 OperationClient to pass down the + * binding chain + * + * @version $Rev$ $Date$ + */ +public class Axis2ReferenceBindingInvoker implements Invoker { + public static final QName QNAME_WSA_FROM = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM, AddressingConstants.WSA_DEFAULT_PREFIX); + public static final QName QNAME_WSA_TO = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_TO, AddressingConstants.WSA_DEFAULT_PREFIX); + public static final QName QNAME_WSA_ACTION = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_ACTION, AddressingConstants.WSA_DEFAULT_PREFIX); + public static final QName QNAME_WSA_RELATESTO = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_RELATES_TO, AddressingConstants.WSA_DEFAULT_PREFIX); + public static final QName QNAME_WSA_MESSAGEID = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_MESSAGE_ID, AddressingConstants.WSA_DEFAULT_PREFIX); + + + private RuntimeEndpointReference endpointReference; + private ServiceClient serviceClient; + private QName wsdlOperationName; + private Options options; + private SOAPFactory soapFactory; + private WebServiceBinding wsBinding; + + public Axis2ReferenceBindingInvoker(RuntimeEndpointReference endpointReference, + ServiceClient serviceClient, + QName wsdlOperationName, + Options options, + SOAPFactory soapFactory, + WebServiceBinding wsBinding) { + this.endpointReference = endpointReference; + this.serviceClient = serviceClient; + this.wsdlOperationName = wsdlOperationName; + this.options = options; + this.soapFactory = soapFactory; + this.wsBinding = wsBinding; + } + + public Message invoke(Message msg) { + try { + final OperationClient operationClient = createOperationClient(msg); + msg.setBindingContext(operationClient); + msg = endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(msg); + + if (wsBinding.isRpcLiteral()){ + // remove the wrapping element containing + // the operation response name + OMElement operationResponseElement = msg.getBody(); + if (operationResponseElement != null){ + msg.setBody(operationResponseElement.getChildElements().next()); + } + } + + } 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; + } + + @SuppressWarnings("deprecation") + protected OperationClient createOperationClient(Message msg) throws AxisFault { + SOAPEnvelope env = soapFactory.getDefaultEnvelope(); + Object[] args = (Object[])msg.getBody(); + if (args != null && args.length > 0) { + + if (wsBinding.isRpcLiteral()){ + // create the wrapping element containing + // the operation name + OMFactory factory = OMAbstractFactory.getOMFactory(); + String wrapperNamespace = null; + + // the rpc style creates a wrapper with a namespace where the namespace is + // defined on the wsdl binding operation. If no binding is provided by the + // user then default to the namespace of the WSDL itself. + if (wsBinding.getBinding() != null){ + Iterator iter = wsBinding.getBinding().getBindingOperations().iterator(); + loopend: + while(iter.hasNext()){ + BindingOperation bOp = (BindingOperation)iter.next(); + if (bOp.getName().equals(msg.getOperation().getName())){ + for (Object ext : bOp.getBindingInput().getExtensibilityElements()){ + if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){ + wrapperNamespace = ((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI(); + break loopend; + } + } + } + } + } + + if (wrapperNamespace == null){ + wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace(); + } + + QName operationQName = new QName(wrapperNamespace, + msg.getOperation().getName()); + OMElement operationNameElement = factory.createOMElement(operationQName); + + // add the parameters as children of the operation name element + for (Object bc : args) { + if (bc instanceof OMElement) { + operationNameElement.addChild((OMElement)bc); + } else { + throw new IllegalArgumentException( "Can't handle mixed payloads between OMElements and other types for endpoint reference " + endpointReference); + } + } + + SOAPBody body = env.getBody(); + body.addChild(operationNameElement); + + } else if (wsBinding.isRpcEncoded()){ + throw new ServiceRuntimeException("rpc/encoded WSDL style not supported for endpoint reference " + endpointReference); + } else if (wsBinding.isDocEncoded()){ + throw new ServiceRuntimeException("doc/encoded WSDL style not supported for endpoint reference " + endpointReference); + // } else if (wsBinding.isDocLiteralUnwrapped()){ + // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint reference " + endpointReference); + } else if (wsBinding.isDocLiteralWrapped() || + wsBinding.isDocLiteralUnwrapped()){ + // it's doc/lit + 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 for endpoint reference " + endpointReference); + } + } + } else { + throw new ServiceRuntimeException("Unrecognized WSDL style for endpoint reference " + endpointReference); + } + } + + 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.createClient(wsdlOperationName); + operationClient.setOptions(options); + + Endpoint callbackEndpoint = msg.getFrom().getCallbackEndpoint(); + + SOAPEnvelope sev = requestMC.getEnvelope(); + SOAPHeader sh = sev.getHeader(); + + // Add WS-Addressing header for the invocation of a bidirectional service + if (callbackEndpoint != null) { + // Load the actual callback endpoint URI into an Axis EPR ready to form the content of the wsa:From header + EndpointReference fromEPR = new EndpointReference(callbackEndpoint.getBinding().getURI()); + + addWSAFromHeader( sh, fromEPR ); + addWSAActionHeader( sh ); + addWSAMessageIDHeader( sh, (String)msg.getHeaders().get("MESSAGE_ID")); + + requestMC.setFrom(fromEPR); + } // end if + + String toAddress = getToAddress( msg ); + requestMC.setTo( new EndpointReference(toAddress) ); + + // For callback references, add wsa:To, wsa:Action and wsa:RelatesTo headers + if( isInvocationForCallback( msg ) ) { + addWSAToHeader( sh, toAddress, msg ); + addWSAActionHeader( sh ); + addWSARelatesTo( sh, msg ); + } // end if + + // 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; + } // end method createOperationClient + + private String getToAddress( Message msg ) throws ServiceRuntimeException { + String address = null; + + // if target endpoint was not specified when this invoker was created, + // use dynamically specified target endpoint passed in with the message + if (options.getTo() == null) { + Endpoint ep = msg.getTo(); + if (ep != null && ep.getBinding() != null) { + address = ep.getBinding().getURI(); + } else { + throw new ServiceRuntimeException("[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference); + } + } else { + address = options.getTo().getAddress(); + } + + return address; + } // end method getToAddress + + /** + * Add wsa:From SOAP header to the message + * @param sh - the SOAP header for the message + * @param fromEPR - the (Axis2) EPR to include in the wsa:From + * @throws AxisFault - if an error occurs setting the wsa:From into the header + */ + private void addWSAFromHeader( SOAPHeader sh, EndpointReference fromEPR ) throws AxisFault { + OMElement epr = EndpointReferenceHelper.toOM(sh.getOMFactory(), + fromEPR, + QNAME_WSA_FROM, + AddressingConstants.Final.WSA_NAMESPACE); + sh.addChild(epr); + + } // end method addWSAFromHeader + + /** + * Add wsa:MessageID SOAP header to the message + * @param sh - the SOAP header for the message + * @param msgID - the message ID + * @throws AxisFault - if an error occurs setting the wsa:From into the header + */ + private void addWSAMessageIDHeader( SOAPHeader sh, String msgID ) throws AxisFault { + OMElement idHeader = sh.getOMFactory().createOMElement(QNAME_WSA_MESSAGEID); + idHeader.setText( msgID ); + + sh.addChild(idHeader); + + } // end method addWSAMessageIDHeader + + private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS"; + /** + * Add wsa:To SOAP header to the message - also handles ReferenceParameters, if present + * @param sh - the SOAP header for the message + * @param address - the address to use + * @param msg - the Tuscany message + */ + private void addWSAToHeader( SOAPHeader sh, String address, Message msg ) { + if( address == null ) return; + + // Create wsa:To header which is required by ws-addressing spec + OMElement wsaToOM = sh.getOMFactory().createOMElement(QNAME_WSA_TO); + wsaToOM.setText( address ); + sh.addChild(wsaToOM); + + if( msg == null ) return; + + // Deal with Reference Parameters, if present - copy to the header without the wsa:ReferenceParameters wrapper + OMElement refParms = (OMElement) msg.getHeaders().get(WS_REF_PARMS); + if( refParms != null ) { + Iterator<?> children = refParms.getChildren(); + while( children.hasNext() ) { + OMNode node = (OMNode) children.next(); + sh.addChild(node); + } + } // end if + + } // end method addWSAActionHeader + + + private void addWSAActionHeader( SOAPHeader sh ) { + // Create wsa:Action header which is required by ws-addressing spec + String action = options.getAction(); + + if (action == null) { + PortType portType = ((WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface()).getPortType(); + Operation op = portType.getOperation(wsdlOperationName.getLocalPart(), null, null); + action = WSDL11ActionHelper.getActionFromInputElement(wsBinding.getGeneratedWSDLDocument(), portType, op, op.getInput()); + } + + OMElement actionOM = sh.getOMFactory().createOMElement(QNAME_WSA_ACTION); + actionOM.setText(action == null ? "" : action); + sh.addChild(actionOM); + } // end method addWSAActionHeader + + private static String WS_MESSAGE_ID = "WS_MESSAGE_ID"; + protected static String SCA_CALLBACK_REL = "http://docs.oasis-open.org/opencsa/sca-bindings/ws/callback"; + /** + * Adds a wsa:RelatesTo SOAP header if the incoming invocation had a wsa:MessageID SOAP header present + * - note that OASIS SCA requires that the RelationshipType attribute is set to a particular SCA value + * @param sh - the SOAP headers + * @param msg - the message + */ + private void addWSARelatesTo( SOAPHeader sh, Message msg ) { + String idValue = (String) msg.getHeaders().get(WS_MESSAGE_ID); + if( idValue != null ){ + OMElement relatesToOM = sh.getOMFactory().createOMElement( QNAME_WSA_RELATESTO ); + OMAttribute relType = sh.getOMFactory().createOMAttribute("RelationshipType", null, SCA_CALLBACK_REL); + relatesToOM.addAttribute( relType ); + relatesToOM.setText( idValue ); + sh.addChild( relatesToOM ); + } + } // end method addWSARelatesTo + + /** + * Indicates if the invocation is for the callback of a bidirectional service + * @param msg the Message + * @return true if the invocation is for the callback of a bidirectional service, false otherwise + */ + private boolean isInvocationForCallback( Message msg ) { + org.apache.tuscany.sca.assembly.EndpointReference fromEPR = msg.getFrom(); + if( fromEPR != null ) { + ComponentReference ref = fromEPR.getReference(); + if( ref != null ) return ref.isForCallback(); + } // end if + return false; + } // end method isInvocationForCallback + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java new file mode 100644 index 0000000000..20f5e004cc --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java @@ -0,0 +1,382 @@ +/* + * 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.provider; + +import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collection; +import java.util.List; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.extensions.soap12.SOAP12Binding; +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.EndpointReferenceHelper; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.description.AxisService; +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.EndpointReference; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.transport.TransportReferenceInterceptor; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.util.PolicyHelper; +import org.apache.tuscany.sca.provider.EndpointReferenceProvider; +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.RuntimeEndpointReference; +import org.oasisopen.sca.ServiceRuntimeException; + +public class Axis2ReferenceBindingProvider extends Axis2BaseBindingProvider implements EndpointReferenceProvider { + + // the endpoint reference configuration that's driving this binding provider + // and some convenience data retrieved from the endpoint reference + private RuntimeEndpointReference endpointReference; + private RuntimeComponent component; + private RuntimeComponentReference reference; + private WebServiceBinding wsBinding; + + // The Axis2 configuration that the binding creates + private ServiceClient serviceClient; + private AxisService axisClientSideService; + + + public Axis2ReferenceBindingProvider(ExtensionPointRegistry extensionPoints, + EndpointReference endpointReference) { + + super(extensionPoints); + + this.endpointReference = (RuntimeEndpointReference)endpointReference; + + this.wsBinding = (WebServiceBinding)endpointReference.getBinding(); + this.component = (RuntimeComponent)endpointReference.getComponent(); + this.reference = (RuntimeComponentReference)endpointReference.getReference(); + + // A WSDL document should always be present in the binding + if (wsBinding.getGeneratedWSDLDocument() == 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()); + } + + isSOAP11Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP11_INTENT); + isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT); + + isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT); + + // TODO - this is not correct as there may be other, custom, policies that + // require rampart. For example this is not going to pick up the case + // of external policy attachment + isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) || + PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) || + PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT); + + // Apply the configuration from any other policies + + for (PolicyProvider pp : this.endpointReference.getPolicyProviders()) { + pp.configureBinding(this); + } + + // check the WSDL style as we currently only support some of them + if (wsBinding.isRpcEncoded()){ + throw new ServiceRuntimeException("rpc/encoded WSDL style not supported. Component " + endpointReference.getComponent().getName() + + " Reference " + endpointReference.getReference() + + " Binding " + endpointReference.getBinding().getName()); + } + + if (wsBinding.isDocEncoded()){ + throw new ServiceRuntimeException("doc/encoded WSDL style not supported. Component " + endpointReference.getComponent().getName() + + " Reference " + endpointReference.getReference() + + " Binding " + endpointReference.getBinding().getName()); + } + + if (wsBinding.isDocLiteralUnwrapped()){ + //throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint reference " + endpointReference); + } + + // Validate that the WSDL is not using SOAP v1.2 if requires="SOAP.v1_1" has been specified + if ( isSOAP11Required ) { + Definition def = wsBinding.getGeneratedWSDLDocument(); + Binding binding = def.getBinding(wsBinding.getBinding().getQName()); + for ( Object ext : binding.getExtensibilityElements() ) { + if ( ext instanceof SOAP12Binding ) + throw new ServiceRuntimeException("WSDL document is using SOAP v1.2 but SOAP v1.1 " + + "is required by the specified policy intents"); + } + } + + // Validate that the WSDL is not using SOAP v1.1 if requires="SOAP.v1_2" has been specified + if ( isSOAP12Required ) { + Definition def = wsBinding.getGeneratedWSDLDocument(); + Binding binding = def.getBinding(wsBinding.getBinding().getQName()); + for ( Object ext : binding.getExtensibilityElements() ) { + if ( ext instanceof SOAPBinding ) + throw new ServiceRuntimeException("WSDL document is using SOAP v1.1 but SOAP v1.2 " + + "is required by the specified policy intents"); + } + } + } + + public void start() { + configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery()); + + try { + Definition definition = wsBinding.getGeneratedWSDLDocument(); + QName serviceQName = wsBinding.getService().getQName(); + Port port = wsBinding.getPort(); + if (port == null) { + // service has multiple ports, select one port to use + // TODO - it feels like there is much more to this than is + // here at the moment as need to match with the service side + // assuming that it's available + 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; + } + } + } + } + + axisClientSideService = Axis2EngineIntegration.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); + } + + serviceClient = new ServiceClient(configContext, axisClientSideService); + + } catch (AxisFault e) { + throw new RuntimeException(e); // TODO: better exception + } + } + + public 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; + } + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public Invoker createInvoker(Operation operation) { + Options options = new Options(); + org.apache.axis2.addressing.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 (isSOAP12Required) + return OMAbstractFactory.getSOAP12Factory(); + else + return OMAbstractFactory.getSOAP11Factory(); + + } + }); + QName wsdlOperationQName = new QName(operationName); + if (isMTOMRequired) + { + options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM, org.apache.axis2.Constants.VALUE_TRUE); + } + + return new Axis2ReferenceBindingInvoker(endpointReference, serviceClient, wsdlOperationQName, options, soapFactory, wsBinding); + +/* + if (operation.isNonBlocking()) { + invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding); + } else { + invoker = new Axis2BindingInvoker(endpointReference, serviceClient, wsdlOperationQName, options, soapFactory, wsBinding); + } + + return invoker; +*/ + } + + /* + * set up the reference binding wire with the right set of ws reference + * interceptors + */ + public void configure() { + InvocationChain bindingChain = endpointReference.getBindingInvocationChain(); + + // add transport interceptor + bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT, + new TransportReferenceInterceptor()); + + } + + // Reference specific utility operations + + protected org.apache.axis2.addressing.EndpointReference getWSATOEPR(WebServiceBinding binding) { + org.apache.axis2.addressing.EndpointReference epr = getEPR(binding); + if (epr == null) { + epr = getPortLocationEPR(binding); + } else if (epr.getAddress() == null || epr.getAddress().length() < 1) { + org.apache.axis2.addressing.EndpointReference bindingEPR = getPortLocationEPR(binding); + if (bindingEPR != null) { + epr.setAddress(bindingEPR.getAddress()); + } + } + return epr; + } + + protected org.apache.axis2.addressing.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 org.apache.axis2.addressing.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; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java new file mode 100644 index 0000000000..e38b97284a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java @@ -0,0 +1,245 @@ +/* + * 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.provider; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.wsdl.Port; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axis2.AxisFault; +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.engine.ListenerManager; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +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.mtom.Axis2MTOMPolicyProvider; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.policy.util.PolicyHelper; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.oasisopen.sca.ServiceRuntimeException; + +public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implements ServiceBindingProvider { + private static final Logger logger = Logger.getLogger(Axis2ServiceBindingProvider.class.getName()); + + // Tuscany extensions + private AssemblyFactory assemblyFactory; + private ServletHost servletHost; + private RuntimeComponent component; + private RuntimeComponentService service; + + // the endpoint configuration that's driving this binding provider + // and some convenience data retrieved from the endpoint + private RuntimeEndpoint endpoint; + private WebServiceBinding wsBinding; + private Port wsdlPort; + private String endpointURI; + private String deployedURI; + private InterfaceContract contract; + + public Axis2ServiceBindingProvider(ExtensionPointRegistry extensionPoints, + RuntimeEndpoint endpoint, + ServletHost servletHost ) { + super(extensionPoints); + + this.extensionPoints = extensionPoints; + this.endpoint = endpoint; + this.servletHost = servletHost; + + this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class); + this.wsBinding = (WebServiceBinding)endpoint.getBinding(); + this.component = (RuntimeComponent)endpoint.getComponent(); + this.service = (RuntimeComponentService)endpoint.getService(); + + // A WSDL document should always be present in the binding + if (wsBinding.getGeneratedWSDLDocument() == null) { + throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + service.getName()); + } + + // Set to use the Axiom data binding + contract = wsBinding.getBindingInterfaceContract(); + contract.getInterface().resetDataBinding(OMElement.class.getName()); + + configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery()); + + // set the root context for this instance of Axis + configContext.setContextRoot(servletHost.getContextPath()); + + // Determine the configuration from the bindings "mayProvides" intents + + isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT); + + isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT); + + // this is not correct as there may be other, custom, policies that + // require rampart. For example this is not going to pick up the case + // of external policy attachment + isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) || + PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) || + PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT); + + + // Apply the configuration from any other policies + + for (PolicyProvider pp : endpoint.getPolicyProviders()) { + pp.configureBinding(this); + } + + // Update port addresses with runtime information + // We can safely assume there is only one port here because you configure + // a binding in the following ways: + // 1/ default - one port generated = host domain : host port / structural path + // 2/ uri="absolute addr" - one port generated = host domain : uri port / uri path + // 3/ uri="relative addr" - one port generated = host domain : host port / structural path / relative path + // 4/ wsdl.binding - one port generated = host domain : host port / structural path + // 5/ wsdl.port - one port generated = host domain : port port / port path + // 6/ wsa:Address - one port generated = host domain : address port / address path + // 7/ 4 + 6 - as 6 + wsdlPort = (Port)wsBinding.getService().getPorts().values().iterator().next(); + + if (wsdlPort == null){ + throw new ServiceRuntimeException("No WSDL port for ws binding of " + component.getName() + "/" + service.getName()); + } + + endpointURI = Axis2EngineIntegration.getPortAddress(wsdlPort); + + if (endpointURI.startsWith("jms:")) { + deployedURI = endpointURI; + isJMSRequired = true; + } else { + if (servletHost == null) { + throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services"); + } + deployedURI = servletHost.getURLMapping(endpointURI, httpSecurityContext).toString(); + } + + Axis2EngineIntegration.setPortAddress(wsdlPort, deployedURI); + + // Apply the configuration from the mayProvides intents + + if (isRampartRequired){ + // TODO - do we need to go back to configurator? + } + + if (isMTOMRequired) { + new Axis2MTOMPolicyProvider(endpoint).configureBinding(configContext); + } + + if (isJMSRequired){ + // TODO - do we need to go back to configurator? + } + wsBinding.setURI(deployedURI); + + // Check the WSDL style as we only support some of them + + if (wsBinding.isRpcEncoded()){ + throw new ServiceRuntimeException("rpc/encoded WSDL style not supported. Component " + endpoint.getComponent().getName() + + " Service " + endpoint.getService() + + " Binding " + endpoint.getBinding().getName()); + } + + if (wsBinding.isDocEncoded()){ + throw new ServiceRuntimeException("doc/encoded WSDL style not supported. Component " + endpoint.getComponent().getName() + + " Service " + endpoint.getService() + + " Binding " + endpoint.getBinding().getName()); + } + + // if (wsBinding.isDocLiteralUnwrapped()){ + // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint " + endpoint); + // } + } + + private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory"; + + public void start() { + try { + createAxisService(deployedURI, wsdlPort); + + if (deployedURI.startsWith("http://") || + deployedURI.startsWith("https://") || + deployedURI.startsWith("/")) { + Axis2ServiceServlet servlet = new Axis2ServiceServlet(); + servlet.init(configContext); + + if (httpSecurityContext.isSSLEnabled()){ + deployedURI = servletHost.addServletMapping(endpointURI, servlet, httpSecurityContext); + } else { + deployedURI = servletHost.addServletMapping(endpointURI, servlet); + } + } + } catch (AxisFault e) { + throw new RuntimeException(e); + } + } + + public void stop() { + try { + servletHost.removeServletMapping(endpointURI); + servletHost = null; + + // get the path to the service + // [nash] Need a leading slash for WSDL imports to work with ?wsdl + URI uriPath = new URI(deployedURI); + String stringURIPath = uriPath.getPath(); + configContext.getAxisConfiguration().removeService(stringURIPath); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } catch (AxisFault e) { + throw new RuntimeException(e); + } + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + + // Service specific utility operations + + private void createAxisService(String endpointURL, Port port) throws AxisFault { + AxisService axisService; + if (wsBinding.getGeneratedWSDLDocument() != null) { + axisService = Axis2EngineIntegration.createWSDLAxisService(endpointURL, port, wsBinding); + } else { + axisService = Axis2EngineIntegration.createJavaAxisService(endpointURL, configContext, service); + } + + Axis2EngineIntegration.createAxisServiceProviders(axisService, endpoint, wsBinding, extensionPoints); + + configContext.getAxisConfiguration().addService(axisService); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java new file mode 100644 index 0000000000..b1f3b35636 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.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.provider; + +import java.lang.reflect.InvocationTargetException; + +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; + +public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver { + + private TuscanyServiceProvider provider; + + public Axis2ServiceInMessageReceiver(TuscanyServiceProvider provider) { + this.provider = provider; + } + + public Axis2ServiceInMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + + provider.invoke(requestOM, 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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.java new file mode 100644 index 0000000000..d6694c9f7d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.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.provider; + +import java.lang.reflect.InvocationTargetException; +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.util.FaultException; +import org.oasisopen.sca.ServiceRuntimeException; + +public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver { + private static final Logger logger = Logger.getLogger(Axis2ServiceInOutSyncMessageReceiver.class.getName()); + + private TuscanyServiceProvider provider; + + public Axis2ServiceInOutSyncMessageReceiver(TuscanyServiceProvider provider) { + this.provider = provider; + } + + public Axis2ServiceInOutSyncMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + + OMElement responseOM = (OMElement)provider.invoke(requestOM, inMC); + + 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) { + if( "AsyncResponse".equals(e.getMessage()) ) { + // Do nothing for an async response exception - it is a signal that the service has been + // invoked asynchronously + } else { + logger.log(Level.SEVERE, e.getMessage(), e); + } // end if + throw AxisFault.makeFault(e); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java new file mode 100644 index 0000000000..2f6b396786 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java @@ -0,0 +1,300 @@ +/* + * 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.provider; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +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.context.ConfigurationContext; +import org.apache.axis2.transport.http.AxisServlet; + +/** + * 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(); + + private boolean initCalled = false; + +//JIRA TUSCANY-1561 Port to Axis2 1.3 + private ConfigurationContext tmpconfigContext; + + public void init(ConfigurationContext configContext) { + this.tmpconfigContext = configContext; + //try { + //super.init(DUMMY_CONFIG); + //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(); + servletConfig = null; + if (tmpconfigContext.getListenerManager() != null){ + tmpconfigContext.getListenerManager().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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java new file mode 100644 index 0000000000..0a20de5067 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.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.provider; + +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.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 = path.split("/"); + 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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java new file mode 100644 index 0000000000..c44454196d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java @@ -0,0 +1,232 @@ +/* + * 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.provider; + +import java.io.IOException; +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 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 org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.transport.http.ListingAgent; +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("wsdl4jDefinition"); + Definition definition = (Definition)wsld4jdefinition.getValue(); + for (Object s : definition.getServices().values()) { + for (Object p : ((Service)s).getPorts().values()) { + String endpointURL = Axis2EngineIntegration.getPortAddress((Port)p); + String modifiedURL = setIPAddress(endpointURL, url); + modifiedURL = addContextRoot(modifiedURL, serviceName); + Axis2EngineIntegration.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 String addContextRoot(String modifiedURL, String serviceName) { + if (!"/".equals(configContext.getContextRoot())) { + if (modifiedURL.endsWith(serviceName)) { + URI uri = URI.create(modifiedURL); + if (!uri.getPath().startsWith(configContext.getContextRoot())) { + modifiedURL = modifiedURL.substring(0, modifiedURL.length() - serviceName.length()) + configContext.getContextRoot() + serviceName; + } + } + } + return modifiedURL; + } + + 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 = path.split("/"); + 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); +// not in Axis2 1.5.1 +// String ipAddr = HttpUtils.getIpAddress(); +// int requestPort = requestURIObj.getPort(); +// String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : ""); +// return wsdlURI.replace(wsdlAddr, newAddr); + return wsdlURI; + } catch (Exception e) { + // URI string not in expected format, so return the WSDL URI unmodified + return wsdlURI; + } + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java new file mode 100644 index 0000000000..ba23e80d88 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java @@ -0,0 +1,296 @@ +/*
+ * 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.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.wsdl.BindingOperation;
+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.OMNode;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class TuscanyServiceProvider {
+ private static final Logger logger = Logger.getLogger(TuscanyServiceProvider.class.getName());
+
+ 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_REPLYTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_REPLY_TO);
+ public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
+ public static final QName QNAME_WSA_MESSAGEID =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_MESSAGE_ID);
+ public static final QName QNAME_WSA_RELATESTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_RELATES_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
+
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+ private MessageFactory messageFactory;
+ private FactoryExtensionPoint modelFactories;
+ private RuntimeAssemblyFactory assemblyFactory;
+ private WebServiceBindingFactory webServiceBindingFactory;
+ private Operation operation;
+
+ public TuscanyServiceProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpoint endpoint,
+ WebServiceBinding wsBinding,
+ Operation operation) {
+ this.endpoint = endpoint;
+ this.wsBinding = wsBinding;
+ this.operation = operation;
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ this.webServiceBindingFactory = (WebServiceBindingFactory)modelFactories.getFactory(WebServiceBindingFactory.class);
+ }
+
+ // Special WS_Addressing values
+ private static String WS_ADDR_ANONYMOUS = "http://www.w3.org/2005/08/addressing/anonymous";
+ private static String WS_ADDR_NONE = "http://www.w3.org/2005/08/addressing/none";
+ /**
+ * Check if the received callback address has either of the special WS-Addressing forms which are outlawed by the
+ * Web Service Binding specification [BWS50004]
+ * @param callbackAddress - the received callback address
+ * @param inMC - the Axis message context for the received forward call
+ * @throws AxisFault - throws a "OnlyNonAnonymousAddressSupportedFault" if the callback address has either of the special forms
+ */
+ private void checkCallbackAddress( String callbackAddress, MessageContext inMC ) throws AxisFault {
+ // If the address is anonymous or none, throw a SOAP fault...
+ if( WS_ADDR_ANONYMOUS.equals(callbackAddress) || WS_ADDR_NONE.equals(callbackAddress) ) {
+ AddressingFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(inMC, "wsa:From");
+ }
+ } // end method checkCallbackAddress
+
+ public OMElement invoke(OMElement requestOM, MessageContext inMC) throws InvocationTargetException, AxisFault {
+ String callbackAddress = null;
+
+ // create a message object and set the args as its body
+ Message msg = messageFactory.createMessage();
+ msg.setOperation(operation);
+ msg.setBindingContext(inMC);
+
+ if (wsBinding.isRpcLiteral()){
+ // remove the wrapping element containing
+ // the operation name
+ Iterator iter = requestOM.getChildElements();
+ List<OMNode> list = new ArrayList<OMNode>();
+ while(iter.hasNext()){
+ OMNode node = (OMNode)iter.next();
+ list.add(node);
+ }
+
+ Object[] args = list.toArray();
+ msg.setBody(args);
+
+ } else if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not supported for endpoint " + endpoint);
+ //} else if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocLiteralWrapped() ||
+ wsBinding.isDocLiteralUnwrapped()){
+ Object[] args = new Object[] {requestOM};
+ msg.setBody(args);
+ } else {
+ throw new ServiceRuntimeException("Unrecognized WSDL style for endpoint " + endpoint);
+ }
+
+ SOAPHeader header = inMC.getEnvelope().getHeader();
+ if (header != null) {
+ // Retrieve callback-related headers
+ callbackAddress = handleCallbackAddress( header, msg );
+ handleMessageIDHeader( header, msg );
+ handleRelatesToHeader( header, msg );
+ } // end if
+
+ // Create a from EPR to hold the details of the callback endpoint, if any
+ createCallbackEPR( callbackAddress, inMC, msg );
+
+ Message response = endpoint.invoke(msg);
+
+ if(response.isFault()) {
+ throw new InvocationTargetException((Throwable) response.getBody());
+ }
+
+ OMElement responseOM = response.getBody();
+
+ if (wsBinding.isRpcLiteral()){
+ // add the response wrapping element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ String wrapperNamespace = null;
+
+ // the rpc style creates a wrapper with a namespace where the namespace is
+ // defined on the wsdl binding operation. If no binding is provided by the
+ // user then default to the namespace of the WSDL itself.
+ if (wsBinding.getBinding() != null){
+ Iterator iter = wsBinding.getBinding().getBindingOperations().iterator();
+ loopend:
+ while(iter.hasNext()){
+ BindingOperation bOp = (BindingOperation)iter.next();
+ if (bOp.getName().equals(msg.getOperation().getName())){
+ for (Object ext : bOp.getBindingOutput().getExtensibilityElements()){
+ if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){
+ wrapperNamespace = ((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI();
+ break loopend;
+ }
+ }
+ }
+ }
+ }
+
+ if (wrapperNamespace == null){
+ wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace();
+ }
+
+ QName operationResponseQName = new QName(wrapperNamespace,
+ msg.getOperation().getName() + "Response");
+ OMElement operationResponseElement = factory.createOMElement(operationResponseQName);
+ operationResponseElement.addChild(responseOM);
+ responseOM = operationResponseElement;
+ }
+
+ return responseOM;
+ } // end method
+
+ /**
+ * If there is a callback address, create an EPR for the callback with a referenced endpoint that contains
+ * the binding and the target callback address
+ * @param callbackAddress - the callback address - may be null
+ * @param inMC - the Axis incoming message context
+ * @param msg - the Tuscany message
+ * @throws AxisFault - if the callback address has any of the disallowed forms of callback address
+ */
+ private void createCallbackEPR( String callbackAddress, MessageContext inMC, Message msg ) throws AxisFault {
+ if (callbackAddress != null ) {
+ // Check for special (& not allowed!) WS_Addressing values
+ checkCallbackAddress( callbackAddress, inMC );
+ //
+ EndpointReference from = assemblyFactory.createEndpointReference();
+ Endpoint fromEndpoint = assemblyFactory.createEndpoint();
+ from.setTargetEndpoint(fromEndpoint);
+ from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ msg.setFrom(from);
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
+ //
+ WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
+ cbBinding.setURI(callbackAddress);
+ callbackEndpoint.setBinding(cbBinding);
+ //
+ callbackEndpoint.setURI(callbackAddress);
+ callbackEndpoint.setUnresolved(true);
+ from.setCallbackEndpoint(callbackEndpoint);
+ } // end if
+ } // end method createCallbackEPR
+
+ private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+ /**
+ * Deal with any Callback address contained in the SOAP headers of the received message
+ * The callback address is contained in one of two headers (in the priority order stated by the SCA Web Service Binding spec):
+ * - wsa:From
+ * - wsa:ReplyTo
+ * Either of these headers should then contain a wsa:Address element containing the callback address
+ * A callback address may also be accompanied by wsa:ReferenceParameters
+ * - if present, ReferenceParameters must be read, stored unchanged and then sent in the header of any message sent to the
+ * callback address, as stated in the WSW-Addressing specification
+ * Any ReferenceParameters are stored into the headers of the Tuscany message under the key "WS_REFERENCE_PARAMETERS"
+ * @param header - the SOAP header for the message
+ * @param msg - the Tuscany message data structure
+ * @return - the callback address, as a String - null if no callback address is found
+ */
+ private String handleCallbackAddress( SOAPHeader header, Message msg ) {
+ String callbackAddress = null;
+
+ // See if there is a wsa:From element - if not search for a wsa:ReplyTo element
+ OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
+ if( from == null ) from = header.getFirstChildWithName(QNAME_WSA_REPLYTO);
+
+ if (from != null) {
+ OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
+ if (callbackAddrElement != null) {
+ callbackAddress = callbackAddrElement.getText();
+ OMElement refParms = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+ if( refParms != null ) msg.getHeaders().put(WS_REF_PARMS, refParms);
+ }
+ } // end if
+
+ return callbackAddress;
+ } // end method handleCallbackAddress
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ /**
+ * Handle a SOAP wsa:MessageID header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleMessageIDHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ OMElement messageID = header.getFirstChildWithName(QNAME_WSA_MESSAGEID);
+ if (messageID != null) {
+ String idValue = messageID.getText();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
+
+ private static String WS_RELATES_TO = "WS_RELATES_TO";
+ /**
+ * Handle a SOAP wsa:RelatesTo header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleRelatesToHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ OMElement messageID = header.getFirstChildWithName(QNAME_WSA_RELATESTO);
+ if (messageID != null) {
+ String idValue = messageID.getText();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
+} // end class AsyncResponseHandler
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java new file mode 100644 index 0000000000..7daa58bf29 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java @@ -0,0 +1,137 @@ +/* + * 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.transport; + +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.apache.axiom.om.OMElement; +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.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Use an Axis2 OperationClient to invoke a remote web service + * + * @version $Rev$ $Date$ + */ +public class TransportReferenceInterceptor implements Interceptor { + + private Invoker next; + + public TransportReferenceInterceptor() { + } + + public Message invoke(Message msg) { + try { + Object resp = null; + + if (msg.getOperation().isNonBlocking()) { + resp = invokeTargetOneWay(msg); + } else { + 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 = msg.getBindingContext(); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext("Out"); + requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + requestMC.getOptions().setTimeOutInMilliSeconds(240000L); + + + // 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("In"); + + 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; + } + + protected Object invokeTargetOneWay(Message msg) throws AxisFault { + OperationClient operationClient = msg.getBindingContext(); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext("Out"); + //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; + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..a35f2502f4 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -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 binding extension
+org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding,ranking=462
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..ae1acbd541 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/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 binding-ws-runtime-axis2 specific policy extensions
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.BasicAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.security.http.ssl.HTTPSPolicyProviderFactory;model=org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy
diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml new file mode 100644 index 0000000000..d1d1203bb9 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml @@ -0,0 +1,501 @@ +<?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 allow 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.provider.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.provider.Axis2ServiceInOutSyncMessageReceiver"/> + + <!-- Added by Tuscany --> + <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only" + class="org.apache.tuscany.sca.binding.ws.axis2.provider.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.provider.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="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"/> + </messageBuilders> + + <!-- ================================================= --> + <!-- Transport Ins --> + <!-- ================================================= --> + <transportReceiver name="http" + class="org.apache.axis2.transport.http.AxisServletListener"> + + <!-- 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="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.provider.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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar Binary files differnew file mode 100644 index 0000000000..ec870734a5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java new file mode 100644 index 0000000000..a482477d3b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.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; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class HelloWorldTestCase extends TestCase { + + private Node node; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite", + new Contribution("test", "target/test-classes")); + node.start(); + helloWorld = node.getService(HelloWorld.class, "HelloWorldClient"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java new file mode 100644 index 0000000000..b55779fa25 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.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; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class WSDLBindingTestCase extends TestCase { + + private Node node; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite", + new Contribution("test", "target/test-classes")); + node.start(); + helloWorld = node.getService(HelloWorld.class, "HelloWorldClient"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java new file mode 100644 index 0000000000..54f25694e1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.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; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class WSDLBindingURITestCase extends TestCase { + + private Node node; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite", + new Contribution("test", "target/test-classes")); + node.start(); + helloWorld = node.getService(HelloWorld.class, "HelloWorldClient"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java new file mode 100644 index 0000000000..addcf67ac0 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.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; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class WSDLBindingWSATestCase extends TestCase { + + private Node node; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite", + new Contribution("test", "target/test-classes")); + node.start(); + helloWorld = node.getService(HelloWorld.class, "HelloWorldClient"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java new file mode 100644 index 0000000000..98eb6e361b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/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.helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HelloWorld { + + String getGreetings(String s); + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..2c6c4fc92c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.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.axis2.helloworld; + +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldClient implements HelloWorld { + + @Reference + public HelloWorld helloWorldWS; + + public String getGreetings(String s) { + String response = helloWorldWS.getGreetings(s); + System.out.println("At client: " + response); + return response; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..3662007984 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.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.helloworld; + +public class HelloWorldService implements HelloWorld { + + public String getGreetings(String s) { + String response = "Hello " + s; + System.out.println("At service: " + response); + return response; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite new file mode 100644 index 0000000000..fdbb68baea --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite @@ -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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2" + name="HelloWorld"> + + <component name="HelloWorldClient"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/> + <reference name="helloWorldWS"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/> + </reference> + </component> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/> + <service name="HelloWorld"> + <interface.wsdl interface="http://helloworld#wsdl.interface(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/HelloWorldWebService1</wsa:Address> + </wsa:EndpointReference> + </binding.ws> + </service> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl new file mode 100644 index 0000000000..0d5fd064ae --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/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="HelloWorldSoapPort1"> + <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/> + </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/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite new file mode 100644 index 0000000000..863d13b97e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite @@ -0,0 +1,41 @@ +<?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://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2" + name="wsdlbinding"> + + <component name="HelloWorldClient"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/> + <reference name="helloWorldWS"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws uri="http://localhost:8080/HelloWorldService/HelloWorld"/> + </reference> + </component> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/> + <service name="HelloWorld"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)"/> + </service> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite new file mode 100644 index 0000000000..a877f9be26 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2" + name="wsdlbindinguri"> + + <component name="HelloWorldClient"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/> + <reference name="helloWorldWS"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/> + </reference> + </component> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/> + <service name="HelloWorld"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws uri="http://localhost:8085/services/HelloWorldWebService1" + wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)"/> + </service> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite new file mode 100644 index 0000000000..7b0263b019 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta2/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite @@ -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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2" + name="wsdlbindingwsa"> + + <component name="HelloWorldClient"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/> + <reference name="helloWorldWS"> + <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" /> + <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/> + </reference> + </component> + + <component name="HelloWorldService"> + <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/> + <service name="HelloWorld"> + <interface.wsdl interface="http://helloworld#wsdl.interface(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/HelloWorldWebService1</wsa:Address> + </wsa:EndpointReference> + </binding.ws> + </service> + </component> + +</composite> |