From b5c0d648cf147d3709eb78d98011f38e07aee723 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:25:44 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835694 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/binding-ws-axis2/LICENSE | 205 +++++ .../sca-java-1.5.2/modules/binding-ws-axis2/NOTICE | 6 + .../modules/binding-ws-axis2/pom.xml | 351 +++++++++ .../sca/binding/ws/axis2/Axis2BindingInvoker.java | 300 ++++++++ .../ws/axis2/Axis2BindingProviderFactory.java | 89 +++ .../ws/axis2/Axis2OneWayBindingInvoker.java | 71 ++ .../ws/axis2/Axis2ReferenceBindingProvider.java | 87 +++ .../ws/axis2/Axis2ServiceBindingProvider.java | 86 +++ .../sca/binding/ws/axis2/Axis2ServiceClient.java | 503 ++++++++++++ .../ws/axis2/Axis2ServiceInMessageReceiver.java | 79 ++ .../Axis2ServiceInOutSyncMessageReceiver.java | 103 +++ .../sca/binding/ws/axis2/Axis2ServiceProvider.java | 843 +++++++++++++++++++++ .../sca/binding/ws/axis2/Axis2ServiceServlet.java | 356 +++++++++ .../sca/binding/ws/axis2/AxisPolicyHelper.java | 79 ++ .../binding/ws/axis2/TuscanyAxisConfigurator.java | 207 +++++ .../sca/binding/ws/axis2/TuscanyDispatcher.java | 105 +++ .../binding/ws/axis2/TuscanyListenerManager.java | 107 +++ .../sca/binding/ws/axis2/TuscanyListingAgent.java | 238 ++++++ .../ws/axis2/WSBindingDefinitionsProvider.java | 66 ++ .../sca/binding/ws/axis2/jms/AxisJMSException.java | 35 + .../binding/ws/axis2/jms/JMSConnectionFactory.java | 605 +++++++++++++++ .../sca/binding/ws/axis2/jms/JMSListener.java | 527 +++++++++++++ .../binding/ws/axis2/jms/JMSMessageReceiver.java | 270 +++++++ .../binding/ws/axis2/jms/JMSOutTransportInfo.java | 220 ++++++ .../sca/binding/ws/axis2/jms/JMSSender.java | 389 ++++++++++ .../apache/tuscany/sca/binding/ws/axis2/jms/README | 14 + ...xis2BindingBasicAuthenticationConfigurator.java | 111 +++ .../Axis2BindingHeaderConfigurator.java | 69 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 + .../tuscany/sca/binding/ws/axis2/definitions.xml | 54 ++ .../sca/binding/ws/axis2/engine/config/axis2.xml | 504 ++++++++++++ .../ws/axis2/engine/config/modules/modules.list | 1 + .../ws/axis2/engine/config/modules/rampart-1.4.mar | Bin 0 -> 2796 bytes .../ws/axis2/engine/config/services/services.list | 0 .../binding/ws/axis2/Axis2ReferenceTestCase.java | 83 ++ .../sca/binding/ws/axis2/Axis2ServiceTestCase.java | 104 +++ .../tuscany/sca/binding/ws/axis2/Greeter.java | 31 + .../sca/binding/ws/axis2/GreetingCallback.java | 24 + .../sca/binding/ws/axis2/itests/Account.java | 34 + .../binding/ws/axis2/itests/AccountService.java | 33 + .../tuscany/sca/binding/ws/axis2/itests/Bar.java | 58 ++ .../ws/axis2/itests/CustomerProfileData.java | 103 +++ .../tuscany/sca/binding/ws/axis2/itests/Echo.java | 29 + .../sca/binding/ws/axis2/itests/EchoComponent.java | 33 + .../sca/binding/ws/axis2/itests/EchoImpl.java | 29 + .../tuscany/sca/binding/ws/axis2/itests/Foo.java | 36 + .../sca/binding/ws/axis2/itests/HelloWorld.java | 29 + .../ws/axis2/itests/HelloWorldComponent.java | 33 + .../ws/axis2/itests/HelloWorldMultiService.java | 51 ++ .../ws/axis2/itests/HelloWorldNoWSDLTestCase.java | 77 ++ .../sca/binding/ws/axis2/itests/HelloWorldOM.java | 30 + .../sca/binding/ws/axis2/itests/HelloWorldOM2.java | 30 + .../ws/axis2/itests/HelloWorldOMComponent.java | 34 + .../ws/axis2/itests/HelloWorldOMService.java | 41 + .../ws/axis2/itests/HelloWorldOMTestCase.java | 58 ++ .../binding/ws/axis2/itests/HelloWorldService.java | 28 + .../ws/axis2/itests/HelloWorldTestCase.java | 46 ++ .../axis2/itests/HelloWorldWSDLMergedTestCase.java | 58 ++ .../itests/QuestionMarkWSDLImportTestCase.java | 96 +++ .../QuestionMarkWSDLIncludeTestCaseFIXME.java | 98 +++ .../ws/axis2/itests/QuestionMarkWSDLTestCase.java | 124 +++ .../ws/axis2/itests/UriPrecedenceTestCase.java | 68 ++ .../endpoints/AbstractHelloWorldOMTestCase.java | 64 ++ .../endpoints/DefaultMultiServiceTestCase.java | 24 + .../endpoints/DefaultSingleServiceTestCase.java | 24 + .../itests/endpoints/WSDLExplicitURITestCase.java | 24 + .../itests/endpoints/WSDLRelativeURITestCase.java | 24 + .../ws/axis2/itests/epr/HelloWorldTestCase.java | 47 ++ .../ws/axis2/itests/mtom/FileTransferClient.java | 57 ++ .../itests/mtom/FileTransferMTOMTestCase.java | 122 +++ .../ws/axis2/itests/mtom/FileTransferService.java | 46 ++ .../itests/mtom/FileTransferServiceClient.java | 42 + .../axis2/itests/mtom/FileTransferServiceImpl.java | 57 ++ .../binding/ws/axis2/itests/mtom/MyException.java | 26 + .../ws/axis2/itests/mtom/MyExceptionAdapter.java | 31 + .../ws/axis2/itests/mtom/MyExceptionImpl.java | 26 + .../configparams/AbstractHelloWorldOMTestCase.java | 64 ++ .../policy/configparams/ClientPWCBHandler.java | 45 ++ .../policy/configparams/IntegrityPWCBHandler.java | 45 ++ .../policy/configparams/ServerPWCBHandler.java | 45 ++ .../WSSecurityAuthenticationTestCaseFIXME.java | 24 + ...onfidentialityTestCaseFIXBouncyCastleIssue.java | 42 + .../configparams/WSSecurityIntegrityTestCase.java | 24 + .../policy/mixed/AbstractHelloWorldOMTestCase.java | 67 ++ .../itests/policy/mixed/ClientPWCBHandler.java | 50 ++ .../itests/policy/mixed/IntegrityPWCBHandler.java | 50 ++ .../itests/policy/mixed/ServerPWCBHandler.java | 49 ++ .../policy/mixed/WSSecurityMixedTestCase.java | 24 + .../wspolicy/AbstractHelloWorldOMTestCase.java | 64 ++ .../itests/policy/wspolicy/ClientPWCBHandler.java | 45 ++ .../policy/wspolicy/IntegrityPWCBHandler.java | 45 ++ .../itests/policy/wspolicy/ServerPWCBHandler.java | 45 ++ .../wspolicy/WSSecurityAuthenticationTestCase.java | 24 + ...onfidentialityTestCaseFIXBouncyCastleIssue.java | 42 + .../wspolicy/WSSecurityIntegrityTestCase.java | 24 + .../itests/soap12/HelloWorldSOAP12TestCase.java | 58 ++ .../itests/soap12/QuestionMarkWSDLTestCase.java | 138 ++++ ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 20 + .../binding/ws/axis2/itests/HelloWorld.composite | 50 ++ .../ws/axis2/itests/HelloWorldNoWSDL.composite | 61 ++ .../sca/binding/ws/axis2/itests/customerdata.xsd | 36 + .../sca/binding/ws/axis2/itests/customerdefs.xsd | 27 + .../sca/binding/ws/axis2/itests/customerinfo.xsd | 31 + .../itests/endpoints/DefaultMultiService.composite | 51 ++ .../endpoints/DefaultSingleService.composite | 51 ++ .../itests/endpoints/WSDLExplicitURI.composite | 49 ++ .../itests/endpoints/WSDLRelativeURI.composite | 49 ++ .../endpoints/helloworld-om-relative-uri.wsdl | 78 ++ .../ws/axis2/itests/epr/HelloWorld.composite | 50 ++ .../ws/axis2/itests/helloworld-om-binding.wsdl | 45 ++ .../ws/axis2/itests/helloworld-om-merged.composite | 42 + .../ws/axis2/itests/helloworld-om-porttype.wsdl | 59 ++ .../binding/ws/axis2/itests/helloworld-om-uri.wsdl | 78 ++ .../ws/axis2/itests/helloworld-om.composite | 43 ++ .../sca/binding/ws/axis2/itests/helloworld-om.wsdl | 78 ++ .../ws/axis2/itests/helloworld-prec.composite | 47 ++ .../binding/ws/axis2/itests/helloworld-prec.wsdl | 81 ++ .../sca/binding/ws/axis2/itests/helloworld.wsdl | 86 +++ .../binding/ws/axis2/itests/mtom/filetransfer.wsdl | 220 ++++++ .../itests/mtom/filetransferservice.composite | 42 + .../WSSecurityAuthentication.composite | 50 ++ .../WSSecurityConfidentiality.composite | 49 ++ .../configparams/WSSecurityIntegrity.composite | 49 ++ .../itests/policy/configparams/definitions.xml | 101 +++ .../itests/policy/configparams/security.properties | 20 + .../itests/policy/configparams/tuscanyKeys.jks | Bin 0 -> 1366 bytes .../ws/axis2/itests/policy/intent/definitions.xml | 32 + .../itests/policy/mixed/WSSecurityMixed.composite | 52 ++ .../ws/axis2/itests/policy/mixed/definitions.xml | 323 ++++++++ .../axis2/itests/policy/mixed/security.properties | 20 + .../ws/axis2/itests/policy/mixed/tuscanyKeys.jks | Bin 0 -> 1366 bytes .../wspolicy/WSSecurityAuthentication.composite | 50 ++ .../wspolicy/WSSecurityConfidentiality.composite | 49 ++ .../policy/wspolicy/WSSecurityIntegrity.composite | 50 ++ .../axis2/itests/policy/wspolicy/definitions.xml | 204 +++++ .../axis2/itests/policy/wspolicy/tuscanyKeys.jks | Bin 0 -> 1352 bytes .../axis2/itests/questionmark-import-nested.wsdl | 70 ++ .../ws/axis2/itests/questionmark-import.wsdl | 49 ++ .../ws/axis2/itests/questionmark-include.wsdl | 94 +++ .../itests/questionmark-wsdl-import.composite | 31 + .../itests/questionmark-wsdl-include.composite | 31 + .../ws/axis2/itests/questionmark-wsdl.composite | 39 + .../axis2/itests/soap12/HelloWorldSOAP12.composite | 71 ++ .../itests/soap12/questionmark-wsdl.composite | 40 + 145 files changed, 12692 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/AxisJMSException.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSConnectionFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSListener.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSMessageReceiver.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSOutTransportInfo.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSSender.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/README create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite (limited to 'sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2') diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/LICENSE b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/NOTICE b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2009 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/pom.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/pom.xml new file mode 100644 index 0000000000..cc8387e009 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/pom.xml @@ -0,0 +1,351 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.5.2-SNAPSHOT + ../pom.xml + + + tuscany-binding-ws-axis2 + Apache Tuscany SCA Axis2-based WS Binding Extension + + + + apache.ws + Apache WebServices Repository + http://ws.zones.apache.org/repository/ + legacy + + + + + + org.apache.tuscany.sca + tuscany-core + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-xml + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-databinding + 1.5.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-databinding-axiom + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-jaxb-axiom + 1.5.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-http + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy-xml-ws + 1.5.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2-policy + 1.5.2-SNAPSHOT + + + + org.apache.axis2 + axis2-kernel + 1.4.1 + + + backport-util-concurrent + backport-util-concurrent + + + org.apache.ant + ant + + + org.apache.ant + ant-launcher + + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + org.apache.axis2 + axis2-java2wsdl + 1.4.1 + + + org.apache.ant + ant + + + org.apache.ant + ant-launcher + + + xom + xom + + + + + + org.apache.axis2 + axis2-codegen + 1.4.1 + runtime + + + stax + stax-api + + + + + + org.apache.neethi + neethi + 2.0.4 + + + org.codehaus.woodstox + wstx-asl + + + + + + commons-httpclient + commons-httpclient + 3.1 + + + + commons-codec + commons-codec + 1.3 + + + commons-codec + commons-codec + + + + + + org.apache.axis2 + axis2-mtompolicy + 1.4.1 + + + + org.apache.santuario + xmlsec + 1.4.2 + + + + org.apache.ws.security + wss4j + 1.5.4 + + + bouncycastle + bcprov-jdk13 + + + bouncycastle + bcprov-jdk15 + + + + + + org.apache.axis2 + mex + 1.41 + impl + + + + org.apache.rampart + rampart-core + 1.4 + + + org.apache.ant + ant-nodeps + + + org.apache.axis2 + addressing + + + org.apache.axis2 + axis2-xmlbeans + + + org.apache.axis2 + mex + + + org.apache.axis2 + axis2-adb + + + org.apache.axis2 + axis2-codegen + + + org.apache.axis2 + axis2-adb-codegen + + + xmlbeans + xbean + + + org.apache.ws.commons.schema + XmlSchema + + + stax + stax-api + + + bouncycastle + bcprov-jdk13 + + + bouncycastle + bcprov-jdk15 + + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + + xalan + xalan + 2.7.0 + optional + + + + xerces + xercesImpl + 2.8.1 + + + + xml-apis + xml-apis + 1.3.03 + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.5.2-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.5.2-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.5.2-SNAPSHOT + test + + + + + + + org.apache.felix + maven-bundle-plugin + + + + ${tuscany.version} + org.apache.tuscany.sca.binding.ws.axis2 + ${pom.name} + org.apache.tuscany.sca.binding.ws.axis2* + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java new file mode 100644 index 0000000000..3ed48425ab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.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; + +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.soap.SOAPBody; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.AddressingConstants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.addressing.EndpointReferenceHelper; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingBasicAuthenticationConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.invocation.DataExchangeSemantics; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.runtime.ReferenceParameters; + +/** + * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics { + + public static final QName QNAME_WSA_FROM = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM, + AddressingConstants.WSA_DEFAULT_PREFIX); + public static final String TUSCANY_PREFIX = "tuscany"; + public static final QName CALLBACK_ID_REFPARM_QN = + new QName(Constants.SCA10_TUSCANY_NS, "CallbackID", TUSCANY_PREFIX); + public static final QName CONVERSATION_ID_REFPARM_QN = + new QName(Constants.SCA10_TUSCANY_NS, "ConversationID", TUSCANY_PREFIX); + public static long GLOBAL_AXIS_TIMEOUT = 240000L; + + + private Axis2ServiceClient serviceClient; + private QName wsdlOperationName; + private Options options; + private SOAPFactory soapFactory; + private List policyHandlerList = null; + private WebServiceBinding wsBinding; + + private BasicAuthenticationPolicy basicAuthenticationPolicy = null; + private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null; + private List axis2HeaderPolicies = new ArrayList(); + + public Axis2BindingInvoker(Axis2ServiceClient serviceClient, + QName wsdlOperationName, + Options options, + SOAPFactory soapFactory, + List policyHandlerList, + WebServiceBinding wsBinding) { + this.serviceClient = serviceClient; + this.wsdlOperationName = wsdlOperationName; + this.options = options; + this.soapFactory = soapFactory; + this.policyHandlerList = policyHandlerList; + this.wsBinding = wsBinding; + + // find out which policies are active + if (wsBinding instanceof PolicySetAttachPoint) { + List policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (BasicAuthenticationPolicy.class.isInstance(p)) { + basicAuthenticationPolicy = (BasicAuthenticationPolicy)p; + } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p; + } else if (Axis2HeaderPolicy.class.isInstance(p)) { + axis2HeaderPolicies.add((Axis2HeaderPolicy)p); + }else { + // etc. check for other types of policy being present + } + } + } + } + } + + private static final QName EXCEPTION = new QName("", "Exception"); + + public Message invoke(Message msg) { + try { + Object resp = invokeTarget(msg); + + msg.setBody(resp); + } catch (AxisFault e) { + if (e.getDetail() != null ) { + FaultException f = new FaultException(e.getMessage(), e.getDetail(), e); + f.setFaultName(e.getDetail().getQName()); + msg.setFaultBody(f); + } else { + msg.setFaultBody(e); + } + } catch (Throwable e) { + msg.setFaultBody(e); + } + + return msg; + } + + protected Object invokeTarget(Message msg) throws AxisFault { + final OperationClient operationClient = createOperationClient(msg); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); + requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + requestMC.getOptions().setTimeOutInMilliSeconds(GLOBAL_AXIS_TIMEOUT); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(msg, requestMC, operationClient); + } + + // set policy specified headers + for (Axis2HeaderPolicy policy : axis2HeaderPolicies){ + Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, policy.getHeaderName()); + } + + if (basicAuthenticationPolicy != null) { + Axis2BindingBasicAuthenticationConfigurator.setOperationOptions(operationClient, msg, basicAuthenticationPolicy); + } + + if (axis2TokenAuthenticationPolicy != null) { + Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, axis2TokenAuthenticationPolicy.getTokenName()); + } + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws AxisFault { + operationClient.execute(true); + return null; + } + }); + } catch (PrivilegedActionException e) { + operationClient.complete(requestMC); + throw (AxisFault)e.getException(); + } + + MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(msg, responseMC, operationClient); + } + + OMElement response = responseMC.getEnvelope().getBody().getFirstElement(); + + // FIXME: [rfeng] We have to pay performance penalty to build the complete OM as the operationClient.complete() will + // release the underlying HTTP connection. + // Force the response to be populated, see https://issues.apache.org/jira/browse/TUSCANY-1541 + if (response != null) { + response.build(); + } + + operationClient.complete(requestMC); + + return response; + } + + @SuppressWarnings("deprecation") + protected OperationClient createOperationClient(Message msg) throws AxisFault { + SOAPEnvelope env = soapFactory.getDefaultEnvelope(); + Object[] args = (Object[])msg.getBody(); + if (args != null && args.length > 0) { + SOAPBody body = env.getBody(); + for (Object bc : args) { + if (bc instanceof OMElement) { + body.addChild((OMElement)bc); + } else { + throw new IllegalArgumentException( + "Can't handle mixed payloads between OMElements and other types."); + } + } + } + final MessageContext requestMC = new MessageContext(); + requestMC.setEnvelope(env); + + // Axis2 operationClients can not be shared so create a new one for each request + final OperationClient operationClient = serviceClient.getServiceClient().createClient(wsdlOperationName); + operationClient.setOptions(options); + + ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); + + // set callback endpoint and callback ID for WS-Addressing header + EndpointReference fromEPR = null; + org.apache.tuscany.sca.runtime.EndpointReference callbackEPR = parameters.getCallbackReference(); + if (callbackEPR != null) { + fromEPR = new EndpointReference(callbackEPR.getBinding().getURI()); + } + Object callbackID = parameters.getCallbackID(); + if (callbackID != null) { + if (fromEPR == null) { + fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL); + } + //FIXME: serialize callback ID to XML in case it is not a string + fromEPR.addReferenceParameter(CALLBACK_ID_REFPARM_QN, callbackID.toString()); + } + + // set conversation ID for WS-Addressing header + Object conversationId = parameters.getConversationID(); + if (conversationId != null) { + if (fromEPR == null) { + fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL); + } + //FIXME: serialize conversation ID to XML in case it is not a string + fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId.toString()); + } + + // add WS-Addressing header + //FIXME: is there any way to use the Axis2 addressing support for this? + if (fromEPR != null) { + SOAPEnvelope sev = requestMC.getEnvelope(); + SOAPHeader sh = sev.getHeader(); + OMElement epr = + EndpointReferenceHelper.toOM(sev.getOMFactory(), + fromEPR, + QNAME_WSA_FROM, + AddressingConstants.Final.WSA_NAMESPACE); + sh.addChild(epr); + requestMC.setFrom(fromEPR); + } + + // Set any message headers required by policy + // Get the header from the tuscany message + // If its not already an OM convert it to OM + // add it to the envelope header + + // if target endpoint was not specified when this invoker was created, + // use dynamically specified target endpoint passed in on this call + if (options.getTo() == null) { + org.apache.tuscany.sca.runtime.EndpointReference ep = msg.getTo(); + if (ep != null) { + requestMC.setTo(new EndpointReference(ep.getURI())); + } else { + throw new RuntimeException("Unable to determine destination endpoint"); + } + } else { + requestMC.setTo(new EndpointReference(options.getTo().getAddress())); + } + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws AxisFault { + operationClient.addMessageContext(requestMC); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + return operationClient; + } + + public boolean allowsPassByReference() { + return true; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java new file mode 100644 index 0000000000..b1923bdf3c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandlerDefinitionsLoader; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.work.WorkScheduler; + +/** + * Axis2BindingProviderFactory + * + * @version $Rev$ $Date$ + */ + +public class Axis2BindingProviderFactory implements BindingProviderFactory { + + private ModelFactoryExtensionPoint modelFactories; + private List hosts; + private List policyHandlerClassnames = null; + private DataBindingExtensionPoint dataBindings; + private WorkScheduler workScheduler; + + public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); + hosts = servletHosts.getServletHosts(); + + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + policyHandlerClassnames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames(); + dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + workScheduler = utilities.getUtility(WorkScheduler.class); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + WebServiceBinding binding) { + return new Axis2ReferenceBindingProvider(component, reference, binding, + modelFactories, policyHandlerClassnames, dataBindings); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + WebServiceBinding binding) { + ServletHost servletHost = null; + + if (!hosts.isEmpty()) { + servletHost = hosts.get(0); + } + + return new Axis2ServiceBindingProvider(component, service, binding, + servletHost, modelFactories, + policyHandlerClassnames, dataBindings, workScheduler); + } + + public Class getModelType() { + return WebServiceBinding.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java new file mode 100644 index 0000000000..f8d0cf55b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + +/** + * Axis2OneWayBindingInvoker uses an Axis2 OperationClient to invoke a OneWay remote web service. + * + * @version $Rev$ $Date$ + */ +public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker { + + public Axis2OneWayBindingInvoker(Axis2ServiceClient serviceClient, + QName wsdlOperationName, + Options options, + SOAPFactory soapFactory, + List policyHandlerList, + WebServiceBinding wsBinding) { + + super(serviceClient, wsdlOperationName, options, soapFactory, policyHandlerList, wsBinding); + } + + @Override + protected Object invokeTarget(Message msg) throws AxisFault { + OperationClient operationClient = createOperationClient(msg); + + // ensure connections are tracked so that they can be closed by the reference binding + MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); + //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + Options opt = requestMC.getOptions(); + opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + opt.setUseSeparateListener(true); + opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE); + + operationClient.execute(false); + + // REVIEW it seems ok to return null + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java new file mode 100644 index 0000000000..958d4aa41d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider { + + private WebServiceBinding wsBinding; + private Axis2ServiceClient axisClient; + + public Axis2ReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + WebServiceBinding wsBinding, + ModelFactoryExtensionPoint modelFactories, + List policyHandlerClassnames, + DataBindingExtensionPoint dataBindings) { + + MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class); + this.wsBinding = wsBinding; + + // A WSDL document should always be present in the binding + if (wsBinding.getWSDLDocument() == null) { + throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + reference.getName()); + } + + // Set to use the Axiom data binding + InterfaceContract contract = wsBinding.getBindingInterfaceContract(); + if (contract.getInterface() != null) { + contract.getInterface().resetDataBinding(OMElement.class.getName()); + } + + axisClient = new Axis2ServiceClient(component, reference, wsBinding, messageFactory, policyHandlerClassnames); + } + + public void start() { + axisClient.start(); + } + + public void stop() { + axisClient.stop(); + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public Invoker createInvoker(Operation operation) { + return axisClient.createInvoker(operation); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java new file mode 100644 index 0000000000..8a4b64d266 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.work.WorkScheduler; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceBindingProvider implements ServiceBindingProvider { + + private WebServiceBinding wsBinding; + private Axis2ServiceProvider axisProvider; + + public Axis2ServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + WebServiceBinding wsBinding, + ServletHost servletHost, + ModelFactoryExtensionPoint modelFactories, + List policyHandlerClassnames, + DataBindingExtensionPoint dataBindings, + WorkScheduler workScheduler) { + + if (servletHost == null) { + throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services"); + } + + MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class); + this.wsBinding = wsBinding; + + // A WSDL document should always be present in the binding + if (wsBinding.getWSDLDocument() == null) { + throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + service.getName()); + } + + // Set to use the Axiom data binding + InterfaceContract contract = wsBinding.getBindingInterfaceContract(); + contract.getInterface().resetDataBinding(OMElement.class.getName()); + + axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, policyHandlerClassnames, workScheduler); + } + + public void start() { + axisProvider.start(); + } + + public void stop() { + axisProvider.stop(); + } + + public InterfaceContract getBindingInterfaceContract() { + return wsBinding.getBindingInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java new file mode 100644 index 0000000000..0d3916019f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java @@ -0,0 +1,503 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.SOAP12_INTENT; +import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.isIntentRequired; + +import java.io.IOException; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Port; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.namespace.QName; +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.dom.DOMSource; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.addressing.EndpointReferenceHelper; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.AxisEndpoint; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.WSDL11ToAxisServiceBuilder; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.util.threadpool.ThreadPool; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.params.HttpConnectionManagerParams; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.xsd.xml.XMLDocumentHelper; +import org.apache.ws.commons.schema.resolver.URIResolver; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceClient { + + private RuntimeComponent component; + private AbstractContract contract; + private WebServiceBinding wsBinding; + private ServiceClient serviceClient; + List policyHandlerClassnames = null; + private List policyHandlerList = new ArrayList(); + + public Axis2ServiceClient(RuntimeComponent component, + AbstractContract contract, + WebServiceBinding wsBinding, + MessageFactory messageFactory, + List policyHandlerClassnames) { + + this.component = component; + this.contract = contract; + this.wsBinding = wsBinding; + this.policyHandlerClassnames = policyHandlerClassnames; + } + + protected void start() { + if (serviceClient == null) { + this.serviceClient = createServiceClient(); + } + } + + public ServiceClient getServiceClient() { + return serviceClient; + } + + protected void configurePolicy(ConfigurationContext context, PolicySet ps) throws AxisFault { + if (ps == null) { + return; + } + for (Object policy : ps.getPolicies()) { + if (policy instanceof Axis2ConfigParamPolicy) { + Axis2ConfigParamPolicy axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + for (Map.Entry param : axis2ConfigParamPolicy.getParamElements().entrySet()) { + Parameter configParam = new Parameter(param.getKey(), param.getValue().getFirstElement()); + configParam.setParameterElement(param.getValue()); + context.getAxisConfiguration().addParameter(configParam); + } + } + } + } + + /** + * Create an Axis2 ServiceClient + */ + protected ServiceClient createServiceClient() { + try { + final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding); + ConfigurationContext configContext; + + try { + // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); + // Allow privileged access to read properties. Requires PropertyPermission read in + // security policy. + TuscanyAxisConfigurator tuscanyAxisConfigurator = + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public TuscanyAxisConfigurator run() throws AxisFault { + return new TuscanyAxisConfigurator(isRampartRequired); + } + }); + configContext = tuscanyAxisConfigurator.getConfigurationContext(); + // deployRampartModule(); + // configureSecurity(); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } + + createPolicyHandlers(); + setupPolicyHandlers(policyHandlerList, configContext); + + Definition definition = wsBinding.getWSDLDocument(); + QName serviceQName = wsBinding.getService().getQName(); + Port port = wsBinding.getPort(); + if (port == null) { + // service has multiple ports, select one port to use + Collection ports = wsBinding.getService().getPorts().values(); + for (Port p : ports) { + // look for a SOAP 1.1 port first + if (p.getExtensibilityElements().get(0) instanceof SOAPAddress) { + port = p; + break; + } + } + if (port == null) { + // no SOAP 1.1 port available, so look for a SOAP 1.2 port + for (Port p : ports) { + if (p.getExtensibilityElements().get(0) instanceof SOAP12Address) { + port = p; + break; + } + } + } + } + AxisService axisService = + createClientSideAxisService(definition, serviceQName, port.getName(), new Options()); + + HttpClient httpClient = (HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT); + if (httpClient == null) { + MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); + HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams(); + connectionManagerParams.setDefaultMaxConnectionsPerHost(2); + connectionManagerParams.setTcpNoDelay(true); + connectionManagerParams.setStaleCheckingEnabled(true); + connectionManagerParams.setLinger(0); + connectionManager.setParams(connectionManagerParams); + httpClient = new HttpClient(connectionManager); + configContext.setThreadPool(new ThreadPool(1, 5)); + configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); + configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); + } + + return new ServiceClient(configContext, axisService); + + } catch (AxisFault e) { + throw new RuntimeException(e); // TODO: better exception + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + /** + * URI resolver implementation for XML schema + */ + public static class URIResolverImpl implements URIResolver { + private Definition definition; + + public URIResolverImpl(Definition definition) { + this.definition = definition; + } + + public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace, + java.lang.String schemaLocation, + java.lang.String baseUri) { + try { + if (baseUri == null) { + baseUri = definition.getDocumentBaseURI(); + } + URL url = new URL(new URL(baseUri), schemaLocation); + return XMLDocumentHelper.getInputSource(url); + } catch (IOException e) { + return null; + } + } + } + + /** + * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 + * @param definition + * @param serviceName + * @return + */ + private static Definition getDefinition(Definition definition, QName serviceName) { + + if (serviceName == null) { + return definition; + } + + if (definition == null) { + return null; + } + Object service = definition.getServices().get(serviceName); + if (service != null) { + return definition; + } + for (Object i : definition.getImports().values()) { + List imports = (List)i; + for (Import imp : imports) { + Definition d = getDefinition(imp.getDefinition(), serviceName); + if (d != null) { + return d; + } + } + } + return null; + } + + /** + * This method is copied from AxisService.createClientSideAxisService to + * work around http://issues.apache.org/jira/browse/WSCOMMONS-228 + * + * @param wsdlDefinition + * @param wsdlServiceName + * @param portName + * @param options + * @return + * @throws AxisFault + */ + @Deprecated + public static AxisService createClientSideAxisService(Definition definition, + QName serviceName, + String portName, + Options options) throws AxisFault { + Definition def = getDefinition(definition, serviceName); + final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, serviceName, portName); + serviceBuilder.setServerSide(false); + // [rfeng] Add a custom resolver to work around WSCOMMONS-228 + serviceBuilder.setCustomResolver(new URIResolverImpl(def)); + serviceBuilder.setBaseUri(def.getDocumentBaseURI()); + // [rfeng] + // Allow access to read properties. Requires PropertiesPermission in security policy. + AxisService axisService; + try { + axisService = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public AxisService run() throws AxisFault { + return serviceBuilder.populateService(); + } + }); + } catch ( PrivilegedActionException e ) { + throw (AxisFault) e.getException(); + } + + AxisEndpoint axisEndpoint = (AxisEndpoint)axisService.getEndpoints().get(axisService.getEndpointName()); + options.setTo(new EndpointReference(axisEndpoint.getEndpointURL())); + if (axisEndpoint != null) { + options.setSoapVersionURI((String)axisEndpoint.getBinding().getProperty(WSDL2Constants.ATTR_WSOAP_VERSION)); + } + return axisService; + } + + /* + private static T getExtensibilityElement(List elements, Class type) { + for (Object e : elements) { + if (type.isInstance(e)) { + return type.cast(e); + } + } + return null; + } + */ + + protected void stop() { + if (serviceClient != null) { + // close all connections that we have initiated, so that the jetty server + // can be restarted without seeing ConnectExceptions + HttpClient httpClient = + (HttpClient)serviceClient.getServiceContext().getConfigurationContext() + .getProperty(HTTPConstants.CACHED_HTTP_CLIENT); + if (httpClient != null) + ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown(); + + serviceClient = null; + } + } + + /** + * Create and configure an Axis2BindingInvoker for each operation + */ + protected Invoker createInvoker(Operation operation) { + Options options = new Options(); + EndpointReference epTo = getWSATOEPR(wsBinding); + if (epTo != null) { + options.setTo(epTo); + } + options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE); + + String operationName = operation.getName(); + + String soapAction = getSOAPAction(operationName); + if (soapAction != null && soapAction.length() > 1) { + options.setAction(soapAction); + } + + options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds + + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + SOAPFactory soapFactory = AccessController.doPrivileged(new PrivilegedAction() { + public SOAPFactory run() { + if (requiresSOAP12()) + return OMAbstractFactory.getSOAP12Factory(); + else + return OMAbstractFactory.getSOAP11Factory(); + + } + }); + QName wsdlOperationQName = new QName(operationName); + if (requiresMTOM()) + { + options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM, org.apache.axis2.Constants.VALUE_TRUE); + } + Axis2BindingInvoker invoker; + if (operation.isNonBlocking()) { + invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding); + } else { + invoker = new Axis2BindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding); + } + + return invoker; + } + + private boolean requiresSOAP12() { + return isIntentRequired(wsBinding, SOAP12_INTENT); + } + + private boolean requiresMTOM() { + return isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT); + } + + protected EndpointReference getWSATOEPR(WebServiceBinding binding) { + EndpointReference epr = getEPR(binding); + if (epr == null) { + epr = getPortLocationEPR(binding); + } else if (epr.getAddress() == null || epr.getAddress().length() < 1) { + EndpointReference bindingEPR = getPortLocationEPR(binding); + if (bindingEPR != null) { + epr.setAddress(bindingEPR.getAddress()); + } + } + return epr; + } + + protected EndpointReference getPortLocationEPR(WebServiceBinding binding) { + String ep = null; + if (binding.getPort() != null) { + List wsdlPortExtensions = binding.getPort().getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + ep = ((SOAPAddress)extension).getLocationURI(); + break; + } + if (extension instanceof SOAP12Address) { + SOAP12Address address = (SOAP12Address)extension; + ep = address.getLocationURI(); + break; + } + } + } + if(ep == null || ep.equals("")) { + ep = binding.getURI(); + } + return ep == null || "".equals(ep) ? null : new EndpointReference(ep); + } + + protected org.apache.axis2.addressing.EndpointReference getEPR(WebServiceBinding wsBinding) { + if (wsBinding.getEndPointReference() == null) { + return null; + } + try { + + XMLStreamReader parser = + XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(wsBinding.getEndPointReference())); + StAXOMBuilder builder = new StAXOMBuilder(parser); + OMElement omElement = builder.getDocumentElement(); + org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement); + return epr; + + } catch (IOException e) { + throw new RuntimeException(e); + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } catch (FactoryConfigurationError e) { + throw new RuntimeException(e); + } + } + + protected String getSOAPAction(String operationName) { + Binding binding = wsBinding.getBinding(); + if (binding != null) { + for (Object o : binding.getBindingOperations()) { + BindingOperation bop = (BindingOperation)o; + if (bop.getName().equalsIgnoreCase(operationName)) { + for (Object o2 : bop.getExtensibilityElements()) { + if (o2 instanceof SOAPOperation) { + return ((SOAPOperation)o2).getSoapActionURI(); + } + } + } + } + } + return null; + } + + private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException { + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + PolicyHandler policyHandler = null; + for (PolicySet policySet : policiedBinding.getPolicySets()) { + policyHandler = PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames); + if (policyHandler != null) { + policyHandler.setApplicablePolicySet(policySet); + policyHandlerList.add(policyHandler); + } + } + + // code to create policy handlers using the new policy SPI based + // on policy providers +/* + List policyProviders = ((RuntimeComponentReference)contract).getPolicyProviders(wsBinding); + + for (PolicyProvider policyProvider : policyProviders){ + policyHandler = policyProvider.createHandler(); + if (policyHandler != null) { + policyHandlerList.add(policyHandler); + } + } +*/ + } + } + + private void setupPolicyHandlers(List policyHandlers, ConfigurationContext configContext) { + for (PolicyHandler aHandler : policyHandlers) { + aHandler.setUp(configContext); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java new file mode 100644 index 0000000000..a0cfab9154 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.apache.axiom.om.OMElement; +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.receivers.AbstractInMessageReceiver; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + +public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver { + + protected Operation operation; + + private Axis2ServiceProvider provider; + + private List policyHandlerList = null; + + public Axis2ServiceInMessageReceiver(Axis2ServiceProvider provider, Operation operation, List policyHandlerList) { + this.provider = provider; + this.operation = operation; + this.policyHandlerList = policyHandlerList; + } + + public Axis2ServiceInMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + Object[] args = new Object[] {requestOM}; + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(operation, args, inMC); + } + */ + + provider.invokeTarget(operation, args, inMC); + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(operation, args, inMC); + } + */ + + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof Exception) { + throw AxisFault.makeFault((Exception)t); + } + throw new RuntimeException(e); + } catch (Exception e) { + e.printStackTrace(); + throw AxisFault.makeFault(e); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java new file mode 100644 index 0000000000..d467e0b3c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.osoa.sca.ServiceRuntimeException; + +public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver { + private static final Logger logger = Logger.getLogger(Axis2ServiceInOutSyncMessageReceiver.class.getName()); + + protected Operation operation; + private List policyHandlerList = null; + + private Axis2ServiceProvider provider; + + public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceProvider provider, Operation operation, List policyHandlerList) { + this.provider = provider; + this.operation = operation; + this.policyHandlerList = policyHandlerList; + } + + public Axis2ServiceInOutSyncMessageReceiver() { + } + + @Override + public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault { + try { + OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement(); + Object[] args = null; + + if (requestOM != null) { + args = new Object[] {requestOM}; + } + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(operation, args, inMC); + } + */ + + OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, inMC); + + /* + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(operation, args, inMC, responseOM); + } + */ + + SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope(); + if (null != responseOM ) { + soapEnvelope.getBody().addChild(responseOM); + } + outMC.setEnvelope(soapEnvelope); + outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE); + + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof FaultException && ((FaultException)t).getFaultInfo() instanceof OMElement) { + OMElement faultDetail = (OMElement)((FaultException)t).getFaultInfo(); + inMC.setProperty(Constants.FAULT_NAME, faultDetail.getQName().getLocalPart()); + AxisFault f = new AxisFault(null, e.getMessage(), "faultNode", "faultRole", faultDetail); + throw f; + } + if (t instanceof Exception) { + throw AxisFault.makeFault((Exception)t); + } + logger.log(Level.SEVERE, e.getMessage(), t); + throw new ServiceRuntimeException(e); + } catch (Throwable e) { + logger.log(Level.SEVERE, e.getMessage(), e); + throw AxisFault.makeFault(e); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java new file mode 100644 index 0000000000..62a18d62ac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java @@ -0,0 +1,843 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Port; +import javax.wsdl.Types; +import javax.wsdl.extensions.UnknownExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.addressing.AddressingConstants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.deployment.util.Utils; +import org.apache.axis2.description.AxisEndpoint; +import org.apache.axis2.description.AxisOperation; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.description.TransportOutDescription; +import org.apache.axis2.description.WSDL11ToAxisServiceBuilder; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.description.WSDLToAxisServiceBuilder; +import org.apache.axis2.engine.ListenerManager; +import org.apache.axis2.engine.MessageReceiver; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.tuscany.sca.assembly.AbstractContract; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.binding.ws.WebServiceBinding; +import org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceClient.URIResolverImpl; +import org.apache.tuscany.sca.binding.ws.axis2.jms.JMSListener; +import org.apache.tuscany.sca.binding.ws.axis2.jms.JMSSender; +import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingBasicAuthenticationConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils; +import org.apache.tuscany.sca.runtime.EndpointReference; +import org.apache.tuscany.sca.runtime.ReferenceParameters; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.work.WorkScheduler; +import org.apache.tuscany.sca.xsd.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; +import org.apache.ws.security.WSSecurityEngineResult; +import org.apache.ws.security.handler.WSHandlerConstants; +import org.apache.ws.security.handler.WSHandlerResult; +import org.osoa.sca.ServiceRuntimeException; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + + +public class Axis2ServiceProvider { + public static final String IMPORT_TAG = "import"; + public static final String INCLUDE_TAG = "include"; + + private static final Logger logger = Logger.getLogger(Axis2ServiceProvider.class.getName()); + + private RuntimeComponent component; + private AbstractContract contract; + private WebServiceBinding wsBinding; + private ServletHost servletHost; + private MessageFactory messageFactory; + private ConfigurationContext configContext; + private JMSSender jmsSender; + private JMSListener jmsListener; + private List policyHandlerClassnames = null; + private List policyHandlerList = new ArrayList(); + private Map urlMap = new HashMap(); + + private BasicAuthenticationPolicy basicAuthenticationPolicy = null; + private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null; + private List axis2HeaderPolicies = new ArrayList(); + private WorkScheduler workScheduler; + + public static final QName QNAME_WSA_ADDRESS = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS); + public static final QName QNAME_WSA_FROM = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM); + public static final QName QNAME_WSA_REFERENCE_PARAMETERS = + new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS); + + private static final QName TRANSPORT_JMS_QUALIFIED_INTENT = + new QName("http://www.osoa.org/xmlns/sca/1.0", "transport.jms"); + private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory"; + + //Schema element names + public static final String ELEM_SCHEMA = "schema"; + + //Schema URI + public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema"; + public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema"; + public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema"; + + //Schema QNames + public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA); + public static final List XSD_QNAME_LIST = + Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001}); + + public Axis2ServiceProvider(RuntimeComponent component, + AbstractContract contract, + WebServiceBinding wsBinding, + ServletHost servletHost, + MessageFactory messageFactory, + List policyHandlerClassnames, + WorkScheduler workScheduler) { + + this.component = component; + this.contract = contract; + this.wsBinding = wsBinding; + this.servletHost = servletHost; + this.messageFactory = messageFactory; + this.policyHandlerClassnames = policyHandlerClassnames; + this.workScheduler = workScheduler; + + final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding); + try { + // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); + // Allow privileged access to read properties. Requires PropertyPermission read in + // security policy. + TuscanyAxisConfigurator tuscanyAxisConfigurator = + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public TuscanyAxisConfigurator run() throws AxisFault { + return new TuscanyAxisConfigurator(isRampartRequired); + } + }); + configContext = tuscanyAxisConfigurator.getConfigurationContext(); + // deployRampartModule(); + // configureSecurity(); + } catch (PrivilegedActionException e) { + throw new ServiceRuntimeException(e.getException()); + } catch (AxisFault e) { + throw new ServiceRuntimeException(e); // TODO: better exception + } + + configContext.setContextRoot(servletHost.getContextPath()); + + // Enable MTOM if the policy intent is specified. + if (AxisPolicyHelper.isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT)) { + configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false); + configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true"); + } + + // Update port addresses with runtime information, and create a + // map from endpoint URIs to WSDL ports that eliminates duplicate + // ports for the same endpoint. + for (Object port : wsBinding.getService().getPorts().values()) { + String portAddress = getPortAddress((Port)port); + String endpointURI = computeEndpointURI(portAddress, servletHost); + setPortAddress((Port)port, endpointURI); + urlMap.put(endpointURI, (Port)port); + } + + // find out which policies are active + if (wsBinding instanceof PolicySetAttachPoint) { + List policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (BasicAuthenticationPolicy.class.isInstance(p)) { + basicAuthenticationPolicy = (BasicAuthenticationPolicy)p; + } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p; + } else if (Axis2HeaderPolicy.class.isInstance(p)) { + axis2HeaderPolicies.add((Axis2HeaderPolicy)p); + } else { + // etc. check for other types of policy being present + } + } + } + } + } + + static String getPortAddress(Port port) { + Object ext = port.getExtensibilityElements().get(0); + if (ext instanceof SOAPAddress) { + return ((SOAPAddress)ext).getLocationURI(); + } + if (ext instanceof SOAP12Address) { + return ((SOAP12Address)ext).getLocationURI(); + } + return null; + } + + static void setPortAddress(Port port, String locationURI) { + Object ext = port.getExtensibilityElements().get(0); + if (ext instanceof SOAPAddress) { + ((SOAPAddress)ext).setLocationURI(locationURI); + } + if (ext instanceof SOAP12Address) { + ((SOAP12Address)ext).setLocationURI(locationURI); + } + } + + private String computeEndpointURI(String uri, ServletHost servletHost) { + + if (uri == null) { + return null; + } + + // pull out the binding intents to see what sort of transport is required + PolicySet transportJmsPolicySet = AxisPolicyHelper.getPolicySet(wsBinding, TRANSPORT_JMS_QUALIFIED_INTENT); + if (transportJmsPolicySet != null){ + if (!uri.startsWith("jms:/")) { + uri = "jms:" + uri; + } + + // construct the rest of the URI based on the policy. All the details are put + // into the URI here rather than being place directly into the Axis configuration + // as the Axis JMS sender relies on parsing the target URI + Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; + for ( Object policy : transportJmsPolicySet.getPolicies() ) { + if ( policy instanceof Axis2ConfigParamPolicy ) { + axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; + Iterator paramIterator = axis2ConfigParamPolicy.getParamElements().get(DEFAULT_QUEUE_CONNECTION_FACTORY).getChildElements(); + + if (paramIterator.hasNext()){ + StringBuffer uriParams = new StringBuffer("?"); + + while (paramIterator.hasNext()){ + OMElement parameter = (OMElement)paramIterator.next(); + uriParams.append(parameter.getAttributeValue(new QName("","name"))); + uriParams.append("="); + uriParams.append(parameter.getText()); + + if (paramIterator.hasNext()){ + uriParams.append("&"); + } + } + + uri = uri + uriParams; + } + } + } + } else { + if (!uri.startsWith("jms:")) { + uri = servletHost.getURLMapping(uri).toString(); + } + } + + return uri; + } + + public void start() { + + try { + createPolicyHandlers(); + for (Map.Entry entry : urlMap.entrySet()) { + AxisService axisService = createAxisService(entry.getKey(), entry.getValue()); + configContext.getAxisConfiguration().addService(axisService); + } + setupPolicyHandlers(policyHandlerList, configContext); + + Axis2ServiceServlet servlet = null; + for (String endpointURL : urlMap.keySet()) { + if (endpointURL.startsWith("http://") || endpointURL.startsWith("https://") || endpointURL.startsWith("/")) { + if (servlet == null) { + servlet = new Axis2ServiceServlet(); + servlet.init(configContext); + } + //[nash] configContext.setContextRoot(endpointURL); + servletHost.addServletMapping(endpointURL, servlet); + } else if (endpointURL.startsWith("jms")) { + logger.log(Level.INFO,"Axis2 JMS URL=" + endpointURL); + + jmsListener = new JMSListener(workScheduler); + jmsSender = new JMSSender(); + ListenerManager listenerManager = configContext.getListenerManager(); + TransportInDescription trsIn = configContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS); + + if (trsIn == null){ + trsIn = new TransportInDescription(Constants.TRANSPORT_JMS); + } + + // get JMS transport parameters from the computed URL + Map jmsProps = JMSUtils.getProperties(endpointURL); + + // collect the parameters used to configure the JMS transport + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement parms = fac.createOMElement(DEFAULT_QUEUE_CONNECTION_FACTORY, null); + + for ( String key : jmsProps.keySet() ) { + OMElement param = fac.createOMElement("parameter", null); + param.addAttribute( "name", key, null ); + param.addChild(fac.createOMText(param, jmsProps.get(key))); + parms.addChild(param); + } + + Parameter queueConnectionFactory = new Parameter(DEFAULT_QUEUE_CONNECTION_FACTORY, parms); + trsIn.addParameter( queueConnectionFactory ); + + trsIn.setReceiver(jmsListener); + + configContext.getAxisConfiguration().addTransportIn( trsIn ); + TransportOutDescription trsOut = configContext.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS); + //configContext.getAxisConfiguration().addTransportOut( trsOut ); + trsOut.setSender(jmsSender); + + if (listenerManager == null) { + listenerManager = new ListenerManager(); + listenerManager.init(configContext); + } + listenerManager.addListener(trsIn, true); + jmsSender.init(configContext, trsOut); + jmsListener.init(configContext, trsIn); + jmsListener.start(); + } + } + } catch (AxisFault e) { + throw new RuntimeException(e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public void stop() { + if ( jmsListener != null ) { + jmsListener.stop(); + jmsListener.destroy(); + } + else { + for (String endpointURL : urlMap.keySet()) { + servletHost.removeServletMapping(endpointURL); + } + } + + servletHost = null; + + if ( jmsSender != null ) + jmsSender.stop(); + + try { + for (String endpointURL : urlMap.keySet()) { + // get the path to the service + URI uriPath = new URI(endpointURL); + String stringURIPath = uriPath.getPath(); + + /* [nash] Need a leading slash for WSDL imports to work with ?wsdl + // remove any "/" from the start of the path + if (stringURIPath.startsWith("/")) { + stringURIPath = stringURIPath.substring(1, stringURIPath.length()); + } + */ + + configContext.getAxisConfiguration().removeService(stringURIPath); + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } catch (AxisFault e) { + throw new RuntimeException(e); + } + } + + private AxisService createAxisService(String endpointURL, Port port) throws AxisFault { + AxisService axisService; + if (wsBinding.getWSDLDocument() != null) { + axisService = createWSDLAxisService(endpointURL, port); + } else { + axisService = createJavaAxisService(endpointURL); + } + initAxisOperations(axisService); + return axisService; + } + + /** + * Create an AxisService from the interface class from the SCA service interface + */ + protected AxisService createJavaAxisService(String endpointURL) throws AxisFault { + AxisService axisService = new AxisService(); + String path = URI.create(endpointURL).getPath(); + axisService.setName(path); + axisService.setServiceDescription("Tuscany configured AxisService for service: " + endpointURL); + axisService.setClientSide(false); + Parameter classParam = + new Parameter(Constants.SERVICE_CLASS, ((JavaInterface)contract.getInterfaceContract().getInterface()) + .getJavaClass().getName()); + axisService.addParameter(classParam); + try { + Utils.fillAxisService(axisService, configContext.getAxisConfiguration(), null, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return axisService; + } + + /** + * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 + * @param definition + * @param serviceName + * @return + */ + private static Definition getDefinition(Definition definition, QName serviceName) { + + if (serviceName == null){ + return definition; + } + + if (definition == null) { + return null; + } + Object service = definition.getServices().get(serviceName); + if (service != null) { + return definition; + } + for (Object i : definition.getImports().values()) { + List imports = (List)i; + for (Import imp : imports) { + Definition d = getDefinition(imp.getDefinition(), serviceName); + if (d != null) { + return d; + } + } + } + return null; + } + + /** + * Create an AxisService from the WSDL doc used by ws binding + */ + protected AxisService createWSDLAxisService(String endpointURL, Port port) throws AxisFault { + + Definition definition = wsBinding.getWSDLDocument(); + QName serviceQName = wsBinding.getService().getQName(); + Definition def = getDefinition(definition, serviceQName); + + // TUSCANY-2824 fix the target namespace of the definition to be the same as + // that for the port. Without this Axis fails during policy application + // when it tries to match binding operation names to port type operation + // names + //def.setTargetNamespace(port.getBinding().getPortType().getQName().getNamespaceURI()); + + + final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, port.getName()); + builder.setServerSide(true); + // [rfeng] Add a custom resolver to work around WSCOMMONS-228 + builder.setCustomResolver(new URIResolverImpl(def)); + builder.setBaseUri(def.getDocumentBaseURI()); + // [rfeng] + // AxisService axisService = builder.populateService(); + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + AxisService axisService; + try { + axisService = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public AxisService run() throws AxisFault { + return builder.populateService(); + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + + String name = URI.create(endpointURL).getPath(); + //[nash] HTTP endpoints need a leading slash for WSDL imports to work with ?wsdl + if (endpointURL.startsWith("jms")) { + name = name.startsWith("/") ? name.substring(1) : name; + } + axisService.setName(name); + axisService.setEndpointURL(endpointURL); + axisService.setDocumentation("Tuscany configured AxisService for service: " + endpointURL); + for ( Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext(); ) { + AxisEndpoint ae = (AxisEndpoint)i.next(); + if (endpointURL.startsWith("jms") ) { + Parameter qcf = new Parameter(JMSConstants.CONFAC_PARAM, null); + qcf.setValue(DEFAULT_QUEUE_CONNECTION_FACTORY); + axisService.addParameter(qcf); + break; + } + } + + // Add schema information to the AxisService (needed for "?xsd=" support) + addSchemas(wsBinding.getWSDLDefinition(), axisService); + + // Use the existing WSDL + Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null); + wsdlParam.setValue(definition); + axisService.addParameter(wsdlParam); + Parameter userWSDL = new Parameter("useOriginalwsdl", "true"); + axisService.addParameter(userWSDL); + + // Modify schema imports and includes to add "servicename?xsd=" prefix. + // Axis2 does this for schema extensibility elements, but Tuscany has + // overriden the WSDl4J deserializer to create UnknownExtensibilityElement + // elements in place of these. + modifySchemaImportsAndIncludes(definition, name); + + // Axis2 1.3 has a bug with returning incorrect values for the port + // addresses. To work around this, compute the values here. + Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false"); + axisService.addParameter(modifyAddr); + + return axisService; + } + + private void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) { + for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) { + if (xsDef.getSchema() != null) { + axisService.addSchema(xsDef.getSchema()); + updateSchemaRefs(xsDef.getSchema(), axisService.getName()); + } + } + for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) { + addSchemas(impDef, axisService); + } + } + + private void updateSchemaRefs(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + String location = extSchema.getSchemaLocation(); + if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) { + extSchema.setSchemaLocation(name + "?xsd=" + location); + } + if (extSchema.getSchema() != null) { + updateSchemaRefs(extSchema.getSchema(), name); + } + } + } + } + + private void modifySchemaImportsAndIncludes(Definition definition, String name){ + // adjust the schema locations in types section + Types types = definition.getTypes(); + if (types != null) { + for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) { + Object ext = iter.next(); + if (ext instanceof UnknownExtensibilityElement && + XSD_QNAME_LIST.contains(((UnknownExtensibilityElement)ext).getElementType())) { + changeLocations(((UnknownExtensibilityElement)ext).getElement(), name); + } + } + } + for (Iterator iter = definition.getImports().values().iterator(); iter.hasNext();) { + Vector values = (Vector)iter.next(); + for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) { + Import wsdlImport = (Import)valuesIter.next(); + modifySchemaImportsAndIncludes(wsdlImport.getDefinition(), name); + } + } + } + + private void changeLocations(Element element, String name) { + NodeList nodeList = element.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + String tagName = nodeList.item(i).getLocalName(); + if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) { + processImport(nodeList.item(i), name); + } + } + } + + private void processImport(Node importNode, String name) { + NamedNodeMap nodeMap = importNode.getAttributes(); + for (int i = 0; i < nodeMap.getLength(); i++) { + Node attribute = nodeMap.item(i); + if (attribute.getNodeName().equals("schemaLocation")) { + String location = attribute.getNodeValue(); + if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) { + attribute.setNodeValue(name + "?xsd=" + location); + } + } + } + } + + protected void initAxisOperations(AxisService axisService) { + for (Iterator i = axisService.getOperations(); i.hasNext();) { + AxisOperation axisOp = (AxisOperation)i.next(); + Operation op = getOperation(axisOp); + if (op != null) { + + if (op.isNonBlocking()) { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY); + } else { + axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT); + } + + MessageReceiver msgrec = null; + if (op.isNonBlocking()) { + msgrec = new Axis2ServiceInMessageReceiver(this, op, policyHandlerList); + } else { + msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op, policyHandlerList); + } + axisOp.setMessageReceiver(msgrec); + } + } + } + + protected Operation getOperation(AxisOperation axisOp) { + String operationName = axisOp.getName().getLocalPart(); + Interface iface = wsBinding.getBindingInterfaceContract().getInterface(); + for (Operation op : iface.getOperations()) { + if (op.getName().equalsIgnoreCase(operationName)) { + return op; + } + } + return null; + } + + // methods for Axis2 message receivers + + public Object invokeTarget(Operation op, Object[] args, MessageContext inMC) throws InvocationTargetException { + String callbackAddress = null; + String callbackID = null; + Object conversationID = null; + + // create a message object and set the args as its body + Message msg = messageFactory.createMessage(); + msg.setBody(args); + msg.setOperation(op); + + //FIXME: can we use the Axis2 addressing support for this? + SOAPHeader header = inMC.getEnvelope().getHeader(); + if (header != null) { + OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM); + if (from != null) { + OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS); + if (callbackAddrElement != null) { + if (contract.getInterfaceContract().getCallbackInterface() != null) { + callbackAddress = callbackAddrElement.getText(); + } + } + OMElement params = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS); + if (params != null) { + OMElement convIDElement = + params.getFirstChildWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN); + if (convIDElement != null) { + if (isConversational()) { + conversationID = convIDElement.getText(); + } + } + OMElement callbackIDElement = + params.getFirstChildWithName(Axis2BindingInvoker.CALLBACK_ID_REFPARM_QN); + if (callbackIDElement != null) { + callbackID = callbackIDElement.getText(); + } + } + } + + // get policy specified headers + for (Axis2HeaderPolicy policy : axis2HeaderPolicies){ + //Axis2BindingHeaderConfigurator.getHeader(inMC, msg, policy.getHeaderName()); + } + + if (axis2TokenAuthenticationPolicy != null) { + Axis2SOAPHeaderString tokenHeader = new Axis2SOAPHeaderString(); + Axis2BindingHeaderConfigurator.getHeader(inMC, + msg, + axis2TokenAuthenticationPolicy.getTokenName(), + tokenHeader); + } + } + + //fill message with QoS context info + fillQoSContext(msg, inMC); + + // if reference parameters are needed, create a new "From" EPR to hold them + EndpointReference from = null; + ReferenceParameters parameters = null; + if (callbackAddress != null || + callbackID != null || + conversationID != null) { + from = new EndpointReferenceImpl(null); + parameters = from.getReferenceParameters(); + msg.setFrom(from); + } + + // set the reference parameters into the "From" EPR + if (callbackAddress != null) { + parameters.setCallbackReference(new EndpointReferenceImpl(callbackAddress)); + } + if (callbackID != null) { + parameters.setCallbackID(callbackID); + } + if (conversationID != null) { + parameters.setConversationID(conversationID); + } + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.beforeInvoke(msg, inMC); + } + + if (basicAuthenticationPolicy != null) { + Axis2BindingBasicAuthenticationConfigurator.parseHTTPHeader(inMC, msg, basicAuthenticationPolicy); + } + + // find the runtime wire and invoke it with the message + RuntimeWire wire = ((RuntimeComponentService)contract).getRuntimeWire(getBinding()); + Object response = wire.invoke(op, msg); + + for ( PolicyHandler policyHandler : policyHandlerList ) { + policyHandler.afterInvoke(response, inMC); + } + + return response; + } + + public boolean isConversational() { + return wsBinding.getBindingInterfaceContract().getInterface().isConversational(); + } + + /** + * Return the binding for this provider as a primitive binding type + * For use when looking up wires registered against the binding. + * + * @return the binding + */ + protected Binding getBinding() { + return wsBinding; + } + + private void setupPolicyHandlers(List policyHandlers, ConfigurationContext configContext) { + for ( PolicyHandler aHandler : policyHandlers ) { + aHandler.setUp(configContext); + } + } + + private void createPolicyHandlers() throws IllegalAccessException, + InstantiationException, + ClassNotFoundException { + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + PolicyHandler policyHandler = null; + + for (PolicySet policySet : policiedBinding.getPolicySets()) { + policyHandler = + PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames); + + if (policyHandler != null) { + policyHandler.setApplicablePolicySet(policySet); + policyHandlerList.add(policyHandler); + } + } + + // code to create policy handlers using a policy SPI based + // on policy providers +/* + List policyProviders = ((RuntimeComponentService)contract).getPolicyProviders(wsBinding); + + for (PolicyProvider policyProvider : policyProviders){ + policyHandler = policyProvider.createHandler(); + if (policyHandler != null) { + policyHandlerList.add(policyHandler); + } + } +*/ + } + } + + private void fillQoSContext(Message message, MessageContext axis2MsgCtx) { + if ( axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS) != null && + axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS) instanceof Vector ) { + Vector recvResults = (Vector)axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS); + for ( int count1 = 0 ; count1 < recvResults.size() ; ++count1 ) { + if ( recvResults.elementAt(count1) instanceof WSHandlerResult ) { + WSHandlerResult wshr = (WSHandlerResult)recvResults.elementAt(count1); + Vector results = wshr.getResults(); + for ( int count2 = 0 ; count2 < results.size() ; ++count2 ) { + if ( results.elementAt(count2) instanceof WSSecurityEngineResult ) { + WSSecurityEngineResult securityResult = + (WSSecurityEngineResult)wshr.getResults().elementAt(count2); + if ( securityResult.get("principal") != null ) { + message.getHeaders().add(securityResult.get("principal")); + } + } + } + } + } + + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java new file mode 100644 index 0000000000..debb2c5764 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java @@ -0,0 +1,356 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.net.MalformedURLException; +import java.net.SocketException; +import java.net.URI; +import java.net.URL; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Set; +import java.util.Vector; + +import javax.servlet.GenericServlet; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.ListenerManager; +import org.apache.axis2.transport.http.AxisServlet; +import org.apache.axis2.transport.http.ListingAgent; +import org.apache.axis2.transport.http.server.HttpUtils; + +/** + * This overrides the Servlet init of the AxisServlet so Tuscany can use + * a single Axis2 ConfigurationContext instance shared between AxisServlet + * instances for each SCA service with a ws binding. + * TODO: need to review if thats really what we want to be doing + * + * @version $Rev$ $Date$ + */ +public class Axis2ServiceServlet extends AxisServlet { + + protected TuscanyListingAgent agent; + + private static final long serialVersionUID = 1L; + private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig(); + + 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); + + // A copy of the init method from the base class because we need to replace the + // version of the ListenerManager that is used so that we can get it's + // shutdown hook removed properly. + + // prevent this method from being called more than once per instance + if (initCalled == false) { + initCalled = true; + // We can't call super.init() as it will just call the AxisServlet version + // which we are replacing here. So reflect on the base class and + // set the private config field in the base class. + //super.init(config); + try { + Field field = GenericServlet.class.getDeclaredField("config"); + field.setAccessible(true); + field.set(this, config); + } catch (Exception ex){ + ex.printStackTrace(); + } + + try { + this.servletConfig = config; + //ServletContext servletContext = servletConfig.getServletContext(); + this.configContext = + (ConfigurationContext) servletContext.getAttribute(CONFIGURATION_CONTEXT); + if(configContext == null){ + configContext = initConfigContext(config); + config.getServletContext().setAttribute(CONFIGURATION_CONTEXT, configContext); + } + axisConfiguration = configContext.getAxisConfiguration(); + + ListenerManager listenerManager = new TuscanyListenerManager(); + listenerManager.init(configContext); + TransportInDescription transportInDescription = new TransportInDescription( + Constants.TRANSPORT_HTTP); + transportInDescription.setReceiver(this); + listenerManager.addListener(transportInDescription, true); + listenerManager.start(); + ListenerManager.defaultConfigurationContext = configContext; + super.agent = new ListingAgent(configContext); + + initParams(); + + } catch (Exception e) { + throw new ServletException(e); + } + } + } + + /** + * 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-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java new file mode 100644 index 0000000000..1f389b422f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPoint; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +/** + * @version $Rev$ $Date$ + */ +public class AxisPolicyHelper { + + public static final String XMLNS_SCA_1_0 = "http://www.osoa.org/xmlns/sca/1.0"; + public static final QName AUTHENTICATION_INTENT = new QName(XMLNS_SCA_1_0, "authentication"); + public static final QName CONFIDENTIALITY_INTENT = new QName(XMLNS_SCA_1_0, "confidentiality"); + public static final QName INTEGRITY_INTENT = new QName(XMLNS_SCA_1_0, "integrity"); + public static final QName MTOM_INTENT = new QName(XMLNS_SCA_1_0, "MTOM"); + public static final QName SOAP12_INTENT = new QName(XMLNS_SCA_1_0, "SOAP12"); + + public static PolicySet getPolicySet(Binding wsBinding, QName intentName) { + PolicySet returnPolicySet = null; + + if (wsBinding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; + for (PolicySet policySet : policiedBinding.getPolicySets()) { + for (Intent intent : policySet.getProvidedIntents()) { + if (intent.getName().equals(intentName)) { + returnPolicySet = policySet; + break; + } + } + } + } + + return returnPolicySet; + } + + public static boolean isIntentRequired(Binding wsBinding, QName intent) { + if (wsBinding instanceof IntentAttachPoint) { + List intents = ((IntentAttachPoint)wsBinding).getRequiredIntents(); + for (Intent i : intents) { + if (intent.equals(i.getName())) { + return true; + } + } + } + return getPolicySet(wsBinding, intent) != null; + } + + public static boolean isRampartRequired(Binding wsBinding) { + return isIntentRequired(wsBinding, AUTHENTICATION_INTENT) || isIntentRequired(wsBinding, INTEGRITY_INTENT) + || isIntentRequired(wsBinding, CONFIDENTIALITY_INTENT); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java new file mode 100644 index 0000000000..bd154dbc67 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java @@ -0,0 +1,207 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.deployment.DeploymentConstants; +import org.apache.axis2.deployment.DeploymentErrorMsgs; +import org.apache.axis2.deployment.DeploymentException; +import org.apache.axis2.deployment.ModuleBuilder; +import org.apache.axis2.deployment.URLBasedAxisConfigurator; +import org.apache.axis2.description.AxisModule; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.AxisConfigurator; +import org.apache.axis2.i18n.Messages; +import org.apache.axis2.util.Loader; + +/** + * Helps configure Axis2 from a resource in binding.ws.axis2 instead of Axis2.xml + *

