Author: nagy
Date: Wed Mar  3 19:51:46 2010
New Revision: 918666

URL: http://svn.apache.org/viewvc?rev=918666&view=rev
Log:
AXIS2-4644

Added new tests to verify MTOMFeature JAX-WS API functionality.

Contributor: Nikhil Thaker


Added:
    axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/pdf/
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/pdf/JAX-WS.pdf
   (with props)
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/wsdl/ProcessDocumentService.wsdl
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MTOMFeatureTests.java
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentDelegate.java
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentPortBindingImpl.java
    
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentService.java
Modified:
    axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml

Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml?rev=918666&r1=918665&r2=918666&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml Wed Mar  3 
19:51:46 2010
@@ -369,6 +369,12 @@
                                     <classpath 
location="${compiled.classes.dir}"/>
                                     <arg line="-d ${schema.generated.src.dir} 
-quiet -wsdl ${wsdl.source.dir}/swamtomservice.wsdl"/>
                                 </java>
+                                <echo>Generating java from 
ProcessDocumentService.wsdl</echo>
+                                <java classname="com.sun.tools.xjc.Driver" 
fork="true">
+                                    <classpath 
refid="maven.runtime.classpath"/>
+                                    <classpath 
location="${compiled.classes.dir}"/>
+                                    <arg line="-d ${schema.generated.src.dir} 
-quiet -wsdl ${wsdl.source.dir}/ProcessDocumentService.wsdl"/>
+                                </java>
                             </tasks>
                         </configuration>
                         <goals>
@@ -1280,6 +1286,22 @@
                                                                
                                                                <delete 
dir="target/test-classes/servicejars/HandlerHeaderService"/>
                                                                
+                                                               <copy 
toDir="target/test-classes/servicejars/ProcessDocumentService/">
+                                                                       
<fileset dir="target/test-classes">
+                                                                          
<include name="org/apache/axis2/jaxws/sample/mtomfeature/**"/>
+                                                                          
<exclude name="org/apache/axis2/jaxws/sample/mtomfeature/META-INF/services.xml" 
/>
+                                                                       
</fileset>
+                                                                       
<fileset dir="test/org/apache/axis2/jaxws/sample/mtomfeature/">
+                                                                          
<include name="META-INF/**"/>
+                                                                           
<exclude name = "services.xml" />
+                                                                       
</fileset>
+                                                               </copy>
+                                                               <zip 
destfile="target/test-classes/servicejars/ProcessDocumentService.jar"
+                                                                       
basedir="${pom.basedir}/target/test-classes/servicejars/ProcessDocumentService"
+                                                               />
+                                                               
+                                                               <delete 
dir="target/test-classes/servicejars/ProcessDocumentService"/>
+                                                               
                                 <copy 
toDir="target/test-classes/servicejars/JAXBStringService/">
                                     <fileset dir="target/test-classes">
                                         <include 
name="org/apache/axis2/jaxws/jaxb/string/**"/>
@@ -1369,6 +1391,7 @@
                         <include>**/BasicAuthSecurityTests.java</include>
                         <include>**/AddressBookTests.java</include>
                         <include>**/MtomSampleTests.java</include>
+                        <include>**/MTOMFeatureTests.java</include>
                         <include>**/JAXBProviderTests.java</include>
                         <include>**/BareTests.java</include>
                         <include>**/AddNumbersHandlerTests.java</include>
@@ -1419,6 +1442,7 @@
                         <include>**/SoapMessageProviderTests.java</include>
                         <include>**/StringProviderTests.java</include>
                         <include>**/OMProviderTests.java</include>
