From 9bf05eac265d9225e47dcb6fac67567869f6d1fa Mon Sep 17 00:00:00 2001 From: ramkumar Date: Thu, 6 Nov 2008 07:12:18 +0000 Subject: Fixes for TUSCANY-2611 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711780 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/ws/axis2/Axis2ServiceProvider.java | 11 ++- .../tuscany/sca/binding/ws/axis2/definitions.xml | 2 +- .../ws/axis2/itests/mtom/FileTransferClient.java | 36 ++++++++++ .../itests/mtom/FileTransferMTOMTestCase.java | 49 +++++++++++++ .../ws/axis2/itests/mtom/FileTransferService.java | 32 +++++++++ .../axis2/itests/mtom/FileTransferServiceImpl.java | 51 +++++++++++++ .../binding/ws/axis2/itests/mtom/filetransfer.wsdl | 84 ++++++++++++++++++++++ .../itests/mtom/filetransferservice.composite | 42 +++++++++++ 8 files changed, 305 insertions(+), 2 deletions(-) create mode 100644 java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java create mode 100644 java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java create mode 100644 java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java create mode 100644 java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java create mode 100644 java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl create mode 100644 java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite (limited to 'java') diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java index dd6678fd7b..84f3e98ca4 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java +++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.binding.ws.axis2; +import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.isIntentRequired; + import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; @@ -50,6 +52,7 @@ 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; @@ -195,7 +198,13 @@ public class Axis2ServiceProvider { } 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. diff --git a/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml index b11059df15..6bff613a7c 100644 --- a/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml +++ b/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml @@ -25,7 +25,7 @@ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> - + diff --git a/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java new file mode 100644 index 0000000000..82f6ff4c5d --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.activation.DataHandler; +import org.osoa.sca.annotations.Reference; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate the FileTransfer service and invoke it. + */ +public class FileTransferClient implements FileTransferService { + + @Reference + public FileTransferService fileTransferWS; + + public String uploadFile(DataHandler attachment) throws Exception { + return fileTransferWS.uploadFile(attachment); + } +} diff --git a/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java new file mode 100644 index 0000000000..e592134037 --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.activation.DataHandler; +import javax.activation.FileDataSource; +import junit.framework.TestCase; +import org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferService; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class FileTransferMTOMTestCase extends TestCase { + + private SCADomain domain; + + public void testFileTransfer() throws Exception { + // For testing purpose lets try uploading FileTransferClient.java file. + DataHandler dataHandler = new DataHandler(new FileDataSource("FileTransferClient.java")); + FileTransferService filetransfer = domain.getService(FileTransferService.class, "FileTransferServiceComponent"); + assertEquals("File uploaded Sucessfully", filetransfer.uploadFile(dataHandler)); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java new file mode 100644 index 0000000000..ce79b47b86 --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import org.osoa.sca.annotations.Remotable; +import javax.activation.DataHandler; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface FileTransferService { + + public String uploadFile(DataHandler attachment) throws Exception; +} + diff --git a/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java new file mode 100644 index 0000000000..8d4a020560 --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; + +import org.osoa.sca.annotations.Service; +import javax.activation.DataHandler; +import java.io.File; +import java.io.FileOutputStream; + +/** + * This class implements the HelloWorld service. + */ +@Service(FileTransferService.class) +public class FileTransferServiceImpl implements FileTransferService { + + public String uploadFile(DataHandler attachment) throws Exception { + + //OMText binaryNode = (OMText) (attachment.getFirstElement()).getFirstOMChild(); + //DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler(); + + // Use this code to save the file we have received. + /*DataHandler dataHandler = attachment; + + File file = new File("transferedfile.java"); + FileOutputStream fileOutputStream = new FileOutputStream(file); + dataHandler.writeTo(fileOutputStream); + fileOutputStream.flush(); + fileOutputStream.close();*/ + + System.out.println(attachment.getContentType()); + + return "File uploaded Sucessfully"; + } + +} diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl new file mode 100644 index 0000000000..1c67a1b26a --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite new file mode 100644 index 0000000000..03a16d9433 --- /dev/null +++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3