TODO: Review: should there be a single global Axis ConfigurationContext + * + * @version $Rev$ $Date$ + */ +public class TuscanyAxisConfigurator extends URLBasedAxisConfigurator implements AxisConfigurator { + + /* these two fields are part of a temporary fix to solve problems that Maven has with including + * rampart-1.4.mar into the classpath and also at the time of Release 1.0 rampart-1.4.mar seems + * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded + * as a Maven dependency and has been packed with this module + */ + /************start of fix *********************************************************************/ + private URL axis2_xml = + getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"); + private URL axis2_repository = null; + private URL rampart_mar_url = + getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar"); + /************** end of fix *************************************************************/ + + private boolean isRampartRequired; + + public TuscanyAxisConfigurator(boolean isRampartRequired) throws AxisFault { + //super(TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"), + // TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart.mar")); + super(getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"), + null); + this.isRampartRequired = isRampartRequired; + } + + private static URL getResource(final String name) { + return AccessController.doPrivileged(new PrivilegedAction() { + public URL run() { + return TuscanyAxisConfigurator.class.getResource(name); + } + }); + } + + public ConfigurationContext getConfigurationContext() throws AxisFault { + if (configContext == null) { + configContext = ConfigurationContextFactory.createConfigurationContext(this); + } + return configContext; + } + + /* these three methods are part of a temporary fix to solve problems that Maven has with including + * rampart-1.3.mar into the classpath and also at the time of Release 1.0 rampart-1.3.mar seems + * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded + * as a Maven dependency and has been packed with this module + */ + /************start of fix *********************************************************************/ + @Override + public AxisConfiguration getAxisConfiguration() throws AxisFault { + InputStream axis2xmlStream; + try { + if (axis2_xml == null) { + axis2xmlStream = + Loader.getResourceAsStream(DeploymentConstants.AXIS2_CONFIGURATION_RESOURCE); + } else { + axis2xmlStream = axis2_xml.openStream(); + } + axisConfig = populateAxisConfiguration(axis2xmlStream); + if (isRampartRequired) { + axisConfig.addGlobalModuleRef("rampart"); + } + if (axis2_repository == null) { + Parameter axis2repoPara = axisConfig.getParameter(DeploymentConstants.AXIS2_REPO); + if (axis2repoPara != null) { + String repoValue = (String) axis2repoPara.getValue(); + if (repoValue != null && !"".equals(repoValue.trim())) { + if (repoValue.startsWith("file:/")) { + // we treat this case specially , by assuming file is + // located in the local machine + loadRepository(repoValue); + } else { + loadRepositoryFromURL(new URL(repoValue)); + } + } + } else { + //log.info("No repository found , module will be loaded from classpath"); + try { + loadFromClassPath(); + } catch ( Exception e ) { + if (isRampartRequired) { + loadRampartModule(); + } + } + } + + } else { + loadRepositoryFromURL(axis2_repository); + } + + } catch (IOException e) { + throw new AxisFault(e.getMessage()); + } + axisConfig.setConfigurator(this); + return axisConfig; + } + + public void loadRampartModule() throws DeploymentException { + try { + ClassLoader deploymentClassLoader = + org.apache.axis2.deployment.util.Utils.createClassLoader( + new URL[]{rampart_mar_url}, + axisConfig.getModuleClassLoader(), + true, + (File) axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR)); + final AxisModule module = new AxisModule(); + module.setModuleClassLoader(deploymentClassLoader); + module.setParent(axisConfig); + //String moduleFile = fileUrl.substring(0, fileUrl.indexOf(".mar")); + if (module.getName() == null) { + module.setName(org.apache.axis2.util.Utils.getModuleName("rampart-1.4")); + module.setVersion(org.apache.axis2.util.Utils.getModuleVersion("rampart-1.4")); + } + populateModule(module, rampart_mar_url); + module.setFileName(rampart_mar_url); + // Allow privileged access to read properties. Requires PropertiesPermission read in + // security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws IOException { + addNewModule(module, axisConfig); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (AxisFault)e.getException(); + } + + org.apache.axis2.util.Utils. + calculateDefaultModuleVersion(axisConfig.getModules(), axisConfig); + axisConfig.validateSystemPredefinedPhases(); + } catch (IOException e) { + throw new DeploymentException(e); + } + } + + private void populateModule(AxisModule module, URL moduleUrl) throws DeploymentException { + try { + ClassLoader classLoader = module.getModuleClassLoader(); + InputStream moduleStream = classLoader.getResourceAsStream("META-INF/module.xml"); + if (moduleStream == null) { + moduleStream = classLoader.getResourceAsStream("meta-inf/module.xml"); + } + if (moduleStream == null) { + throw new DeploymentException( + Messages.getMessage( + DeploymentErrorMsgs.MODULE_XML_MISSING, moduleUrl.toString())); + } + ModuleBuilder moduleBuilder = new ModuleBuilder(moduleStream, module, axisConfig); + moduleBuilder.populateModule(); + } catch (IOException e) { + throw new DeploymentException(e); + } + } + + /************** end of fix *************************************************************/ + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java new file mode 100644 index 0000000000..34899a4af0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.net.URI; +import java.util.HashMap; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.HandlerDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.RequestURIBasedDispatcher; +import org.apache.axis2.util.JavaUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A Tuscany specific Axis2 Dispatcher that enables using services + * exposed at the SCA defined service URI instead of /services/ + * + * @version $Rev$ $Date$ + */ +public class TuscanyDispatcher extends RequestURIBasedDispatcher { + + public static final String NAME = "TuscanyDispatcher"; + private static final Log log = LogFactory.getLog(RequestURIBasedDispatcher.class); + private static final boolean isDebugEnabled = log.isDebugEnabled(); + + /* + * (non-Javadoc) + * + * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext) + */ + @Override + public AxisService findService(MessageContext messageContext) throws AxisFault { + EndpointReference toEPR = messageContext.getTo(); + + if (toEPR != null) { + if(isDebugEnabled){ + log.debug("Checking for Service using target endpoint address : " + toEPR.getAddress()); + } + + String path = URI.create(toEPR.getAddress()).getPath(); + + ConfigurationContext configurationContext = messageContext.getConfigurationContext(); + AxisConfiguration registry = configurationContext.getAxisConfiguration(); + + String serviceName = findAxisServiceName(registry, path); + return registry.getService(serviceName); + + } else { + if(isDebugEnabled){ + log.debug("Attempted to check for Service using null target endpoint URI"); + } + return null; + } + } + + @Override + public void initDispatcher() { + init(new HandlerDescription(NAME)); + } + + protected String findAxisServiceName(AxisConfiguration registry, String path) { + HashMap services = registry.getServices(); + if (services == null) { + return null; + } + String[] parts = JavaUtils.split(path, '/'); + String serviceName = ""; + for (int i=parts.length-1; i>=0; i--) { + serviceName = parts[i] + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + serviceName = "/" + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + } + + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java new file mode 100644 index 0000000000..7d331aa6c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Iterator; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.ListenerManager; +import org.apache.axis2.transport.TransportListener; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A Tuscany specific Axis2 ListenerManager. Created purely as part of + * TUSCANY-3149 to unregister the ListenerManager from the runtime + * shutown hook + */ +public class TuscanyListenerManager extends ListenerManager { + private static final Log log = LogFactory.getLog(TuscanyListenerManager.class); + + private ListenerManagerShutdownThread shutdownThread = null; + + /** + * To start all the transports + */ + public synchronized void start() { + + ConfigurationContext configctx = getConfigctx(); + + // very nasty! but this is in order to get someone running who keeps + // getting perm gen errors. This will all go away when we move up to Axis2 1.5 + HashMap startedTransports = null; + + try { + Field field = ListenerManager.class.getDeclaredField("startedTransports"); + field.setAccessible(true); + startedTransports = (HashMap)field.get(this); + } catch (Exception ex){ + ex.printStackTrace(); + } + + for (Iterator transportNames = + configctx.getAxisConfiguration().getTransportsIn().values().iterator(); + transportNames.hasNext();) { + try { + TransportInDescription transportIn = (TransportInDescription) transportNames.next(); + TransportListener listener = transportIn.getReceiver(); + if (listener != null && + startedTransports.get(transportIn.getName()) == null) { + listener.init(configctx, transportIn); + listener.start(); + if (startedTransports.get(transportIn.getName()) == null) { + startedTransports.put(transportIn.getName(), listener); + } + } + } catch (Exception e) { + log.info(e.getMessage(), e); + } + } + shutdownThread = new ListenerManagerShutdownThread(this); + Runtime.getRuntime().addShutdownHook(shutdownThread); + } + + public synchronized void stop() throws AxisFault { + super.stop(); + Runtime.getRuntime().removeShutdownHook(shutdownThread); + } + + static class ListenerManagerShutdownThread extends Thread { + ListenerManager listenerManager; + + public ListenerManagerShutdownThread(ListenerManager listenerManager) { + super(); + this.listenerManager = listenerManager; + } + + public void run() { + try { + listenerManager.stop(); + } catch (AxisFault axisFault) { + log.error(axisFault.getMessage(), axisFault); + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java new file mode 100644 index 0000000000..21fef3e5d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java @@ -0,0 +1,238 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.axiom.attachments.utils.IOUtils; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.deployment.DeploymentConstants; +import org.apache.axis2.description.AxisDescription; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.PolicyInclude; +import org.apache.axis2.transport.http.ListingAgent; +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.axis2.util.ExternalPolicySerializer; +import org.apache.axis2.util.JavaUtils; +import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.neethi.Policy; +import org.apache.neethi.PolicyRegistry; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; + +/** + * A Tuscany specific Axis2 ListingAgent as the Axis2 one does not work + * with the Tuscany service names which include slash ('/') characters. + * Unfortunately it ends up having to copy a fair amount of Axis2 code to do this. + * + * @version $Rev$ $Date$ + */ +public class TuscanyListingAgent extends ListingAgent { + + private static final String LIST_SINGLE_SERVICE_JSP_NAME = + "listSingleService.jsp"; + + public TuscanyListingAgent(ConfigurationContext aConfigContext) { + super(aConfigContext); + } + + /** + * This method overrides the Axis2 listing agent's computation of the + * service name. + */ + @Override + public String extractServiceName(String urlString) { + String serviceName = findAxisServiceName(urlString); + setContextRoot(urlString, serviceName); + return serviceName; + } + + /** + * Override ?xsd processing so that WSDL documents with XSD imports + * and includes work correctly. When we move to Axis2 1.4, we may + * be able to use SchemaSupplier to do this in a cleaner way. Also + * ensure that the correct IP address and port are returned by ?wsdl. + */ + @Override + public void processListService(HttpServletRequest req, + HttpServletResponse res) + throws IOException, ServletException { + + String url = req.getRequestURL().toString(); + String query = req.getQueryString(); + + // for ?wsdl requests, need to update the WSDL with correct IPaddr and port + int wsdl = query.indexOf("wsdl"); + if (wsdl >= 0) { + String serviceName = extractServiceName(url); + HashMap services = configContext.getAxisConfiguration().getServices(); + if ((services != null) && !services.isEmpty()) { + AxisService axisService = (AxisService)services.get(serviceName); + Parameter wsld4jdefinition = axisService.getParameter(WSDLConstants.WSDL_4_J_DEFINITION); + Definition definition = (Definition)wsld4jdefinition.getValue(); + for (Object s : definition.getServices().values()) { + for (Object p : ((Service)s).getPorts().values()) { + String endpointURL = Axis2ServiceProvider.getPortAddress((Port)p); + String modifiedURL = setIPAddress(endpointURL, url); + Axis2ServiceProvider.setPortAddress((Port)p, modifiedURL); + } + } + } + } + + // handle ?xsd requests here + int xsd = query.indexOf("xsd"); + if (xsd >= 0) { + String serviceName = extractServiceName(url); + HashMap services = configContext.getAxisConfiguration().getServices(); + if ((services != null) && !services.isEmpty()) { + Object serviceObj = services.get(serviceName); + if (serviceObj != null) { + String xsds = req.getParameter("xsd"); + if (xsds != null && !"".equals(xsds)) { + // a schema name (perhaps with path) is present + AxisService axisService = (AxisService)serviceObj; + ArrayList schemas = axisService.getSchema(); + for (Object rootSchema : axisService.getSchema()) { + XmlSchema schema = getSchema(((XmlSchema)rootSchema), xsds); + if (schema != null) { + // found the schema + res.setContentType("text/xml"); + OutputStream out = res.getOutputStream(); + schema.write(new OutputStreamWriter(out, "UTF8")); + out.flush(); + out.close(); + return; + } + } + } + } + } + } + + // in all other cases, delegate to the Axis2 code + super.processListService(req, res); + } + + private XmlSchema getSchema(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + if (extSchema.getSchemaLocation().endsWith(name)) { + return extSchema.getSchema(); + } else { + XmlSchema schema = getSchema(extSchema.getSchema(), name); + if (schema != null) { + return schema; + } + } + } + } + return null; + } + + private String findAxisServiceName(String path) { + HashMap services = configContext.getAxisConfiguration().getServices(); + if (services == null) { + return null; + } + String[] parts = JavaUtils.split(path, '/'); + String serviceName = ""; + for (int i=parts.length-1; i>=0; i--) { + serviceName = parts[i] + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + serviceName = "/" + serviceName; + if (services.containsKey(serviceName)) { + return serviceName; + } + } + + return null; + } + + /** + * Hack for Tuscany to get ?wsdl working with Tuscany service names + * Can go once moved up to Axis2 1.3 + */ + private void setContextRoot(String filePart, String serviceName) { + String contextRoot = configContext.getContextRoot(); + if (contextRoot != null && contextRoot.length() > 0) { + if (contextRoot.equals("/")) { + configContext.setServicePath("/"); + } else { + int i = filePart.indexOf(contextRoot) + contextRoot.length(); + int j = filePart.lastIndexOf(serviceName); + if (i>=j || (i+1 == j)) { + configContext.setServicePath("/"); + } else { + String mapping = filePart.substring(i+1, j); + configContext.setServicePath(mapping); + } + } + configContext.setContextRoot(contextRoot); + } + } + + private static String setIPAddress(String wsdlURI, String requestURI) { + try { + URI wsdlURIObj = new URI(wsdlURI); + String wsdlHost = wsdlURIObj.getHost(); + int wsdlPort = wsdlURIObj.getPort(); + String wsdlAddr = wsdlHost + (wsdlPort != -1 ? ":" + Integer.toString(wsdlPort) : ""); + URI requestURIObj = new URI(requestURI); + String ipAddr = HttpUtils.getIpAddress(); + int requestPort = requestURIObj.getPort(); + String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : ""); + return wsdlURI.replace(wsdlAddr, newAddr); + } catch (Exception e) { + // URI string not in expected format, so return the WSDL URI unmodified + return wsdlURI; + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java new file mode 100644 index 0000000000..5254a5716c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSBindingDefinitionsProvider.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2; + +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.SCADefinitions; +import org.apache.tuscany.sca.provider.SCADefinitionsProvider; +import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; + +/** + * Provider for Policy Intents and PolicySet definitions related to security + * + * @version $Rev$ $Date$ + */ +public class WSBindingDefinitionsProvider implements SCADefinitionsProvider { + private String definitionsFile = "org/apache/tuscany/sca/binding/ws/axis2/definitions.xml"; + URLArtifactProcessor urlArtifactProcessor = null; + + public WSBindingDefinitionsProvider(ExtensionPointRegistry registry) { + URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); + } + + public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { + final URL definitionsFileUrl = getClass().getClassLoader().getResource(definitionsFile); + SCADefinitions scaDefn = null; + try { + final URI uri = new URI(definitionsFile); + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public SCADefinitions run() throws ContributionReadException { + return (SCADefinitions)urlArtifactProcessor.read(null, uri, definitionsFileUrl); + } + }); + } catch (Exception e) { + throw new SCADefinitionsProviderException(e); + } + return scaDefn; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/AxisJMSException.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/AxisJMSException.java new file mode 100644 index 0000000000..09a1960ce4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/AxisJMSException.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.jms; + +public class AxisJMSException extends RuntimeException { + + AxisJMSException() { + super(); + } + + AxisJMSException(String msg) { + super(msg); + } + + AxisJMSException(String msg, Exception e) { + super(msg, e); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSConnectionFactory.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSConnectionFactory.java new file mode 100644 index 0000000000..a96ec0b1c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSConnectionFactory.java @@ -0,0 +1,605 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.jms; + +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.Topic; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tuscany.sca.work.WorkScheduler; + +/** + * Encapsulate a JMS Connection factory definition within an Axis2.xml + *

+ * More than one JMS connection factory could be defined within an Axis2 XML + * specifying the JMSListener as the transportReceiver. + *

+ * These connection factories are created at the initialization of the + * transportReceiver, and any service interested in using any of these could + * specify the name of the factory and the destination through Parameters named + * JMSConstants.CONFAC_PARAM and JMSConstants.DEST_PARAM as shown below. + *

+ * myQueueConnectionFactory + * TestQueue + *

+ * If a connection factory is defined by a parameter named + * JMSConstants.DEFAULT_CONFAC_NAME in the Axis2 XML, services which does not + * explicitly specify a connection factory will be defaulted to it - if it is + * defined in the Axis2 configuration. + *

+ * e.g. + * + * + * org.apache.activemq.jndi.ActiveMQInitialContextFactory + * tcp://localhost:61616 + * TopicConnectionFactory + * myTopicOne, myTopicTwo + * + * + * org.apache.activemq.jndi.ActiveMQInitialContextFactory + * tcp://localhost:61616 + * QueueConnectionFactory + * myQueueOne, myQueueTwo + * + * + * org.apache.activemq.jndi.ActiveMQInitialContextFactory + * tcp://localhost:61616 + * ConnectionFactory + * myDestinationOne, myDestinationTwo + * + * + */ +public class JMSConnectionFactory { + + private static final Log log = LogFactory.getLog(JMSConnectionFactory.class); + + /** + * The name used for the connection factory definition within Axis2 + */ + private String name = null; + /** + * The JNDI name of the actual connection factory + */ + private String jndiName = null; + /** + * The JNDI name of the actual connection factory username + */ + private String jndiUser = null; + /** + * The JNDI name of the actual connection factory password + */ + private String jndiPass = null; + /** + * Map of destination JNDI names to service names + */ + private Map serviceJNDINameMapping = null; + /** + * Map of destinations to service names + */ + private Map serviceDestinationMapping = null; + /** + * The JMS Sessions listening for messages + */ + private Map jmsSessions = null; + /** + * Properties of the connection factory + */ + private Hashtable properties = null; + /** + * The JNDI Context used + */ + private Context context = null; + /** + * The actual ConnectionFactory instance held within + */ + private ConnectionFactory conFactory = null; + /** + * The JMS Connection is opened. + */ + private Connection connection = null; + /** + * The JMS Message receiver for this connection factory + */ + private JMSMessageReceiver msgRcvr = null; + /** + * The actual password for the connection factory after retrieval from JNDI. + * If this is not supplied, the OS username will be used by default + */ + private String user = null; + /** + * The actual password for the connection factory after retrieval from JNDI. + * If this is not supplied, the OS credentials will be used by default + */ + private String pass = null; + + private WorkScheduler workScheduler; + private boolean consumerRunning; + + /** + * Create a JMSConnectionFactory for the given Axis2 name and JNDI name + * + * @param name the local Axis2 name of the connection factory + * @param jndiName the JNDI name of the actual connection factory used + */ + JMSConnectionFactory(String name, String jndiName, WorkScheduler workScheduler) { + this.name = name; + this.jndiName = jndiName; + serviceJNDINameMapping = new HashMap(); + serviceDestinationMapping = new HashMap(); + properties = new Hashtable(); + jmsSessions = new HashMap(); + this.workScheduler = workScheduler; + } + + /** + * Create a JMSConnectionFactory for the given Axis2 name + * + * @param name the local Axis2 name of the connection factory + */ + JMSConnectionFactory(String name, WorkScheduler workScheduler) { + this(name, null, workScheduler); + } + + /** + * Connect to the actual JMS connection factory specified by the JNDI name + * + * @throws NamingException if the connection factory cannot be found + */ + public void connect() throws NamingException { + if (context == null) { + createInitialContext(); + } + conFactory = (ConnectionFactory) context.lookup(jndiName); + + if (jndiUser != null) + user = (String ) context.lookup(jndiUser); + + if (jndiPass != null) + pass = (String ) context.lookup(jndiPass); + + log.debug("Connected to the actual connection factory : " + jndiName); + } + + /** + * Creates the initial context using the set properties + * + * @throws NamingException + */ + private void createInitialContext() throws NamingException { + context = new InitialContext(properties); + } + + /** + * Set the JNDI connection factory name + * + * @param jndiName + */ + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } + + /** + * Get the JNDI name of the actual factory username + * + * @return the jndi name of the actual connection factory username + */ + public void setJndiUser(String jndiUser) { + this.jndiUser = jndiUser; + } + + /** + * Get the JNDI name of the actual factory password + * + * @return the jndi name of the actual connection factory password + */ + public void setJndiPass(String jndiPass) { + this.jndiPass = jndiPass; + } + + /** + * Add a listen destination on this connection factory on behalf of the given service + * + * @param destinationJndi destination JNDI name + * @param serviceName the service to which it belongs + */ + public void addDestination(String destinationJndi, String serviceName) { + + serviceJNDINameMapping.put(destinationJndi, serviceName); + String destinationName = getDestinationName(destinationJndi); + + if (destinationName == null) { + log.warn("JMS Destination with JNDI name : " + destinationJndi + " does not exist"); + + Connection con = null; + try { + if ((jndiUser == null) || (jndiPass == null)){ + // Use the OS username and credentials + con = conFactory.createConnection(); + } else{ + // use an explicit username and password + con = conFactory.createConnection(user, pass); + } + Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue(destinationJndi); + destinationName = queue.getQueueName(); + log.warn("JMS Destination with JNDI name : " + destinationJndi + " created"); + + } catch (JMSException e) { + log.error("Unable to create a Destination with JNDI name : " + destinationJndi, e); + // mark service as faulty + JMSUtils.markServiceAsFaulty( + (String) serviceJNDINameMapping.get(destinationJndi), + "Error looking up JMS destination : " + destinationJndi, + msgRcvr.getAxisConf().getAxisConfiguration()); + + } finally { + if (con != null) { + try { + con.close(); + } catch (JMSException ignore) {} + } + } + } + + serviceDestinationMapping.put(destinationName, serviceName); + log.info("Mapping JNDI name : " + destinationJndi + " and JMS Destination name : " + + destinationName + " against service : " + serviceName); + } + + /** + * Remove listen destination on this connection factory + * + * @param destinationJndi the JMS destination to be removed + * @throws if an error occurs trying to stop listening for messages before removal + */ + public void removeDestination(String destinationJndi) throws JMSException { + // find and save provider specific Destination name before we delete + String providerSpecificDestination = getDestinationName(destinationJndi); + stoplistenOnDestination(destinationJndi); + serviceJNDINameMapping.remove(destinationJndi); + if (providerSpecificDestination != null) { + serviceDestinationMapping.remove(providerSpecificDestination); + } + } + + /** + * Add a property to the connection factory + * + * @param key + * @param value + */ + public void addProperty(String key, String value) { + properties.put(key, value); + } + + /** + * Return the name of the connection factory + * + * @return the Axis2 name of this factory + */ + public String getName() { + return name; + } + + /** + * Get the JNDI name of the actual factory + * + * @return the jndi name of the actual connection factory + */ + public String getJndiName() { + return jndiName; + } + + /** + * Get the JNDI name of the actual factory username + * + * @return the jndi name of the actual connection factory username + */ + public String getJndiUser() { + return jndiUser; + } + + /** + * Get the JNDI name of the actual factory password + * + * @return the jndi name of the actual connection factory password + */ + public String getJndiPass() { + return jndiPass; + } + + + /** + * This is the real password for the connection factory after the JNDI lookup + * + * @return the real password for the connection factory after the JNDI lookup + */ + public String getPass() { + return pass; + } + + /** + * This is the real username for the connection factory after the JNDI lookup + * + * @return the eal username for the connection factory after the JNDI lookup + */ + public String getUser() { + return user; + } + + /** + * Get the actual underlying connection factory + * + * @return actual connection factory + */ + public ConnectionFactory getConFactory() { + return conFactory; + } + + /** + * Get the list of destinations (JNDI) associated with this connection factory + * + * @return destinations to service maping + */ + public Map getDestinations() { + return serviceJNDINameMapping; + } + + /** + * Get the connection factory properties + * + * @return properties + */ + public Hashtable getProperties() { + return properties; + } + + /** + * Begin listening for messages on the list of destinations associated + * with this connection factory. (Called during Axis2 initialization of + * the Transport receivers) + * + * @param msgRcvr the message receiver which will process received messages + * @throws JMSException on exceptions + */ + public void listen(JMSMessageReceiver msgRcvr) throws JMSException { + + // save a reference to the message receiver + this.msgRcvr = msgRcvr; + + log.debug("Connection factory : " + name + " initializing..."); + + if (conFactory == null || context == null) { + handleException( + "Connection factory must be 'connected' before listening"); + } else { + try { + if ((jndiUser == null) || (jndiPass == null)){ + // User the OS username and credentials + connection = conFactory.createConnection(); + } else{ + // use an explicit username and password + connection = conFactory.createConnection(user, pass); + } + } catch (JMSException e) { + handleException("Error creating a JMS connection using the " + + "factory : " + jndiName, e); + } + } + + Iterator iter = serviceJNDINameMapping.keySet().iterator(); + while (iter.hasNext()) { + String destinationJndi = (String) iter.next(); + listenOnDestination(destinationJndi); + } + + // start the connection + if (!consumerRunning) { + connection.start(); + } + log.info("Connection factory : " + name + " initialized..."); + } + + /** + * Listen on the given destination from this connection factory. Used to + * start listening on a destination associated with a newly deployed service + * + * @param destinationJndi the JMS destination to listen on + * @throws JMSException on exception + */ + public void listenOnDestination(String destinationJndi) throws JMSException { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination destination = null; + try { + Object o = context.lookup(destinationJndi); + destination = (Destination) o; + + } catch (NameNotFoundException e) { + log.warn("Cannot find destination : " + destinationJndi + + " Creating a Queue with this name"); + destination = session.createQueue(destinationJndi); + + } catch (NamingException e) { + log.warn("Error looking up destination : " + destinationJndi, e); + // mark service as faulty + JMSUtils.markServiceAsFaulty( + (String) serviceJNDINameMapping.get(destinationJndi), + "Error looking up JMS destination : " + destinationJndi, + this.msgRcvr.getAxisConf().getAxisConfiguration()); + } + + MessageConsumer consumer = session.createConsumer(destination); +// consumer.setMessageListener(this.msgRcvr); replace with new Tuscany method: + registerMessageReceiver(consumer, this.msgRcvr); + jmsSessions.put(destinationJndi, session); + } + + private void registerMessageReceiver(final MessageConsumer consumer, final JMSMessageReceiver messageReceiver) throws JMSException { + + try { + + consumer.setMessageListener(messageReceiver); + + } catch (javax.jms.JMSException e) { + + // setMessageListener not allowed in JEE container so use Tuscany threads + + connection.start(); + consumerRunning = true; + + workScheduler.scheduleWork(new Runnable() { + + public void run() { + try { + while (consumerRunning) { + final Message msg = consumer.receive(); + if (msg != null) { + workScheduler.scheduleWork(new Runnable() { + public void run() { + try { + messageReceiver.onMessage(msg); + } catch (Exception e) { + log.error("Exception on message receiver thread", e); + } + } + }); + } + } + } catch (Exception e) { + log.error("Exception on consumer receive thread", e); + } + } + }); + } + } + + /** + * Stop listening on the given destination - for undeployment of services + * + * @param destinationJndi the JNDI name of the JMS destination + * @throws JMSException on exception + */ + private void stoplistenOnDestination(String destinationJndi) throws JMSException { + ((Session) jmsSessions.get(destinationJndi)).close(); + } + + /** + * Return the service name using this destination + * + * @param destination the destination name + * @return the service which uses the given destination, or null + */ + public String getServiceNameForDestination(String destination) { + + return (String) serviceJNDINameMapping.get(destination); + } + + /** + * Close all connections, sessions etc.. and stop this connection factory + */ + public void stop() { + try { + consumerRunning = false; + connection.close(); + } catch (JMSException e) { + log.warn("Error shutting down connection factory : " + name, e); + } + } + + /** + * Return the provider specific Destination name if any for the destination with the given + * JNDI name + * @param destinationJndi the JNDI name of the destination + * @return the provider specific Destination name or null if cannot be found + */ + public String getDestinationName(String destinationJndi) { + try { + Destination destination = (Destination) context.lookup(destinationJndi); + if (destination != null && destination instanceof Queue) { + return ((Queue) destination).getQueueName(); + } else if (destination != null && destination instanceof Topic) { + return ((Topic) destination).getTopicName(); + } + } catch (JMSException e) { + log.warn("Error reading provider specific JMS destination name for destination " + + "with JNDI name : " + destinationJndi, e); + } catch (NamingException e) { + log.warn("Error looking up destination with JNDI name : " + destinationJndi + + " to map its corresponding provider specific Destination name"); + } + return null; + } + + /** + * Return the EPR for the JMS Destination with the given JNDI name and using + * this connection factory + * @param destination the JNDI name of the JMS Destionation + * @return the EPR + */ + public EndpointReference getEPRForDestination(String destination) { + + StringBuffer sb = new StringBuffer(); + sb.append(JMSConstants.JMS_PREFIX).append(destination); + sb.append("?").append(JMSConstants.CONFAC_JNDI_NAME_PARAM). + append("=").append(getJndiName()); + Iterator props = getProperties().keySet().iterator(); + while (props.hasNext()) { + String key = (String) props.next(); + String value = (String) getProperties().get(key); + sb.append("&").append(key).append("=").append(value); + } + + return new EndpointReference(sb.toString()); + } + + public String getServiceByDestination(String destinationName) { + return (String) serviceDestinationMapping.get(destinationName); + } + + private void handleException(String msg) throws AxisJMSException { + log.error(msg); + throw new AxisJMSException(msg); + } + + private void handleException(String msg, Exception e) throws AxisJMSException { + log.error(msg, e); + throw new AxisJMSException(msg, e); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSListener.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSListener.java new file mode 100644 index 0000000000..08190fb57c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSListener.java @@ -0,0 +1,527 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.jms; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.StringTokenizer; + +import javax.jms.JMSException; +import javax.naming.Context; +import javax.naming.NamingException; + +import org.apache.axiom.om.OMElement; +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.context.SessionContext; +import org.apache.axis2.description.AxisModule; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.AxisServiceGroup; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.description.ParameterIncludeImpl; +import org.apache.axis2.description.TransportInDescription; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.AxisEvent; +import org.apache.axis2.engine.AxisObserver; +import org.apache.axis2.transport.TransportListener; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tuscany.sca.work.WorkScheduler; + +import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService; +import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue; +import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor; +import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; + +/** + * The JMS Transport listener implementation. A JMS Listner will hold one or + * more JMS connection factories, which would be created at initialization + * time. This implementation does not support the creation of connection + * factories at runtime. This JMS Listener registers with Axis to be notified + * of service deployment/undeployment/start and stop, and enables or disables + * listening for messages on the destinations as appropriate. + *

+ * A Service could state the JMS connection factory name and the destination + * name for use as Parameters in its services.xml as shown in the example + * below. If the connection name was not specified, it will use the connection + * factory named "default" (JMSConstants.DEFAULT_CONFAC_NAME) - if such a + * factory is defined in the Axis2.xml. If the destination name is not specified + * it will default to a JMS queue by the name of the service. If the destination + * should be a Topic, it should be created on the JMS implementation, and + * specified in the services.xml of the service. + *

+ * + * myTopicConnectionFactory + * + * dynamicTopics/something.TestTopic + */ +public class JMSListener implements TransportListener { + + private static final Log log = LogFactory.getLog(JMSListener.class); + + /** + * The maximum number of threads used for the worker thread pool + */ + private static final int WORKERS_MAX_THREADS = 100; + /** + * The keep alive time of an idle worker thread + */ + private static final long WORKER_KEEP_ALIVE = 60L; + /** + * The worker thread timeout time unit + */ + private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; + + /** + * A Map containing the connection factories managed by this, keyed by name + */ + private Map connectionFactories = new HashMap(); + /** + * A Map of service name to the JMS EPR addresses + */ + private Map serviceNameToEprMap = new HashMap(); + /** + * The Axis2 Configuration context + */ + private ConfigurationContext configCtx = null; + + private ExecutorService workerPool; + + private WorkScheduler workScheduler; + + public JMSListener(WorkScheduler workScheduler) { + this.workScheduler = workScheduler; + } + + /** + * This is the TransportListener initialization method invoked by Axis2 + * + * @param axisConf the Axis configuration context + * @param transprtIn the TransportIn description + */ + public void init(ConfigurationContext axisConf, + TransportInDescription transprtIn) { + + // save reference to the configuration context + this.configCtx = axisConf; + + // initialize the defined connection factories + initializeConnectionFactories(transprtIn); + + // if no connection factories are defined, we cannot listen + if (connectionFactories.isEmpty()) { + log.warn("No JMS connection factories are defined." + + "Will not listen for any JMS messages"); + return; + } + + // iterate through deployed services and validate connection factory + // names, and mark services as faulty where appropriate. + Iterator services = + axisConf.getAxisConfiguration().getServices().values().iterator(); + + while (services.hasNext()) { + AxisService service = (AxisService) services.next(); + if (JMSUtils.isJMSService(service)) { + processService(service); + } + } + + // register to receive updates on services for lifetime management + axisConf.getAxisConfiguration().addObservers(new JMSAxisObserver()); + + log.info("JMS Transport Receiver (Listener) initialized..."); + } + + + /** + * Prepare to listen for JMS messages on behalf of this service + * + * @param service + */ + private void processService(AxisService service) { + JMSConnectionFactory cf = getConnectionFactory(service); + if (cf == null) { + String msg = "Service " + service.getName() + " does not specify" + + "a JMS connection factory or refers to an invalid factory. " + + "This service is being marked as faulty and will not be " + + "available over the JMS transport"; + log.warn(msg); + JMSUtils.markServiceAsFaulty( + service.getName(), msg, service.getAxisConfiguration()); + return; + } + + String destination = JMSUtils.getDestination(service); + + // compute service EPR and keep for later use + serviceNameToEprMap.put(service.getName(), getEPR(cf, destination)); + + // add the specified or implicit destination of this service + // to its connection factory + cf.addDestination(destination, service.getName()); + } + + /** + * Return the connection factory name for this service. If this service + * refers to an invalid factory or defaults to a non-existent default + * factory, this returns null + * + * @param service the AxisService + * @return the JMSConnectionFactory to be used, or null if reference is invalid + */ + private JMSConnectionFactory getConnectionFactory(AxisService service) { + Parameter conFacParam = service.getParameter(JMSConstants.CONFAC_PARAM); + + // validate connection factory name (specified or default) + if (conFacParam != null) { + String conFac = (String) conFacParam.getValue(); + if (connectionFactories.containsKey(conFac)) { + return (JMSConnectionFactory) connectionFactories.get(conFac); + } else { + return null; + } + + } else if (connectionFactories.containsKey(JMSConstants.DEFAULT_CONFAC_NAME)) { + return (JMSConnectionFactory) connectionFactories. + get(JMSConstants.DEFAULT_CONFAC_NAME); + + } else { + return null; + } + } + + /** + * Initialize the defined connection factories, parsing the TransportIn + * descriptions + * + * @param transprtIn The Axis2 Transport in for the JMS + */ + private void initializeConnectionFactories(TransportInDescription transprtIn) { + // iterate through all defined connection factories + Iterator conFacIter = transprtIn.getParameters().iterator(); + + while (conFacIter.hasNext()) { + + Parameter param = (Parameter) conFacIter.next(); + JMSConnectionFactory jmsConFactory = + new JMSConnectionFactory(param.getName(), workScheduler); + + ParameterIncludeImpl pi = new ParameterIncludeImpl(); + try { + pi.deserializeParameters((OMElement) param.getValue()); + } catch (AxisFault axisFault) { + handleException("Error reading Parameters for JMS connection " + + "factory" + jmsConFactory.getName(), axisFault); + } + + // read connection facotry properties + Iterator params = pi.getParameters().iterator(); + + while (params.hasNext()) { + Parameter p = (Parameter) params.next(); + + if (Context.INITIAL_CONTEXT_FACTORY.equals(p.getName())) { + jmsConFactory.addProperty( + Context.INITIAL_CONTEXT_FACTORY, (String) p.getValue()); + } else if (Context.PROVIDER_URL.equals(p.getName())) { + jmsConFactory.addProperty( + Context.PROVIDER_URL, (String) p.getValue()); + } else if (Context.SECURITY_PRINCIPAL.equals(p.getName())) { + jmsConFactory.addProperty( + Context.SECURITY_PRINCIPAL, (String) p.getValue()); + } else if (Context.SECURITY_CREDENTIALS.equals(p.getName())) { + jmsConFactory.addProperty( + Context.SECURITY_CREDENTIALS, (String) p.getValue()); + } else if (JMSConstants.CONFAC_JNDI_NAME_PARAM.equals(p.getName())) { + jmsConFactory.setJndiName((String) p.getValue()); + } else if (JMSConstants.CONFAC_JNDI_NAME_USER.equals(p.getName())) { + jmsConFactory.setJndiUser((String) p.getValue()); + } else if (JMSConstants.CONFAC_JNDI_NAME_PASS.equals(p.getName())) { + jmsConFactory.setJndiPass((String) p.getValue()); + } else if (JMSConstants.DEST_PARAM.equals(p.getName())) { + StringTokenizer st = + new StringTokenizer((String) p.getValue(), " ,"); + while (st.hasMoreTokens()) { + jmsConFactory.addDestination(st.nextToken(), null); + } + } + } + + // connect to the actual connection factory + try { + jmsConFactory.connect(); + connectionFactories.put(jmsConFactory.getName(), jmsConFactory); + } catch (NamingException e) { + handleException("Error connecting to JMS connection factory : " + + jmsConFactory.getJndiName(), e); + } + } + } + + /** + * Get the EPR for the given JMS connection factory and destination + * the form of the URL is + * jms:/?[=&]* + * + * @param cf the Axis2 JMS connection factory + * @param destination the JNDI name of the destination + * @return the EPR as a String + */ + private static String getEPR(JMSConnectionFactory cf, String destination) { + StringBuffer sb = new StringBuffer(); + sb.append(JMSConstants.JMS_PREFIX).append(destination); + sb.append("?").append(JMSConstants.CONFAC_JNDI_NAME_PARAM). + append("=").append(cf.getJndiName()); + Iterator props = cf.getProperties().keySet().iterator(); + while (props.hasNext()) { + String key = (String) props.next(); + String value = (String) cf.getProperties().get(key); + sb.append("&").append(key).append("=").append(value); + } + return sb.toString(); + } + + /** + * Start this JMS Listener (Transport Listener) + * + * @throws AxisFault + */ + public void start() throws AxisFault { + // create thread pool of workers + workerPool = new ThreadPoolExecutor( + 1, + WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT, + new LinkedBlockingQueue(), + new org.apache.axis2.util.threadpool.DefaultThreadFactory( + new ThreadGroup("JMS Worker thread group"), + "JMSWorker")); + + Iterator iter = connectionFactories.values().iterator(); + while (iter.hasNext()) { + JMSConnectionFactory conFac = (JMSConnectionFactory) iter.next(); + JMSMessageReceiver msgRcvr = + new JMSMessageReceiver(conFac, workerPool, configCtx); + + try { + conFac.listen(msgRcvr); + } catch (JMSException e) { + handleException("Error starting connection factory : " + + conFac.getName(), e); + } + } + } + + /** + * Stop this transport listener and shutdown all of the connection factories + */ + public void stop() { + Iterator iter = connectionFactories.values().iterator(); + while (iter.hasNext()) { + ((JMSConnectionFactory) iter.next()).stop(); + } + if (workerPool != null) { + workerPool.shutdown(); + } + } + + /** + * Returns EPRs for the given service and IP. (Picks up precomputed EPR) + * + * @param serviceName service name + * @param ip ignored + * @return the EPR for the service + * @throws AxisFault not used + */ + public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault { + //Strip out the operation name + if (serviceName.indexOf('/') != -1) { + serviceName = serviceName.substring(0, serviceName.indexOf('/')); + } + + String endpointName = (String) serviceNameToEprMap.get(serviceName); + if (endpointName == null){ + if (serviceName.indexOf(".") != -1){ + serviceName = serviceName.substring(0, serviceName.indexOf(".")); + endpointName = (String) serviceNameToEprMap.get(serviceName); + } + } + return new EndpointReference[]{new EndpointReference(endpointName)}; + } + + /** + * Returns the EPR for the given service and IP. (Picks up precomputed EPR) + * + * @param serviceName service name + * @param ip ignored + * @return the EPR for the service + * @throws AxisFault not used + */ + public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault { + return getEPRsForService(serviceName, ip)[0]; + } + + /** + * Starts listening for messages on this service + * + * @param service the AxisService just deployed + */ + private void startListeningForService(AxisService service) { + processService(service); + JMSConnectionFactory cf = getConnectionFactory(service); + if (cf == null) { + String msg = "Service " + service.getName() + " does not specify" + + "a JMS connection factory or refers to an invalid factory." + + "This service is being marked as faulty and will not be " + + "available over the JMS transport"; + log.warn(msg); + JMSUtils.markServiceAsFaulty( + service.getName(), msg, service.getAxisConfiguration()); + return; + } + + String destination = JMSUtils.getDestination(service); + try { + cf.listenOnDestination(destination); + log.info("Started listening on destination : " + destination + + " for service " + service.getName()); + + } catch (JMSException e) { + handleException( + "Could not listen on JMS for service " + service.getName(), e); + JMSUtils.markServiceAsFaulty( + service.getName(), e.getMessage(), service.getAxisConfiguration()); + } + } + + /** + * Stops listening for messages for the service undeployed + * + * @param service the AxisService just undeployed + */ + private void stopListeningForService(AxisService service) { + + JMSConnectionFactory cf = getConnectionFactory(service); + if (cf == null) { + String msg = "Service " + service.getName() + " does not specify" + + "a JMS connection factory or refers to an invalid factory." + + "This service is being marked as faulty and will not be " + + "available over the JMS transport"; + log.warn(msg); + JMSUtils.markServiceAsFaulty( + service.getName(), msg, service.getAxisConfiguration()); + return; + } + + // remove from the serviceNameToEprMap + serviceNameToEprMap.remove(service.getName()); + + String destination = JMSUtils.getDestination(service); + try { + cf.removeDestination(destination); + } catch (JMSException e) { + handleException( + "Error while terminating listening on JMS destination : " + destination, e); + } + } + + private void handleException(String msg, Exception e) { + log.error(msg, e); + throw new AxisJMSException(msg, e); + } + + /** + * An AxisObserver which will start listening for newly deployed services, + * and stop listening when services are undeployed. + */ + class JMSAxisObserver implements AxisObserver { + + // The initilization code will go here + public void init(AxisConfiguration axisConfig) { + } + + public void serviceUpdate(AxisEvent event, AxisService service) { + + if (JMSUtils.isJMSService(service)) { + switch (event.getEventType()) { + case AxisEvent.SERVICE_DEPLOY : + startListeningForService(service); + break; + case AxisEvent.SERVICE_REMOVE : + stopListeningForService(service); + break; + case AxisEvent.SERVICE_START : + startListeningForService(service); + break; + case AxisEvent.SERVICE_STOP : + stopListeningForService(service); + break; + } + } + } + + public void moduleUpdate(AxisEvent event, AxisModule module) { + } + + //-------------------------------------------------------- + public void addParameter(Parameter param) throws AxisFault { + } + + public void removeParameter(Parameter param) throws AxisFault { + } + + public void deserializeParameters(OMElement parameterElement) throws AxisFault { + } + + public Parameter getParameter(String name) { + return null; + } + + public ArrayList getParameters() { + return null; + } + + public boolean isParameterLocked(String parameterName) { + return false; + } + + public void serviceGroupUpdate(AxisEvent event, AxisServiceGroup serviceGroup) { + } + } + + public ConfigurationContext getConfigurationContext() { + return this.configCtx; + } + + + public SessionContext getSessionContext(MessageContext messageContext) { + return null; + } + + public void destroy() { + this.configCtx = null; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSMessageReceiver.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSMessageReceiver.java new file mode 100644 index 0000000000..e9e9f04ab2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSMessageReceiver.java @@ -0,0 +1,270 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.jms; + +import java.io.InputStream; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Queue; +import javax.jms.Topic; +import javax.naming.Context; +import javax.xml.stream.XMLStreamException; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.addressing.RelatesTo; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.engine.AxisEngine; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.axis2.util.MessageContextBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.emory.mathcs.backport.java.util.concurrent.Executor; + +/** + * This is the actual receiver which listens for and accepts JMS messages, and + * hands them over to be processed by a worker thread. An instance of this + * class is created for each JMSConnectionFactory, but all instances may and + * will share the same worker thread pool. + */ +public class JMSMessageReceiver implements MessageListener { + + private static final Log log = LogFactory.getLog(JMSMessageReceiver.class); + + /** + * The thread pool of workers + */ + private Executor workerPool = null; + /** + * The Axis configuration context + */ + private ConfigurationContext axisConf = null; + /** + * A reference to the JMS Connection Factory + */ + private JMSConnectionFactory jmsConFac = null; + + /** + * Create a new JMSMessage receiver + * + * @param jmsConFac the JMS connection factory associated with + * @param workerPool the worker thead pool to be used + * @param axisConf the Axis2 configuration + */ + JMSMessageReceiver(JMSConnectionFactory jmsConFac, + Executor workerPool, ConfigurationContext axisConf) { + this.jmsConFac = jmsConFac; + this.workerPool = workerPool; + this.axisConf = axisConf; + } + + /** + * Return the Axis configuration + * + * @return the Axis configuration + */ + public ConfigurationContext getAxisConf() { + return axisConf; + } + + /** + * Set the worker thread pool + * + * @param workerPool the worker thead pool + */ + public void setWorkerPool(Executor workerPool) { + this.workerPool = workerPool; + } + + /** + * The entry point on the recepit of each JMS message + * + * @param message the JMS message received + */ + public void onMessage(Message message) { + // directly create a new worker and delegate processing + try { + if (log.isDebugEnabled()) { + StringBuffer sb = new StringBuffer(); + sb.append("Received JMS message to destination : " + message.getJMSDestination()); + sb.append("\nMessage ID : " + message.getJMSMessageID()); + sb.append("\nCorrelation ID : " + message.getJMSCorrelationID()); + sb.append("\nReplyTo ID : " + message.getJMSReplyTo()); + log.debug(sb.toString()); + } + } catch (JMSException e) { + e.printStackTrace(); + } + workerPool.execute(new Worker(message)); + } + + /** + * Creates an Axis MessageContext for the received JMS message and + * sets up the transports and various properties + * + * @param message the JMS message + * @return the Axis MessageContext + */ + private MessageContext createMessageContext(Message message) { + + InputStream in = JMSUtils.getInputStream(message); + + try { + MessageContext msgContext = axisConf.createMessageContext(); + + // get destination and create correct EPR + Destination dest = message.getJMSDestination(); + String destinationName = null; + if (dest instanceof Queue) { + destinationName = ((Queue) dest).getQueueName(); + } else if (dest instanceof Topic) { + destinationName = ((Topic) dest).getTopicName(); + } + + String serviceName = jmsConFac.getServiceByDestination(destinationName); + + // hack to get around the crazy Active MQ dynamic queue and topic issues + if (serviceName == null) { + String provider = (String) jmsConFac.getProperties().get( + Context.INITIAL_CONTEXT_FACTORY); + if (provider.indexOf("activemq") != -1) { + serviceName = jmsConFac.getServiceNameForDestination( + ((dest instanceof Queue ? + JMSConstants.ACTIVEMQ_DYNAMIC_QUEUE : + JMSConstants.ACTIVEMQ_DYNAMIC_TOPIC) + destinationName)); + } + } + + + if (serviceName != null) { + // set to bypass dispatching and handover directly to this service + msgContext.setAxisService( + axisConf.getAxisConfiguration().getService(serviceName)); + } + + msgContext.setIncomingTransportName(Constants.TRANSPORT_JMS); + msgContext.setTransportIn( + axisConf.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS)); + + msgContext.setTransportOut( + axisConf.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS)); + // the reply is assumed to be on the JMSReplyTo destination, using + // the same incoming connection factory + + + JMSOutTransportInfo jmsOutTransportInfo; + + if ((jmsConFac.getJndiUser() == null) || (jmsConFac.getJndiPass() == null)) + jmsOutTransportInfo= new JMSOutTransportInfo(jmsConFac.getConFactory(), message.getJMSReplyTo()); + else + jmsOutTransportInfo= new JMSOutTransportInfo(jmsConFac.getConFactory(), jmsConFac.getUser(), jmsConFac.getPass(), message.getJMSReplyTo()); + + msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, jmsOutTransportInfo); + + msgContext.setServerSide(true); + msgContext.setMessageID(message.getJMSMessageID()); + + Destination replyTo = message.getJMSReplyTo(); + String jndiDestinationName = null; + if (replyTo == null) { + Parameter param = msgContext.getAxisService().getParameter(JMSConstants.REPLY_PARAM); + if (param != null && param.getValue() != null) { + jndiDestinationName = (String) param.getValue(); + } + } + + if (jndiDestinationName != null) { + msgContext.setReplyTo(jmsConFac.getEPRForDestination(jndiDestinationName)); + } + + String soapAction = JMSUtils.getProperty(message, JMSConstants.SOAPACTION); + if (soapAction != null) { + msgContext.setSoapAction(soapAction); + } + + msgContext.setEnvelope( + JMSUtils.getSOAPEnvelope(message, msgContext, in)); + + // set correlation id + String correlationId = message.getJMSCorrelationID(); + if (correlationId != null && correlationId.length() > 0) { + msgContext.setProperty(JMSConstants.JMS_COORELATION_ID, correlationId); + msgContext.setRelationships( + new RelatesTo[] { new RelatesTo(correlationId) }); + } + + return msgContext; + + } catch (JMSException e) { + handleException("JMS Exception reading the destination name", e); + } catch (AxisFault e) { + handleException("Axis fault creating the MessageContext", e); + } catch (XMLStreamException e) { + handleException("Error reading the SOAP envelope", e); + } + return null; + } + + private void handleException(String msg, Exception e) { + log.error(msg, e); + throw new AxisJMSException(msg, e); + } + + /** + * The actual Runnable Worker implementation which will process the + * received JMS messages in the worker thread pool + */ + class Worker implements Runnable { + + private Message message = null; + + Worker(Message message) { + this.message = message; + } + + public void run() { + MessageContext msgCtx = createMessageContext(message); + + AxisEngine engine = new AxisEngine(msgCtx.getConfigurationContext()); + try { + log.debug("Delegating JMS message for processing to the Axis engine"); + try { + engine.receive(msgCtx); + } catch (AxisFault e) { + log.debug("Exception occured when receiving the SOAP message", e); + if (msgCtx.isServerSide()) { + MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgCtx, e); + engine.sendFault(faultContext); + } + } + } catch (AxisFault af) { + log.error("JMS Worker [" + Thread.currentThread().getName() + + "] Encountered an Axis Fault : " + af.getMessage(), af); + } + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSOutTransportInfo.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSOutTransportInfo.java new file mode 100644 index 0000000000..5fa6542eec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSOutTransportInfo.java @@ -0,0 +1,220 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.jms; + +import java.util.Hashtable; + +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +import org.apache.axis2.transport.OutTransportInfo; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The JMS OutTransportInfo + */ +public class JMSOutTransportInfo implements OutTransportInfo { + + private static final Log log = LogFactory.getLog(JMSOutTransportInfo.class); + + private ConnectionFactory connectionFactory = null; + private String connectionFactoryUser = null; + private String connectionFactoryPassword = null; + private Destination destination = null; + + private String contentType = null; + + /** + * Creates an instance using the given connection factory and destination + * + * @param connectionFactory the connection factory + * @param dest the destination + */ + JMSOutTransportInfo(ConnectionFactory connectionFactory, Destination dest) { + this.connectionFactory = connectionFactory; + this.destination = dest; + } + + /** + * Creates an instance using the given connection factory and destination + * + * @param connectionFactory the connection factory + * @param dest the destination + */ + JMSOutTransportInfo(ConnectionFactory connectionFactory, String connectionFactoryUser, String connectionFactoryPassword, Destination dest) { + this.connectionFactory = connectionFactory; + this.connectionFactoryUser = connectionFactoryUser; + this.connectionFactoryPassword = connectionFactoryPassword; + this.destination = dest; + } + + /** + * Creates and instance using the given URL + * + * @param url the URL + */ + JMSOutTransportInfo(String url) { + if (!url.startsWith(JMSConstants.JMS_PREFIX)) { + handleException("Invalid JMS URL : " + url + + " Must begin with the prefix " + JMSConstants.JMS_PREFIX); + } else { + Context context = null; + Hashtable props = JMSUtils.getProperties(url); + try { + context = new InitialContext(props); + } catch (NamingException e) { + handleException("Could not get the initial context", e); + } + + connectionFactory = getConnectionFactory(context, props); + connectionFactoryUser = getConnectionFactoryUser(context, props); + connectionFactoryPassword = getConnectionFactoryPass(context, props); + destination = getDestination(context, url); + } + } + + /** + * Get the referenced ConnectionFactory using the properties from the context + * + * @param context the context to use for lookup + * @param props the properties which contains the JNDI name of the factory + * @return the connection factory + */ + private ConnectionFactory getConnectionFactory(Context context, Hashtable props) { + try { + + String conFacJndiName = (String) props.get(JMSConstants.CONFAC_JNDI_NAME_PARAM); + if (conFacJndiName != null) { + return (ConnectionFactory) context.lookup(conFacJndiName); + } else { + throw new NamingException( + "JMS Connection Factory JNDI name cannot be determined from url"); + } + } catch (NamingException e) { + handleException("Cannot get JMS Connection factory with props : " + props, e); + } + return null; + } + + /** + * Get the referenced ConnectionFactory Username (if supplied) using the properties from the context + * + * @param context the context to use for lookup + * @param props the properties which contains the JNDI name of the factory username + * @return the connection factory username (or null if one is not in the JNDI tree) + */ + private String getConnectionFactoryUser(Context context, Hashtable props) { + try { + + String conFacJndiUser = (String) props.get(JMSConstants.CONFAC_JNDI_NAME_USER); + if (conFacJndiUser != null) { + return (String) context.lookup(conFacJndiUser); + } else { + return null; + } + } catch (NamingException e) { + handleException("Cannot get JMS Connection factory username with props : " + props, e); + } + return null; + } + + /** + * Get the referenced ConnectionFactory Password (if supplied) using the properties from the context + * + * @param context the context to use for lookup + * @param props the properties which contains the JNDI name of the factory password + * @return the connection factory password (or null if one is not in the JNDI tree) + */ + private String getConnectionFactoryPass(Context context, Hashtable props) { + try { + + String conFacJndiPass = (String) props.get(JMSConstants.CONFAC_JNDI_NAME_PASS); + if (conFacJndiPass != null) { + return (String) context.lookup(conFacJndiPass); + } else { + return null; + } + } catch (NamingException e) { + handleException("Cannot get JMS Connection factory password with props : " + props, e); + } + return null; + } + + /** + * Get the JMS destination specified by the given URL from the context + * + * @param context the Context to lookup + * @param url URL + * @return the JMS destination, or null if it does not exist + */ + private Destination getDestination(Context context, String url) { + String destinationName = JMSUtils.getDestination(url); + try { + return (Destination) context.lookup(destinationName); + + } catch (NameNotFoundException e) { + log.warn("Cannot get or lookup JMS destination : " + destinationName + + " from url : " + url + " : " + e.getMessage()); + + } catch (NamingException e) { + handleException("Cannot get JMS destination : " + destinationName + + " from url : " + url, e); + } + return null; + } + + + private void handleException(String s) { + log.error(s); + throw new AxisJMSException(s); + } + + private void handleException(String s, Exception e) { + log.error(s, e); + throw new AxisJMSException(s, e); + } + + public Destination getDestination() { + return destination; + } + + public ConnectionFactory getConnectionFactory() { + return connectionFactory; + } + + public String getConnectionFactoryPassword() { + return connectionFactoryPassword; + } + + public String getConnectionFactoryUser() { + return connectionFactoryUser; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSSender.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSSender.java new file mode 100644 index 0000000000..7caa045015 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/JMSSender.java @@ -0,0 +1,389 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.jms; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.Hashtable; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; +import javax.xml.stream.XMLStreamException; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMOutputFormat; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.TransportOutDescription; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.handlers.AbstractHandler; +import org.apache.axis2.java.security.AccessController; +import org.apache.axis2.transport.TransportSender; +import org.apache.axis2.transport.http.HTTPTransportUtils; +import org.apache.axis2.transport.http.SOAPMessageFormatter; +import org.apache.axis2.transport.jms.JMSConstants; +import org.apache.axis2.transport.jms.JMSUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The TransportSender for JMS + */ +public class JMSSender extends AbstractHandler implements TransportSender { + + private static final Log log = LogFactory.getLog(JMSSender.class); + + /** + * Performs the actual sending of the JMS message + * + * @param msgContext the message context to be sent + * @throws AxisFault on exception + */ + public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { + + log.debug("JMSSender invoke()"); + + /* Added due to possible bug in Axis2, MTOM enablement is based on msgContext.isDoingMTOM + * However msgContext.isDoingMTOM will always return false unless set programmatically. + * HTTP sets this boolean programmatically by looking up whether enableMTOM has been set + * in axis2.xml or as an option on the client. + */ + msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext)); + + JMSOutTransportInfo transportInfo = null; + String targetAddress = null; + + // is there a transport url? which may be different from the WS-A To.. + targetAddress = (String) msgContext.getProperty( + Constants.Configuration.TRANSPORT_URL); + + if (targetAddress != null) { + transportInfo = new JMSOutTransportInfo(targetAddress); + } else if (targetAddress == null && msgContext.getTo() != null && + !msgContext.getTo().hasAnonymousAddress()) { + targetAddress = msgContext.getTo().getAddress(); + + if (!msgContext.getTo().hasNoneAddress()) { + transportInfo = new JMSOutTransportInfo(targetAddress); + } else { + //Don't send the message. + return InvocationResponse.CONTINUE; + } + } else if (msgContext.isServerSide()) { + // get the jms ReplyTo + transportInfo = (JMSOutTransportInfo) + msgContext.getProperty(Constants.OUT_TRANSPORT_INFO); + } + + // get the ConnectionFactory to be used for the send + ConnectionFactory connectionFac = transportInfo.getConnectionFactory(); + + Connection con = null; + try { + String user = transportInfo.getConnectionFactoryUser(); + String password = transportInfo.getConnectionFactoryPassword(); + + if ((user == null) || (password == null)){ + // Use the OS username and credentials + con = connectionFac.createConnection(); + } else{ + // use an explicit username and password + con = connectionFac.createConnection(user, password); + } + + Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); + Message message = createJMSMessage(msgContext, session); + + // get the JMS destination for the message being sent + Destination dest = transportInfo.getDestination(); + + if (dest == null) { + if (targetAddress != null) { + + // if it does not exist, create it + String name = JMSUtils.getDestination(targetAddress); + if (log.isDebugEnabled()) { + log.debug("Creating JMS Destination : " + name); + } + + try { + dest = session.createQueue(name); + } catch (JMSException e) { + handleException("Error creating destination Queue : " + name, e); + } + } else { + handleException("Cannot send reply to unknown JMS Destination"); + } + } + + MessageProducer producer = session.createProducer(dest); + Destination replyDest = null; + + boolean waitForResponse = + msgContext.getOperationContext() != null && + WSDL2Constants.MEP_URI_OUT_IN.equals( + msgContext.getOperationContext().getAxisOperation().getMessageExchangePattern()); + + if (waitForResponse) { + String replyToJNDIName = (String) msgContext.getProperty(JMSConstants.REPLY_PARAM); + if (replyToJNDIName != null && replyToJNDIName.length() > 0) { + Context context = null; + final Hashtable props = JMSUtils.getProperties(targetAddress); + try { + try { + context = (Context) AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Object run() throws NamingException{ + return new InitialContext(props); + } + } + ) + ; + } catch (PrivilegedActionException e) { + throw (NamingException) e.getException(); + } + } catch (NamingException e) { + handleException("Could not get the initial context", e); + } + + try { + replyDest = (Destination) context.lookup(replyToJNDIName); + + } catch (NameNotFoundException e) { + log.warn("Cannot get or lookup JMS response destination : " + + replyToJNDIName + " : " + e.getMessage() + + ". Attempting to create a Queue named : " + replyToJNDIName); + replyDest = session.createQueue(replyToJNDIName); + + } catch (NamingException e) { + handleException("Cannot get JMS response destination : " + + replyToJNDIName + " : ", e); + } + + } else { + try { + // create temporary queue to receive reply + replyDest = session.createTemporaryQueue(); + } catch (JMSException e) { + handleException("Error creating temporary queue for response"); + } + } + message.setJMSReplyTo(replyDest); + if (log.isDebugEnabled()) { + log.debug("Expecting a response to JMS Destination : " + + (replyDest instanceof Queue ? + ((Queue) replyDest).getQueueName() : ((Topic) replyDest).getTopicName())); + } + } + + try { + log.debug("[" + (msgContext.isServerSide() ? "Server" : "Client") + + "]Sending message to destination : " + dest); + producer.send(message); + producer.close(); + + } catch (JMSException e) { + handleException("Error sending JMS message to destination : " + + dest.toString(), e); + } + + if (waitForResponse) { + try { + // wait for reply + MessageConsumer consumer = session.createConsumer(replyDest); + + long timeout = JMSConstants.DEFAULT_JMS_TIMEOUT; + Long waitReply = (Long) msgContext.getProperty(JMSConstants.JMS_WAIT_REPLY); + if (waitReply != null) { + timeout = waitReply.longValue(); + } + + log.debug("Waiting for a maximum of " + timeout + + "ms for a response message to destination : " + replyDest); + con.start(); + Message reply = consumer.receive(timeout); + + if (reply != null) { + msgContext.setProperty(MessageContext.TRANSPORT_IN, + JMSUtils.getInputStream(reply)); + } else { + log.warn("Did not receive a JMS response within " + + timeout + " ms to destination : " + dest); + } + + } catch (JMSException e) { + handleException("Error reading response from temporary " + + "queue : " + replyDest, e); + } + } + } catch (JMSException e) { + handleException("Error preparing to send message to destination", e); + + } finally { + if (con != null) { + try { + con.close(); // closes all sessions, producers, temp Q's etc + } catch (JMSException e) { + } // ignore + } + } + return InvocationResponse.CONTINUE; + } + + public void cleanup(MessageContext msgContext) throws AxisFault { + // do nothing + } + + public void init(ConfigurationContext confContext, + TransportOutDescription transportOut) throws AxisFault { + // do nothing + } + + public void stop() { + // do nothing + } + + /** + * Create a JMS Message from the given MessageContext and using the given + * session + * + * @param msgContext the MessageContext + * @param session the JMS session + * @return a JMS message from the context and session + * @throws JMSException on exception + */ + private Message createJMSMessage(MessageContext msgContext, Session session) + throws JMSException { + + Message message = null; + String msgType = getProperty(msgContext, JMSConstants.JMS_MESSAGE_TYPE); + + OMElement msgElement = msgContext.getEnvelope(); + if (msgContext.isDoingREST()) { + msgElement = msgContext.getEnvelope().getBody().getFirstElement(); + } + + if (msgType != null && JMSConstants.JMS_BYTE_MESSAGE.equals(msgType)) { + + message = session.createBytesMessage(); + BytesMessage bytesMsg = (BytesMessage) message; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OMOutputFormat format = new OMOutputFormat(); + + /* Added due to possible bug in Axis2, OMOutputFormat's boolean isSOAP11 defaults to true. + * This means that if left untouched all JMS byte messages must be SOAP 1.1 + * We set the boolean here based on the messageContexts value, which is assertained from + * the soap namespace used. This is what HTTP does also. + */ + format.setSOAP11(msgContext.isSOAP11()); + format.setCharSetEncoding( + getProperty(msgContext, Constants.Configuration.CHARACTER_SET_ENCODING)); + format.setDoOptimize(msgContext.isDoingMTOM()); + try { + msgElement.serializeAndConsume(baos, format); + baos.flush(); + } catch (XMLStreamException e) { + handleException("XML serialization error creating BytesMessage", e); + } catch (IOException e) { + handleException("IO Error while creating BytesMessage", e); + } + bytesMsg.writeBytes(baos.toByteArray()); + + /* Added due to possible bug in Axis2, the content type is never set for a JMS byte message. This + * goes unnoticed when MTOM is not used, as the server can handle the message. However once MTOM + * is used a contentType of multipart/related is required. + */ + bytesMsg.setStringProperty(JMSConstants.CONTENT_TYPE, + new SOAPMessageFormatter().getContentType(msgContext, format, null)); + } else { + message = session.createTextMessage(); // default + TextMessage txtMsg = (TextMessage) message; + txtMsg.setText(msgElement.toString()); + } + + // set the JMS correlation ID if specified + String correlationId = getProperty(msgContext, JMSConstants.JMS_COORELATION_ID); + if (correlationId == null && msgContext.getRelatesTo() != null) { + correlationId = msgContext.getRelatesTo().getValue(); + } + + if (correlationId != null) { + message.setJMSCorrelationID(correlationId); + } + + if (msgContext.isServerSide()) { + // set SOAP Action and context type as properties on the JMS message + setProperty(message, msgContext, JMSConstants.SOAPACTION); + setProperty(message, msgContext, JMSConstants.CONTENT_TYPE); + } else { + String action = msgContext.getOptions().getAction(); + if (action != null) { + message.setStringProperty(JMSConstants.SOAPACTION, action); + } + } + + return message; + } + + private void setProperty(Message message, MessageContext msgCtx, String key) { + + String value = getProperty(msgCtx, key); + if (value != null) { + try { + message.setStringProperty(key, value); + } catch (JMSException e) { + log.warn("Couldn't set message property : " + key + " = " + value, e); + } + } + } + + private String getProperty(MessageContext mc, String key) { + return (String) mc.getProperty(key); + } + + private static void handleException(String s) { + log.error(s); + throw new AxisJMSException(s); + } + + private static void handleException(String s, Exception e) { + log.error(s, e); + throw new AxisJMSException(s, e); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/README b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/README new file mode 100644 index 0000000000..5df1751298 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/jms/README @@ -0,0 +1,14 @@ +The classes in this package are a copy of the same classes from the +Axis2 package org.apache.axis2.transport.jms in the Axis2 1.4.1 release. + +The only change is in the listenOnDestination method in JMSConnectionFactory +to use Tuscany threads instead of the setMessageListener call approach when +running in a JEE container where setMessageListener is prohibited. There are +several classes copied in this Tuscany package as many of the constructors +and methods are not public so we can't just subclass to fix the problem. + +In Axis2 1.5 and the new separately released JMS transport will fix this +problem so when we move up to that in Tuscany we can get rid of this package. + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java new file mode 100644 index 0000000000..4c18c89353 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.configurator; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.security.auth.Subject; + +import org.apache.axiom.om.util.Base64; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.SecurityUtil; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; +import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; +import org.osoa.sca.ServiceRuntimeException; + +/** + * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingBasicAuthenticationConfigurator { + + + public static void setOperationOptions(OperationClient operationClient, Message msg, BasicAuthenticationPolicy policy) { + String username = null; + String password = null; + + // get the security context + Subject subject = SecurityUtil.getSubject(msg); + BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject, + BasicAuthenticationPrincipal.class); + + // could use the security principal to look up basic auth credentials + if ( principal != null ) { + username = ((BasicAuthenticationPrincipal)principal).getName(); + password = ((BasicAuthenticationPrincipal)principal).getPassword(); + } + + if (username == null || password == null ){ + throw new ServiceRuntimeException("Basic authentication username or password is null"); + } + + HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); + List auth = new ArrayList(); + auth.add(Authenticator.BASIC); + authenticator.setAuthSchemes(auth); + authenticator.setPreemptiveAuthentication(true); + authenticator.setUsername(username); + authenticator.setPassword(password); + + operationClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, + authenticator); + } + + public static void parseHTTPHeader(MessageContext messageContext, Message msg, BasicAuthenticationPolicy policy) { + + Map httpHeaderProperties = (Map)messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + + String basicAuthString = (String)httpHeaderProperties.get("Authorization"); + String decodedBasicAuthString = null; + String username = null; + String password = null; + + if (basicAuthString != null) { + basicAuthString = basicAuthString.trim(); + + if (basicAuthString.startsWith("Basic ")) { + decodedBasicAuthString = new String(Base64.decode(basicAuthString.substring(6))); + } + + int collonIndex = decodedBasicAuthString.indexOf(':'); + + if (collonIndex == -1){ + username = decodedBasicAuthString; + } else { + username = decodedBasicAuthString.substring(0, collonIndex); + password = decodedBasicAuthString.substring(collonIndex + 1); + } + } + + // get the security context + Subject subject = SecurityUtil.getSubject(msg); + BasicAuthenticationPrincipal principal = new BasicAuthenticationPrincipal(username, + password); + subject.getPrincipals().add(principal); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java new file mode 100644 index 0000000000..647f934c02 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.configurator; + + + +import javax.xml.namespace.QName; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axiom.soap.SOAPHeader; +import org.apache.axis2.context.MessageContext; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeader; +import org.apache.tuscany.sca.invocation.Message; + + +/** + * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances + * + * @version $Rev$ $Date$ + */ +public class Axis2BindingHeaderConfigurator { + + + public static void setHeader(MessageContext messageContext, Message msg, QName headerQName) { + + if (headerQName != null){ + SOAPEnvelope envelope = messageContext.getEnvelope(); + OMFactory factory = envelope.getOMFactory(); + SOAPHeader soapHeader = envelope.getHeader(); + + Axis2SOAPHeader header = Axis2HeaderPolicyUtil.getHeader(msg, headerQName) ; + + if (header != null){ + soapHeader.addChild(header.getAsSOAPHeaderBlock(factory)); + } + } + } + + public static void getHeader(MessageContext messageContext, Message msg, QName headerQName, Axis2SOAPHeader header) { + + SOAPEnvelope sev = messageContext.getEnvelope(); + SOAPHeader sh = sev.getHeader(); + OMElement omHeader = sh.getFirstChildWithName(headerQName); + + header.setAsSOAPHeaderBlock(omHeader); + + msg.getHeaders().add(header); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..a48ff54c77 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..370b83f87b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.binding.ws.axis2.WSBindingDefinitionsProvider \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml new file mode 100644 index 0000000000..6bff613a7c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + Communication through this binding requires SOAP + + + + + + Communication through this binding requires SOAP 1.1 + + + + + + Communication through this binding requires SOAP 1.2 + + + + + + Communication through this binding requires MTOM support + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml new file mode 100644 index 0000000000..f75a2e8cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml @@ -0,0 +1,504 @@ + + + + + + + + true + false + false + false + + + + + + + + + 30000 + + + + + + true + + + + + + false + + admin + axis2 + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6060 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + HTTP/1.1 + chunked + + + + + + + HTTP/1.1 + chunked + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list new file mode 100644 index 0000000000..e6e70dfd4b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list @@ -0,0 +1 @@ +rampart-1.4.mar \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar new file mode 100644 index 0000000000..ec870734a5 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar differ diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java new file mode 100644 index 0000000000..2ce23bf2c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import junit.framework.TestCase; + +public class Axis2ReferenceTestCase extends TestCase { + + public void testInvokeService() throws Exception { +// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); +// ServiceContract contract = new JavaServiceContract(); +// Operation operation = new Operation("sayHi", null, null, null, false, null, NO_CONVERSATION); +// TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(contract, operation); +// assertNotNull(targetInvoker); +// assertFalse(targetInvoker instanceof Axis2AsyncTargetInvoker); + } + + public void testAsyncTargetInvoker() throws Exception { +// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName"); +// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class +// Wire inboundWire = EasyMock.createNiceMock(Wire.class); +// JavaServiceContract contract = new JavaServiceContract(Greeter.class); +// contract.setCallbackName(""); +// contract.setCallbackClass(GreetingCallback.class); +// Operation callbackOp = +// new Operation("sayHiCallback", null, null, null, true, null, NO_CONVERSATION); +// HashMap> callbackOps = new HashMap>(); +// callbackOps.put("sayHiCallback", callbackOp); +// contract.setCallbackOperations(callbackOps); +// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes(); +// EasyMock.replay(inboundWire); +// +// axis2Reference.setWire(inboundWire); +// Operation operation = new Operation("sayHi", null, null, null, true, null, NO_CONVERSATION); +// TargetInvoker asyncTargetInvoker = axis2Reference.createTargetInvoker(contract, operation); +// assertNotNull(asyncTargetInvoker); +// assertTrue(asyncTargetInvoker instanceof Axis2AsyncTargetInvoker); + } + +// @SuppressWarnings("unchecked") +// private Axis2ReferenceBinding createAxis2Reference(String webAppName, String serviceName) throws Exception { +// //Create WebServiceBindingDefinition +// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; +// URL url = getClass().getResource(wsdlLocation); +// assertNotNull("Could not find wsdl " + url.toString(), url); +// +// WSDLFactory factory = WSDLFactory.newInstance(); +// WSDLReader reader = factory.newWSDLReader(); +// reader.setFeature("javax.wsdl.verbose", false); +// InputSource input = new InputSource(url.openStream()); +// Definition wsdlDef = reader.readWSDL(url.toString(), input); +// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", +// "SOAPService")); +// Port port = wsdlService.getPort("SoapPort"); +// WebServiceBindingDefinition wsBinding = +// new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); +// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. +// // TODO figure out what to do with the service contract +// ServiceContract contract = new WSDLServiceContract(); +// contract.setInterfaceClass(Greeter.class); +// return new Axis2ReferenceBinding(URI.create(serviceName), +// wsBinding, +// contract, +// null, +// null); +// } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java new file mode 100644 index 0000000000..d4d20414e5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +import junit.framework.TestCase; + +public class Axis2ServiceTestCase extends TestCase { + + public void testInvokeService() throws Exception { +// TestServletHost tomcatHost = new TestServletHost(); +// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, false); +// axis2Service.start(); +// +// if (true) return; +// Servlet servlet = tomcatHost.getMapping("testWebAppName/serviceBindings/testServiceName"); +// assertNotNull(servlet); +// +// //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet +// //To be done: + + } + + public void testAsyncMessageReceiver() throws Exception { + +// TestServletHost tomcatHost = new TestServletHost(); +// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, true); +// axis2Service.start(); + } + +// @SuppressWarnings("unchecked") +// private Axis2ServiceBinding createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback) +// throws Exception { +// //Create WebServiceBindingDefinition +// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl"; +// URL url = getClass().getResource(wsdlLocation); +// assertNotNull("Could not find wsdl " + url.toString(), url); +// +// WSDLFactory factory = WSDLFactory.newInstance(); +// WSDLReader reader = factory.newWSDLReader(); +// reader.setFeature("javax.wsdl.verbose", false); +// InputSource input = new InputSource(url.openStream()); +// Definition wsdlDef = reader.readWSDL(url.toString(), input); +// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http", +// "SOAPService")); +// Port port = wsdlService.getPort("SoapPort"); +// WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService); +// +// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance. +//// WireService wireService = EasyMock.createNiceMock(WireService.class); +//// wireService.createProxy(EasyMock.isA(Class.class), EasyMock.isA(Wire.class)); +//// EasyMock.expectLastCall().andReturn(null); +//// EasyMock.replay(wireService); +// +// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class +// Wire inboundWire = EasyMock.createNiceMock(Wire.class); +// JavaServiceContract contract = new JavaServiceContract(Greeter.class); +// Map> opMap = new HashMap>(); +// for (Method m : Greeter.class.getMethods()) { +// opMap.put(m.getName(), new Operation(m.getName(), null, null, null)); +// } +// contract.setOperations(opMap); +// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes(); +// if (callback) { +// contract.setCallbackName(""); +// } +// EasyMock.replay(inboundWire); +// +// Wire outboundWire = EasyMock.createNiceMock(Wire.class); +// Map, InvocationChain> map = new HashMap, InvocationChain>(); +// EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once(); +// EasyMock.replay(outboundWire); +// +// TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(); +// ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext(); +// Axis2ServiceBinding axis2Service = +// new Axis2ServiceBinding(URI.create(serviceName), +// contract, +// null, +// wsBinding, +// tomcatHost, +// configurationContext, null); +// axis2Service.setWire(inboundWire); +//// axis2Service.setOutboundWire(outboundWire); +// +// return axis2Service; +// } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java new file mode 100644 index 0000000000..767f59646f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +public interface Greeter { + + String sayHi(); + + String greetMe(String requestType); + + void greetMeOneWay(String requestType); + + void greetMeWithCallback(String requestType); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java new file mode 100644 index 0000000000..e5e76af0b7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2; + +public interface GreetingCallback { + + void greetMeCallback(String greetMeResponse); +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java new file mode 100644 index 0000000000..4e7c1b0539 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Remotable; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface Account { + + CustomerProfileData getCustomerProfile(String loginID); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java new file mode 100644 index 0000000000..5edb4ddc5a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class AccountService implements Account { + + public CustomerProfileData getCustomerProfile(String loginID) { + return new CustomerProfileData(loginID); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java new file mode 100644 index 0000000000..2dc7d8dee4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import java.io.Serializable; + +public class Bar implements Serializable { + private static final long serialVersionUID = 1249963611910502668L; + + private String s; + private int x; + private Integer y; + + private Boolean b; + + public Boolean getB() { + return b; + } + public void setB(Boolean b) { + this.b = b; + } + public String getS() { + return s; + } + public void setS(String s) { + this.s = s; + } + public int getX() { + return x; + } + public void setX(int x) { + this.x = x; + } + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java new file mode 100644 index 0000000000..5c1ee6a435 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class CustomerProfileData { + + private String firstName; + private String lastName; + private String address; + private String email; + private String loginID; + private String password; + private int id; + + public CustomerProfileData(String loginID) { + firstName = "John"; + lastName = "Doe"; + address = "345 Main Street"; + email = "john@doe.org"; + this.loginID = loginID; + password = "hello"; + id = 1234; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String firstName) { + this.lastName = lastName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getLoginID() { + return loginID; + } + + public void setLoginID(String loginID) { + this.loginID = loginID; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java new file mode 100644 index 0000000000..6fccbcfd00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Echo { + + Foo echoFoo(Foo foo); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java new file mode 100644 index 0000000000..5e1a4cf259 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Reference; + +public class EchoComponent implements Echo { + + @Reference + public Echo echoWS; + + public Foo echoFoo(Foo foo) { + return echoWS.echoFoo(foo); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java new file mode 100644 index 0000000000..d028ced69e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + + +public class EchoImpl implements Echo { + + public Foo echoFoo(Foo foo) { + return foo; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java new file mode 100644 index 0000000000..c7b503af17 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import java.io.Serializable; + +public class Foo implements Serializable { + private static final long serialVersionUID = 4879476066850018458L; + + private Bar[] bars; + + public Bar[] getBars() { + return bars; + } + + public void setBars(Bar[] bars) { + this.bars = bars; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java new file mode 100644 index 0000000000..f474c12af3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorld { + + String getGreetings(String s); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java new file mode 100644 index 0000000000..88705c1a95 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldComponent implements HelloWorld { + + @Reference + public HelloWorld helloWorldWS; + + public String getGreetings(String s) { + return helloWorldWS.getGreetings(s); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java new file mode 100644 index 0000000000..f30286feea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +public class HelloWorldMultiService implements HelloWorldOM, HelloWorldOM2 { + + public OMElement getGreetings(OMElement requestOM) { + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello " + name)); + + return responseOM; + } + + public OMElement getGreetings2(OMElement requestOM) { + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello2 " + name)); + + return responseOM; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java new file mode 100644 index 0000000000..7ee48d4451 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests ; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldNoWSDLTestCase extends TestCase { + + private SCADomain domain; + + public void testHelloWorld() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + /** + * Test a a WS call with a complex type + */ + public void testEchoFoo() throws Exception { + Echo echo = domain.getService(Echo.class, "EchoComponent"); + + Foo f = new Foo(); + Bar b1 = new Bar(); + b1.setS("petra"); + b1.setX(1); + b1.setY(new Integer(2)); + b1.setB(Boolean.TRUE); + Bar b2 = new Bar(); + b2.setS("beate"); + b2.setX(3); + b2.setY(new Integer(4)); + b2.setB(Boolean.FALSE); + f.setBars(new Bar[] { b1, b2} ); + + Foo f2 = echo.echoFoo(f); + + assertEquals("petra", f2.getBars()[0].getS()); + assertEquals(1, f2.getBars()[0].getX()); + assertEquals(2, f2.getBars()[0].getY().intValue()); + assertTrue(f2.getBars()[0].getB().booleanValue()); + assertEquals("beate", f2.getBars()[1].getS()); + assertEquals(3, f2.getBars()[1].getX()); + assertEquals(4, f2.getBars()[1].getY().intValue()); + assertFalse(f2.getBars()[1].getB().booleanValue()); + + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java new file mode 100644 index 0000000000..274f6c8d28 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldOM { + + OMElement getGreetings(OMElement parmE); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java new file mode 100644 index 0000000000..bf371430a1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldOM2 { + + OMElement getGreetings2(OMElement parmE); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java new file mode 100644 index 0000000000..d1cbfb88fd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Reference; + +public class HelloWorldOMComponent implements HelloWorldOM { + + @Reference + public HelloWorldOM helloWorldWS; + + public OMElement getGreetings(OMElement om) { + return helloWorldWS.getGreetings(om); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java new file mode 100644 index 0000000000..71d7bf68fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; + +public class HelloWorldOMService implements HelloWorldOM { + + public OMElement getGreetings(OMElement requestOM) { + System.out.println(" **** getGreetings **** "); + String name = requestOM.getFirstElement().getText(); + + OMFactory omFactory = OMAbstractFactory.getOMFactory(); + OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld"); + OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld"); + responseOM.addChild(param); + param.addChild(omFactory.createOMText("Hello " + name)); + + return responseOM; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java new file mode 100644 index 0000000000..e7511027c2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite"); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java new file mode 100644 index 0000000000..017d9bb478 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +public class HelloWorldService implements HelloWorld { + + public String getGreetings(String s) { + return "Hello " + s; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java new file mode 100644 index 0000000000..a3a43d032f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldTestCase extends TestCase { + + private SCADomain domain; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite"); + helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java new file mode 100644 index 0000000000..8e17b89f33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldWSDLMergedTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite"); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldWSDLMergedComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java new file mode 100644 index 0000000000..b276d8210f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class QuestionMarkWSDLImportTestCase extends TestCase { + + private SCADomain domain; + + /** + * Tests ?wsdl works and returns the correct port endpoint from the WSDL + */ + public void testWSDLImportPortEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8086/AccountService?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose", false); + wsdlReader.setFeature("javax.wsdl.importDocuments", true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8086/AccountService?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://account2/AccountService/$promoted$ep1", "AccountService")); + Port port = service.getPort("AccountSoapPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8086/AccountService", endpoint); + } + + private String getEndpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java new file mode 100644 index 0000000000..0d10881e7b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * ********* Currently broken, see TUSCANY-2942 + * + * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $ + */ +public class QuestionMarkWSDLIncludeTestCaseFIXME extends TestCase { + + private SCADomain domain; + + /** + * Tests ?wsdl works and returns the correct port endpoint from the WSDL + */ + public void testWSDLIncludePortEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose", false); + wsdlReader.setFeature("javax.wsdl.importDocuments", true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$ep1", "AccountService")); + Port port = service.getPort("AccountSoapPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/AccountService", endpoint); + } + + private String getEndpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java new file mode 100644 index 0000000000..0508f28e11 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class QuestionMarkWSDLTestCase extends TestCase { + + private SCADomain domain; + + /** + * Tests ?wsdl works and returns the correct port endpoint from the WSDL + */ + public void testWSDLPortEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/services/HelloWorldWebService?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/services/HelloWorldWebService?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://helloworld/HelloWorldService/$promoted$ep1", + "HelloWorldService")); + Port port = service.getPort("HelloWorldSoapPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/services/HelloWorldWebService", endpoint); + } + + /** + * Tests ?wsdl works and returns the correct port endpoint from binding.ws with a custom URI + */ + public void testCustomEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/foo/bar?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/foo/bar?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://itests.axis2.ws.binding.sca.tuscany.apache.org/", + "HelloWorldService")); + Port port = service.getPort("HelloWorldPort"); + + String endpoint = getEndpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/foo/bar", endpoint); + } + + protected String getEndpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java new file mode 100644 index 0000000000..5efbedba4c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.ServiceRuntimeException; + +/** + * This test verifies that the Endpoint URI specified in the wsdl takes precedence over the URI specified + * in binding. Ref: WS Binding Specification V1.00 - Section 2.1.1 + * + * @version $Rev$ $Date$ + */ +public class UriPrecedenceTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testUriPrecedence() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-prec", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-prec", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + try { + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } catch (ServiceRuntimeException e) { + fail("Endpoint URI from wsdl did not take precedence over URI in binding."); + } + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite"); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..56d0537a44 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.endpoints; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractHelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testCalculator() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java new file mode 100644 index 0000000000..661afdddad --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.endpoints; + +public class DefaultMultiServiceTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java new file mode 100644 index 0000000000..9b2e0eafa0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.endpoints; + +public class DefaultSingleServiceTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java new file mode 100644 index 0000000000..98d9a73926 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.endpoints; + +public class WSDLExplicitURITestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java new file mode 100644 index 0000000000..201d11a79f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.endpoints; + +public class WSDLRelativeURITestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java new file mode 100644 index 0000000000..f5d87cdcee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.epr; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldTestCase extends TestCase { + + private SCADomain domain; + private HelloWorld helloWorld; + + public void testCalculator() throws Exception { + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite"); + helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java new file mode 100644 index 0000000000..cf5e4947d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.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.itests.mtom; + +import javax.activation.DataHandler; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; +import java.awt.Image; +import org.apache.axiom.om.OMElement; +import javax.xml.transform.Source; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate the FileTransfer service and invoke it. + */ +@Service(FileTransferServiceClient.class) +public class FileTransferClient implements FileTransferServiceClient { + + @Reference + public FileTransferService fileTransferService; + + public String uploadImageFileForward (Image attachment) throws Exception { + return fileTransferService.uploadImageFile(attachment); + } + + public String uploadSourceFileForward (Source attachment) throws Exception { + return fileTransferService.uploadSourceFile(attachment); + } + + public String uploadDataHandlerFileForward (DataHandler attachment) throws Exception { + return fileTransferService.uploadDataHandlerFile(attachment); + } + + public String uploadOMElementFileForward (OMElement attachment) throws Exception { + return fileTransferService.uploadOMElementFile(attachment); + } + + public String sendMyExceptionForward (MyException attachment) throws Exception { + return fileTransferService.sendMyException(attachment); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java new file mode 100644 index 0000000000..35bf6888e3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.activation.DataHandler; +import javax.activation.FileDataSource; +import java.awt.Image; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMText; +import javax.xml.transform.dom.DOMSource; +import org.apache.axiom.om.OMFactory; +import java.awt.image.BufferedImage; + +import junit.framework.TestCase; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferServiceClient; +import org.apache.tuscany.sca.databinding.xml.String2Node; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class FileTransferMTOMTestCase extends TestCase { + + private SCADomain domain; + private FileTransferServiceClient filetransfer; + + /** + * Runs once before the tests + */ + @BeforeClass + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite"); + filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); + } + + /** + * Runs once after the tests + */ + @AfterClass + protected void tearDown() throws Exception { + domain.close(); + } + + @Test + public void testImageFileTransfer() throws Exception { + try { + Image image = new BufferedImage(80, 24, BufferedImage.TYPE_INT_RGB); + assertEquals("File uploaded Sucessfully", filetransfer.uploadImageFileForward(image)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testSourceFileTransfer() throws Exception { + try { + String xml = "ABC"; + Source source = new DOMSource(new String2Node().transform(xml, null)); + assertEquals("File uploaded Sucessfully", filetransfer.uploadSourceFileForward(source)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testDataHandlerFileTransfer() throws Exception { + try { + // For testing purpose lets try uploading LICENSE file. + DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); + assertEquals("File uploaded Sucessfully", filetransfer.uploadDataHandlerFileForward(dataHandler)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testOMElementFileTransfer() throws Exception { + try { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement imageElement = factory.createOMElement(new QName("image")); + + DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); + + OMText textData = factory.createOMText(dataHandler, true); + imageElement.addChild(textData); + assertEquals("File uploaded Sucessfully", filetransfer.uploadOMElementFileForward(imageElement)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testSendMyException() throws Exception { + try { + MyException exp = new MyExceptionImpl(); + assertEquals("File uploaded Sucessfully", filetransfer.sendMyExceptionForward(exp)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java new file mode 100644 index 0000000000..ab7fc9c43a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import org.osoa.sca.annotations.Remotable; +import javax.activation.DataHandler; +import java.awt.Image; +import javax.xml.transform.Source; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.apache.axiom.om.OMElement; + +/** + * This is the business interface of the MTOM FileTransfer service. + */ +@Remotable +public interface FileTransferService { + + public String uploadImageFile(Image attachment) throws Exception; + + public String uploadSourceFile(Source attachment) throws Exception; + + public String uploadDataHandlerFile(DataHandler attachment) throws Exception; + + public String uploadOMElementFile(OMElement attachment) throws Exception; + + //This method uses an user defined interface MyException as parameter type. + public String sendMyException(@XmlJavaTypeAdapter(MyExceptionAdapter.class) MyException attachment) + throws Exception; +} + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java new file mode 100644 index 0000000000..5fc95441b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.activation.DataHandler; +import java.awt.Image; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.transform.Source; +import org.apache.axiom.om.OMElement; + +/** + * This is the client interface of the File Transfer service. + */ +public interface FileTransferServiceClient { + + public String uploadImageFileForward (Image attachment) throws Exception; + + public String uploadSourceFileForward (Source attachment) throws Exception; + + public String uploadDataHandlerFileForward (DataHandler attachment) throws Exception; + + public String uploadOMElementFileForward (OMElement attachment) throws Exception; + + public String sendMyExceptionForward (MyException attachment) throws Exception; +} + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java new file mode 100644 index 0000000000..cc757e5e33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.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.itests.mtom; + +import org.osoa.sca.annotations.Service; +import javax.activation.DataHandler; +import java.awt.Image; +import javax.xml.transform.Source; +import org.apache.axiom.om.OMElement; + +/** + * This class implements the HelloWorld service. + */ +@Service(interfaces={FileTransferService.class}) +public class FileTransferServiceImpl implements FileTransferService { + + public String uploadImageFile(Image attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } + + public String uploadSourceFile(Source attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } + + public String uploadDataHandlerFile(DataHandler attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } + + public String uploadOMElementFile(OMElement attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } + + public String sendMyException(MyException attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java new file mode 100644 index 0000000000..5ecc22572b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +//@XmlJavaTypeAdapter(MyExceptionAdapter.class) +public interface MyException { + + public String getMessage(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java new file mode 100644 index 0000000000..4c4e8a3fcf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +public class MyExceptionAdapter extends XmlAdapter { + public MyException unmarshal(MyExceptionImpl v) { + return v; + } + + public MyExceptionImpl marshal(MyException v) { + return (MyExceptionImpl)v; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java new file mode 100644 index 0000000000..1bd9b9b1a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +public class MyExceptionImpl extends Exception implements MyException { + + public String getMessage() { + return "good job......"; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..6cdb12c221 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractHelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java new file mode 100644 index 0000000000..67d6f1c56e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..45c5472100 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class IntegrityPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Integrity Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java new file mode 100644 index 0000000000..7a4b50cc2c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java new file mode 100644 index 0000000000..18a713a243 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +public class WSSecurityAuthenticationTestCaseFIXME extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java new file mode 100644 index 0000000000..1fd1b8d48e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +import java.security.Provider; +import java.security.Security; + +public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCase { + + /** + * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + // Workaround an issue with IBM JDK + Provider jce = Security.getProvider("IBMJCE"); + if (jce != null) { + // Make sure IBMJCE is used first + Security.removeProvider("IBMJCE"); + Security.insertProviderAt(jce, 1); + } + super.setUp(); + } + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java new file mode 100644 index 0000000000..824132161c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams; + +public class WSSecurityIntegrityTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..458a472479 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed; + +import junit.framework.Assert; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public abstract class AbstractHelloWorldOMTestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + @Test + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @After + public void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java new file mode 100644 index 0000000000..88fc0d63fa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..0d8914156f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class IntegrityPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Integrity Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java new file mode 100644 index 0000000000..5840f71057 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println(" **** 1. UserId : " + pwcb.getIdentifer()); + System.out.println(" **** 2. Passwd : " + pwcb.getPassword()); + System.out.println(" **** 3. Usage : " + pwcb.getUsage()); + + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java new file mode 100644 index 0000000000..db5b88f9ac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed; + +public class WSSecurityMixedTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java new file mode 100644 index 0000000000..04de589fb1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCase.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOM; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractHelloWorldOMTestCase extends TestCase { + + private SCADomain domain; + private HelloWorldOM helloWorld; + + public void testHelloWorld() throws Exception { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld"); + OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld"); + requestOM.addChild(parmE); + parmE.addChild(fac.createOMText("petra")); + OMElement responseOM = helloWorld.getGreetings(requestOM); + OMElement child = (OMElement)responseOM.getFirstElement(); + Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText()); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + helloWorld = domain.getService(HelloWorldOM.class, "HelloWorldComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java new file mode 100644 index 0000000000..cf342653c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java new file mode 100644 index 0000000000..84b64d3902 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class IntegrityPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Integrity Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java new file mode 100644 index 0000000000..04825b6b56 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + * + * @version $Rev$ $Date$ + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java new file mode 100644 index 0000000000..a439ff4c8f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +public class WSSecurityAuthenticationTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java new file mode 100644 index 0000000000..f37a8deeb7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +import java.security.Provider; +import java.security.Security; + +public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCase { + + /** + * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + // Workaround an issue with IBM JDK + Provider jce = Security.getProvider("IBMJCE"); + if (jce != null) { + // Make sure IBMJCE is used first + Security.removeProvider("IBMJCE"); + Security.insertProviderAt(jce, 1); + } + super.setUp(); + } + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java new file mode 100644 index 0000000000..18bbf98628 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCase.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy; + +public class WSSecurityIntegrityTestCase extends AbstractHelloWorldOMTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java new file mode 100644 index 0000000000..b2ccd7f97d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCase.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.soap12 ; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class HelloWorldSOAP12TestCase extends TestCase { + + private SCADomain domain; + + public void testHelloWorld() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClient"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP11() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP11"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + public void testHelloWorldSOAP12() throws Exception { + HelloWorld helloWorld = domain.getService(HelloWorld.class, "HelloWorldClientSOAP12"); + assertEquals("Hello petra", helloWorld.getGreetings("petra")); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java new file mode 100644 index 0000000000..8d378565d4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.soap12; + +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap12.SOAP12Address; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axis2.transport.http.server.HttpUtils; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev$ $Date$ + */ +public class QuestionMarkWSDLTestCase extends TestCase { + + private static boolean newGenerator = true; + private SCADomain domain; + + /** + * Tests ?wsdl returns a soap 1.1 port by default + */ + public void testSOAPDefault() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep1?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); + + String endpoint = getSOAP11Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep1", endpoint); + } + + /** + * Tests ?wsdl returns a soap 1.1 port when binding uses requires="SOAP.1_1" + */ + public void testSOAP11Endpoint() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep2?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); + + String endpoint = getSOAP11Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep2", endpoint); + } + + /** + * Tests ?wsdl returns a soap 1.2 port when binding uses requires="SOAP.1_2" + */ + public void testSOAP12Endpoint() throws Exception { + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose",false); + wsdlReader.setFeature("javax.wsdl.importDocuments",true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep3?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName( + "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), + newGenerator ? "HelloWorldService" : "HelloWorld")); + Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP12port_http"); + + String endpoint = getSOAP12Endpoint(port); + String ip = HttpUtils.getIpAddress(); + assertEquals("http://" + ip + ":8085/ep3", endpoint); + } + + protected String getSOAP11Endpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + protected String getSOAP12Endpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAP12Address) { + return ((SOAP12Address) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler new file mode 100644 index 0000000000..32b042402b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures +# handler classname;qname=;model= +org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyHandler;intent=http://tuscany.apache.org/xmlns/sca/1.0#wsAuthentication,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite new file mode 100644 index 0000000000..5cea469e3d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite @@ -0,0 +1,50 @@ + + + + + + + + + + http://localhost:8085/services/HelloWorldWebService + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite new file mode 100644 index 0000000000..b11c50b00c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd new file mode 100644 index 0000000000..f09ed09b6a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd new file mode 100644 index 0000000000..ec67b84851 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd new file mode 100644 index 0000000000..7c903c6394 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite new file mode 100644 index 0000000000..394bf05506 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite new file mode 100644 index 0000000000..c7081b9a72 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite new file mode 100644 index 0000000000..7d3e1d1327 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite new file mode 100644 index 0000000000..c2cd598508 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl new file mode 100644 index 0000000000..fe68755c47 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite new file mode 100644 index 0000000000..47ce6cc1a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite @@ -0,0 +1,50 @@ + + + + + + + + + http://localhost:8085/myService + + + + + + + + + + + + + + + + + http://localhost:8085/myService + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl new file mode 100644 index 0000000000..7bf47bc412 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite new file mode 100644 index 0000000000..dee0effd99 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl new file mode 100644 index 0000000000..c66fa51c34 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl new file mode 100644 index 0000000000..baa223f41c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite new file mode 100644 index 0000000000..8fcbdef33d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl new file mode 100644 index 0000000000..73ca02246d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite new file mode 100644 index 0000000000..c506b09bb2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl new file mode 100644 index 0000000000..5908c43e7d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl new file mode 100644 index 0000000000..1a2272d7ee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl new file mode 100644 index 0000000000..df52fff9b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite new file mode 100644 index 0000000000..beba2512da --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite new file mode 100644 index 0000000000..da5bab45e8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite new file mode 100644 index 0000000000..13e002be1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite new file mode 100644 index 0000000000..2f6fab0d07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml new file mode 100644 index 0000000000..8fa2d3b8c0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml @@ -0,0 +1,101 @@ + + + + + + + + + + UsernameToken + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ServerPWCBHandler + + + + + + + + + + UsernameToken + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ClientPWCBHandler" + + PasswordText + + + + + + + + + + Timestamp Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + + + + + Timestamp Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler" + + DirectReference + + + + + + + + + + Timestamp Signature Encrypt + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + + + + + Timestamp Signature Encrypt + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + DirectReference + SKIKeyIdentifier + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties new file mode 100644 index 0000000000..592edf183b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd +org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks new file mode 100644 index 0000000000..0b4f2399f0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml new file mode 100644 index 0000000000..65f8cb67d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml @@ -0,0 +1,32 @@ + + + + + + + Communitcation thro this binding required Authentication. + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite new file mode 100644 index 0000000000..12b2b18e55 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml new file mode 100644 index 0000000000..871e889835 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml @@ -0,0 +1,323 @@ + + + + + + + + + + UsernameToken + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + + + + + + UsernameToken + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler" + + PasswordText + + + + + + + + + + Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + + + + + + + + + + Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler + DirectReference + + + + + + + + + + UsernameToken Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + DirectReference + + + + + + + + + + Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + + + + + UsernameToken Signature + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler" + + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + PasswordText + DirectReference + + + + + + + + + + + + + + + + + TuscanyWsUser + + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler + + + + + + + + + + + + + + + + + + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties new file mode 100644 index 0000000000..cb188e6676 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd +org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks new file mode 100644 index 0000000000..0b4f2399f0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite new file mode 100644 index 0000000000..2a22a0905d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite new file mode 100644 index 0000000000..e6f999aad7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite new file mode 100644 index 0000000000..d9e889768b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml new file mode 100644 index 0000000000..bfa9b1a222 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + TuscanyWsUser + PasswordText + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.ClientPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks new file mode 100644 index 0000000000..d77c889141 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl new file mode 100644 index 0000000000..41a491361f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl new file mode 100644 index 0000000000..99a8c6d81d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl new file mode 100644 index 0000000000..80e4b62801 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite new file mode 100644 index 0000000000..008d42d03d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite new file mode 100644 index 0000000000..7fff56377b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite new file mode 100644 index 0000000000..c042ae5675 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite new file mode 100644 index 0000000000..fbd4c66c45 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite new file mode 100644 index 0000000000..033a77eea6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3