+                        
                        
                     </includes>
                     <systemProperties>

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/pdf/JAX-WS.pdf
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/pdf/JAX-WS.pdf?rev=918666&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/pdf/JAX-WS.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/wsdl/ProcessDocumentService.wsdl
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/wsdl/ProcessDocumentService.wsdl?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/wsdl/ProcessDocumentService.wsdl
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test-resources/wsdl/ProcessDocumentService.wsdl
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/";
+       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:tns="http://mtomfeature.sample.jaxws.axis2.apache.org/";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
name="ProcessDocumentService"
+       targetNamespace="http://mtomfeature.sample.jaxws.axis2.apache.org/";>
+       <types>
+               <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+                       xmlns:xmime="http://www.w3.org/2005/05/xmlmime"; 
xmlns:tns="http://mtomfeature.sample.jaxws.axis2.apache.org/";
+                       
targetNamespace="http://mtomfeature.sample.jaxws.axis2.apache.org/"; 
version="1.0">
+
+                       <xs:element name="sendPDFFile" type="tns:sendPDFFile" />
+
+                       <xs:element name="sendPDFFileResponse" 
type="tns:sendPDFFileResponse" />
+
+                       <xs:complexType name="sendPDFFile">
+                               <xs:sequence>
+                                       <xs:element minOccurs="0" name="arg0" 
type="xs:base64Binary"
+                                               
xmime:expectedContentTypes="*/*" />
+                               </xs:sequence>
+                       </xs:complexType>
+
+                       <xs:complexType name="sendPDFFileResponse">
+                               <xs:sequence>
+                                       <xs:element minOccurs="0" name="return" 
type="xs:base64Binary"
+                                               
xmime:expectedContentTypes="*/*" />
+                               </xs:sequence>
+                       </xs:complexType>
+               </xs:schema>
+       </types>
+
+       <message name="sendPDFFile">
+               <part element="tns:sendPDFFile" name="parameters" />
+       </message>
+       <message name="sendPDFFileResponse">
+               <part element="tns:sendPDFFileResponse" name="parameters" />
+       </message>
+       <portType name="ProcessDocumentDelegate">
+               <operation name="sendPDFFile">
+                       <input message="tns:sendPDFFile" />
+                       <output message="tns:sendPDFFileResponse" />
+               </operation>
+       </portType>
+       <binding name="ProcessDocumentPortBinding" 
type="tns:ProcessDocumentDelegate">
+               <soap:binding style="document"
+                       transport="http://schemas.xmlsoap.org/soap/http"; />
+               <operation name="sendPDFFile">
+                       <soap:operation soapAction="" />
+                       <input>
+                               <soap:body use="literal" />
+                       </input>
+                       <output>
+                               <soap:body use="literal" />
+                       </output>
+               </operation>
+       </binding>
+       <service name="ProcessDocumentService">
+               <port binding="tns:ProcessDocumentPortBinding" 
name="ProcessDocumentPort">
+                       <soap:address
+                               
location="http://localhost:9080/MTOM/ProcessDocumentService"; />
+               </port>
+       </service>
+</definitions>

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MTOMFeatureTests.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MTOMFeatureTests.java?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MTOMFeatureTests.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MTOMFeatureTests.java
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.sample;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.util.List;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.sample.mtomfeature.ObjectFactory;
+import org.apache.axis2.jaxws.sample.mtomfeature.ProcessDocumentDelegate;
+import org.apache.axis2.jaxws.sample.mtomfeature.ProcessDocumentService;
+import org.apache.axis2.jaxws.sample.mtomfeature.SendPDFFile;
+import org.apache.axis2.jaxws.sample.mtomfeature.SendPDFFileResponse;
+import org.apache.axis2.jaxws.spi.Binding;
+
+
+public class MTOMFeatureTests extends AbstractTestCase {
+    private static final String axisEndpoint = 
"http://localhost:6060/axis2/services/ProcessDocumentService.ProcessDocumentPortBindingImplPort";;
+    private static final QName serviceName = new 
QName("http://mtomfeature.sample.jaxws.axis2.apache.org/";, 
"ProcessDocumentService");
+    private static final QName portName = new 
QName("http://mtomfeature.sample.jaxws.axis2.apache.org/";, 
"ProcessDocumentPort");
+    String resourceDir = System.getProperty("basedir",".")+ 
File.separator+"test-resources"+File.separator+"pdf";
+    public static Test suite() {
+        return getTestSetup(new TestSuite(MTOMFeatureTests.class));
+    }
+    public void testMTOMFeatureProxy(){
+        try{
+            
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+            MTOMFeature mtomFeature = new MTOMFeature(true, 1);
+            ProcessDocumentService service = new ProcessDocumentService();
+            ProcessDocumentDelegate proxy = 
service.getProcessDocumentPort(mtomFeature);
+            
+            BindingProvider bp = (BindingProvider)proxy;
+            
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
axisEndpoint);
+            Binding b =(Binding) bp.getBinding();
+
+            WebServiceFeature wsFeature = b.getFeature(MTOMFeature.ID);
+            assertNotNull(wsFeature);
+            assertTrue("Expecting WSFeature to be enabled, but found 
disabled.", wsFeature.isEnabled());
+            assertTrue("Expecting WSFeature to be instance of MTOMFeature, but 
found WSFeature is not a MTOMFeature",wsFeature instanceof MTOMFeature);
+            assertTrue("Expecting Threshold value to be 1, but found"+ 
((MTOMFeature)wsFeature).getThreshold(),((MTOMFeature)wsFeature).getThreshold()==1);
+           //so webservices feature is correctly set at this point.
+            //lets make sure attachments payloads are flowing correctly.
+          
+            //Fetch attachment file
+            File pdfFile = new File(resourceDir+File.separator+"JAX-WS.pdf");
+            FileDataSource fds = new FileDataSource(pdfFile);
+            DataHandler pdfHandler = new DataHandler(fds);
+            
+            //Invoke Operation
+            DataHandler response = proxy.sendPDFFile(pdfHandler);
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            assertNotNull(response);
+            //Lets ensure the file content came back as expected.
+            //Validate that the file data is available
+            BufferedInputStream fileIn = new 
BufferedInputStream(response.getInputStream());
+            assertNotNull(fileIn);
+            assertTrue(fileIn.available()>0);
+            
+        }catch(Exception e){
+            fail(e.getMessage());
+        }
+    }
+    
+    public void testMTOMFeatureDispatch(){
+        try{      
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+            MTOMFeature mtomFeature = new MTOMFeature(true, 1);
+            //Create the necessary JAXBContext
+            JAXBContext jbc = 
JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtomfeature");
+            // Create the JAX-WS client needed to send the request
+            Service service = Service.create(serviceName);
+            service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, 
axisEndpoint);
+            Dispatch<Object> dispatch = service.createDispatch(portName, jbc, 
Mode.PAYLOAD, mtomFeature);
+            ObjectFactory of = new ObjectFactory();
+            SendPDFFile pdf = of.createSendPDFFile();
+            //Fetch attachment file
+            File pdfFile = new File(resourceDir+File.separator+"JAX-WS.pdf");
+            FileDataSource fds = new FileDataSource(pdfFile);
+            DataHandler pdfHandler = new DataHandler(fds);
+            pdf.setArg0(pdfHandler);
+            BindingProvider bp = (BindingProvider)dispatch;
+            Binding b =(Binding) bp.getBinding();
+            
+            WebServiceFeature wsFeature = b.getFeature(MTOMFeature.ID);
+            assertNotNull(wsFeature);
+            assertTrue("Expecting WSFeature to be enabled, but found 
disabled.", wsFeature.isEnabled());
+            assertTrue("Expecting WSFeature to be instance of MTOMFeature, but 
found WSFeature is not a MTOMFeature",wsFeature instanceof MTOMFeature);
+            assertTrue("Expecting Threshold value to be 1, but found"+ 
((MTOMFeature)wsFeature).getThreshold(),((MTOMFeature)wsFeature).getThreshold()==1);
+            
+            JAXBElement<SendPDFFileResponse> response = 
(JAXBElement<SendPDFFileResponse>)dispatch.invoke(of.createSendPDFFile(pdf));
+            assertNotNull(response);
+            SendPDFFileResponse responsePdf = response.getValue();
+            assertNotNull(responsePdf);
+            DataHandler dh = responsePdf.getReturn();
+            assertNotNull(dh);
+            //Lets ensure the file content came back as expected.
+            //Validate that the file data is available
+            BufferedInputStream fileIn = new 
BufferedInputStream(dh.getInputStream());
+            assertNotNull(fileIn);
+            assertTrue(fileIn.available()>0);
+        }catch(Exception e){
+            fail(e.getMessage());
+        }
+    }
+}

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/";
+       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:tns="http://mtomfeature.sample.jaxws.axis2.apache.org/";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
name="ProcessDocumentService"
+       targetNamespace="http://mtomfeature.sample.jaxws.axis2.apache.org/";>
+       <types>
+               <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+                       xmlns:xmime="http://www.w3.org/2005/05/xmlmime"; 
xmlns:tns="http://mtomfeature.sample.jaxws.axis2.apache.org/";
+                       
targetNamespace="http://mtomfeature.sample.jaxws.axis2.apache.org/"; 
version="1.0">
+
+                       <xs:element name="sendPDFFile" type="tns:sendPDFFile" />
+
+                       <xs:element name="sendPDFFileResponse" 
type="tns:sendPDFFileResponse" />
+
+                       <xs:complexType name="sendPDFFile">
+                               <xs:sequence>
+                                       <xs:element minOccurs="0" name="arg0" 
type="xs:base64Binary"
+                                               
xmime:expectedContentTypes="*/*" />
+                               </xs:sequence>
+                       </xs:complexType>
+
+                       <xs:complexType name="sendPDFFileResponse">
+                               <xs:sequence>
+                                       <xs:element minOccurs="0" name="return" 
type="xs:base64Binary"
+                                               
xmime:expectedContentTypes="*/*" />
+                               </xs:sequence>
+                       </xs:complexType>
+               </xs:schema>
+       </types>
+
+       <message name="sendPDFFile">
+               <part element="tns:sendPDFFile" name="parameters" />
+       </message>
+       <message name="sendPDFFileResponse">
+               <part element="tns:sendPDFFileResponse" name="parameters" />
+       </message>
+       <portType name="ProcessDocumentDelegate">
+               <operation name="sendPDFFile">
+                       <input message="tns:sendPDFFile" />
+                       <output message="tns:sendPDFFileResponse" />
+               </operation>
+       </portType>
+       <binding name="ProcessDocumentPortBinding" 
type="tns:ProcessDocumentDelegate">
+               <soap:binding style="document"
+                       transport="http://schemas.xmlsoap.org/soap/http"; />
+               <operation name="sendPDFFile">
+                       <soap:operation soapAction="" />
+                       <input>
+                               <soap:body use="literal" />
+                       </input>
+                       <output>
+                               <soap:body use="literal" />
+                       </output>
+               </operation>
+       </binding>
+       <service name="ProcessDocumentService">
+               <port binding="tns:ProcessDocumentPortBinding" 
name="ProcessDocumentPort">
+                       <soap:address
+                               
location="http://localhost:9080/MTOM/ProcessDocumentService"; />
+               </port>
+       </service>
+</definitions>

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentDelegate.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentDelegate.java?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentDelegate.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentDelegate.java
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,40 @@
+//
+// Generated By:JAX-WS RI IBM 2.1.1 in JDK 6 (JAXB RI IBM JAXB 2.1.3 in JDK 
1.6)
+//
+
+
+package org.apache.axis2.jaxws.sample.mtomfeature;
+
+import javax.activation.DataHandler;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+import org.apache.axis2.jaxws.sample.mtomfeature.ObjectFactory;
+
+...@webservice(name = "ProcessDocumentDelegate", targetNamespace = 
"http://mtomfeature.sample.jaxws.axis2.apache.org/";)
+...@xmlseealso({
+    ObjectFactory.class
+})
+public interface ProcessDocumentDelegate {
+
+
+    /**
+     * 
+     * @param arg0
+     * @return
+     *     returns javax.activation.DataHandler
+     */
+    @WebMethod
+    @WebResult(targetNamespace = "")
+    @RequestWrapper(localName = "sendPDFFile", targetNamespace = 
"http://mtomfeature.sample.jaxws.axis2.apache.org/";, className = 
"org.apache.axis2.jaxws.sample.mtomfeature.SendPDFFile")
+    @ResponseWrapper(localName = "sendPDFFileResponse", targetNamespace = 
"http://mtomfeature.sample.jaxws.axis2.apache.org/";, className = 
"org.apache.axis2.jaxws.sample.mtomfeature.SendPDFFileResponse")
+    public DataHandler sendPDFFile(
+        @WebParam(name = "arg0", targetNamespace = "")
+        DataHandler arg0);
+
+}

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentPortBindingImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentPortBindingImpl.java?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentPortBindingImpl.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentPortBindingImpl.java
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample.mtomfeature;
+
+import java.io.BufferedInputStream;
+
+import javax.activation.DataHandler;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+
+import org.apache.axis2.jaxws.TestLogger;
+...@javax.jws.webservice (serviceName="ProcessDocumentService", 
endpointInterface="org.apache.axis2.jaxws.sample.mtomfeature.ProcessDocumentDelegate")
+...@mtom(threshold=0)
+public class ProcessDocumentPortBindingImpl implements ProcessDocumentDelegate 
{
+
+    public DataHandler sendPDFFile(DataHandler dh) {
+        try {
+            TestLogger.logger.debug("--------------------------------------");
+            TestLogger.logger.debug("sendPDFFile");
+           //Check if we got the attachment.
+           if (dh == null) {
+               TestLogger.logger.debug("Null DataHandler received.");
+               throw new WebServiceException("Null input received.");
+           } 
+           //Validate that the file data is available
+           BufferedInputStream fileIn = new 
BufferedInputStream(dh.getInputStream());
+           if(fileIn.available() <= 0) {
+               TestLogger.logger.debug("No File Content in the MTOM 
attachment");
+               throw new WebServiceException("PDF File is empty");
+           }
+           //All went well and we got the pdf file content.
+            TestLogger.logger.debug("sendPDFFile: Request received.");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        //return the file data handler.
+        return dh;
+    }
+}

Added: 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentService.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentService.java?rev=918666&view=auto
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentService.java
 (added)
+++ 
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtomfeature/ProcessDocumentService.java
 Wed Mar  3 19:51:46 2010
@@ -0,0 +1,71 @@
+//
+// Generated By:JAX-WS RI IBM 2.1.1 in JDK 6 (JAXB RI IBM JAXB 2.1.3 in JDK 
1.6)
+//
+
+
+package org.apache.axis2.jaxws.sample.mtomfeature;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceFeature;
+
+...@webserviceclient(name = "ProcessDocumentService", targetNamespace = 
"http://mtomfeature.sample.jaxws.axis2.apache.org/";, wsdlLocation = 
"file:/C:/work/mtomfeature/ProcessDocumentService.wsdl")
+public class ProcessDocumentService
+extends Service
+{
+
+    private final static URL PROCESSDOCUMENTSERVICE_WSDL_LOCATION;
+    private static String 
wsdlLocation="/test/org/apache/axis2/jaxws/sample/mtomfeature/META-INF/ProcessDocumentService.wsdl";
+    static {
+        URL url = null;
+        try {
+            try{
+                String baseDir = new 
File(System.getProperty("basedir",".")).getCanonicalPath();
+                wsdlLocation = new File(baseDir + 
wsdlLocation).getAbsolutePath();
+            }catch(Exception e){
+                e.printStackTrace();
+            }
+            File file = new File(wsdlLocation);
+            url = file.toURI().toURL();
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        }
+        PROCESSDOCUMENTSERVICE_WSDL_LOCATION = url;
+    }
+
+    public ProcessDocumentService(URL wsdlLocation, QName serviceName) {
+        super(wsdlLocation, serviceName);
+    }
+
+    public ProcessDocumentService() {
+        super(PROCESSDOCUMENTSERVICE_WSDL_LOCATION, new 
QName("http://mtomfeature.sample.jaxws.axis2.apache.org/";, 
"ProcessDocumentService"));
+    }
+
+    /**
+     * 
+     * @return
+     *     returns ProcessDocumentDelegate
+     */
+    @WebEndpoint(name = "ProcessDocumentPort")
+    public ProcessDocumentDelegate getProcessDocumentPort() {
+        return (ProcessDocumentDelegate)super.getPort(new 
QName("http://mtomfeature.sample.jaxws.axis2.apache.org/";, 
"ProcessDocumentPort"), ProcessDocumentDelegate.class);
+    }
+
+    /**
+     * 
+     * @param features
+     *     A list of {...@link javax.xml.ws.WebServiceFeature} to configure on 
the proxy.  Supported features not in the <code>features</code> parameter will 
have their default values.
+     * @return
+     *     returns ProcessDocumentDelegate
+     */
+    @WebEndpoint(name = "ProcessDocumentPort")
+    public ProcessDocumentDelegate getProcessDocumentPort(WebServiceFeature... 
features) {
+        return (ProcessDocumentDelegate)super.getPort(new 
QName("http://mtomfeature.sample.jaxws.axis2.apache.org/";, 
"ProcessDocumentPort"), ProcessDocumentDelegate.class, features);
+    }
+
+}


Reply via email to