cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r491479 - in /incubator/cxf/trunk: rt/bindings/http/ rt/bindings/http/src/main/java/org/apache/cxf/binding/http/ rt/bindings/http/src/test/java/org/apache/cxf/binding/http/ rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/ rt...
Date Sun, 31 Dec 2006 20:35:30 GMT
Author: dandiep
Date: Sun Dec 31 12:35:28 2006
New Revision: 491479

URL: http://svn.apache.org/viewvc?view=rev&rev=491479
Log:
o Add support for MTOM over the HTTP binding (user requested feature). Still
  needs a proper client. 
o Start on Soap w/ Attachments support. 
  - Reenabled MIME processing inside the tools. Not sure why this was
    disabled to begin with.
  - Add support for INOUT MIME parameters in the tooling
  - Start adding SwA support back into the attachment serializer/deserializer.
  - Added a test which tests parsing from an Axis 1.x message. 
  - Add a Client/Server SwA test. It doesn't actually work yet though...
o Renamed MultipartMessageInterceptor to AttachmentInInterceptor to match the
  AttachmentOutInterceptor.
o TODO items for SwA:
  - Find a way to get Axis 1.x to work with CXF. Axis 1.x doesn't support the 
    WS-I Attachments Profile, however that is the only thing JAXB supports. I
    can't seem to get the two talk yet, but I have an email out to the axis
    dev list about it.
  - Make sure that serialization works correctly
  - Get Client/Server test passing

Added:
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java   (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java   (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java   (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson   (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/
    incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd   (with props)
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java
      - copied, changed from r491080, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MultipartMessageInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java   (with props)
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl   (with props)
    incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl   (with props)
Removed:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MultipartMessageInterceptor.java
Modified:
    incubator/cxf/trunk/rt/bindings/http/pom.xml
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/AbstractRestTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBinding.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
    incubator/cxf/trunk/testutils/pom.xml
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jaxws/JAXWSBinding.java
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/MIMEProcessor.java
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaMIMETest.java
    incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/binary_attachment.wsdl

Modified: incubator/cxf/trunk/rt/bindings/http/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/pom.xml?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/pom.xml (original)
+++ incubator/cxf/trunk/rt/bindings/http/pom.xml Sun Dec 31 12:35:28 2006
@@ -100,5 +100,31 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.cxf</groupId>
+                <artifactId>cxf-common-xsd</artifactId>
+                <version>${project.version}</version>
+                <executions>
+                    <execution>
+                        <id>generate-test-sources</id>
+                        <phase>generate-test-sources</phase>
+                        <configuration>
+                            <sourceRoot>${basedir}/target/generated/src/test/java</sourceRoot>
+                            <xsdOptions>
+                                <xsdOption>
+                                    <xsd>${basedir}/src/test/resources/schemas/person.xsd</xsd>
+                                </xsdOption>
+                            </xsdOptions>
+                        </configuration>
+                        <goals>
+                            <goal>xsdtojava</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java Sun Dec 31 12:35:28 2006
@@ -31,6 +31,8 @@
 import org.apache.cxf.binding.xml.interceptor.XMLFaultInInterceptor;
 import org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor;
 import org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
 import org.apache.cxf.interceptor.WrappedOutInterceptor;
 import org.apache.cxf.service.model.BindingInfo;
@@ -67,9 +69,11 @@
     public Binding createBinding(BindingInfo bi) {
         XMLBinding binding = new XMLBinding();
         
+        binding.getInInterceptors().add(new AttachmentInInterceptor());
         binding.getInInterceptors().add(new DispatchInterceptor());
         binding.getInInterceptors().add(new URIParameterInterceptor());
 
+        binding.getOutInterceptors().add(new AttachmentOutInterceptor());
         binding.getOutInterceptors().add(new StaxOutInterceptor());
         binding.getOutInterceptors().add(new ContentTypeOutInterceptor());
         binding.getOutInterceptors().add(new WrappedOutInterceptor());

Modified: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/AbstractRestTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/AbstractRestTest.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/AbstractRestTest.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/AbstractRestTest.java Sun Dec 31 12:35:28 2006
@@ -18,11 +18,13 @@
  */
 package org.apache.cxf.binding.http;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
+import java.net.ProtocolException;
 import java.net.URL;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -41,7 +43,7 @@
 
 public abstract class AbstractRestTest extends AbstractCXFTest {
     boolean debug;
-    
+
     protected Bus createBus() throws BusException {
         return new SpringBusFactory().createBus();
     }
@@ -50,13 +52,12 @@
         ParserConfigurationException {
         return get(urlStr, null);
     }
-    
-    protected Document get(String urlStr, Integer resCode) 
-        throws MalformedURLException, IOException, SAXException,
-        ParserConfigurationException {
+
+    protected Document get(String urlStr, Integer resCode) throws MalformedURLException, IOException,
+        SAXException, ParserConfigurationException {
         URL url = new URL(urlStr);
         HttpURLConnection c = (HttpURLConnection)url.openConnection();
-    
+
         if (resCode != null) {
             assertEquals(resCode.intValue(), c.getResponseCode());
         }
@@ -81,24 +82,15 @@
 
     protected Document doMethod(String urlStr, String message, String method) throws MalformedURLException,
         IOException, SAXException, ParserConfigurationException {
+        return doMethod(urlStr, message, method, "application/xml");
+    }
 
-        URL url = new URL(urlStr);
-        HttpURLConnection c = (HttpURLConnection)url.openConnection();
-        c.setRequestMethod(method);
-        c.setDoOutput(true);
-        c.setRequestProperty("Content-Type", "application/xml");
-
-        OutputStream out = c.getOutputStream();
-        InputStream msgIs = getResourceAsStream(message);
-        assertNotNull(msgIs);
+    protected Document doMethod(String urlStr, String message, String method, String ct)
+        throws MalformedURLException, IOException, SAXException, ParserConfigurationException {
 
-        IOUtils.copy(msgIs, out);
-        out.close();
-        msgIs.close();
-        
-        InputStream is = c.getInputStream();
+        InputStream is = invoke(urlStr, message, method, ct);
         Document res = DOMUtils.readXml(is);
-        
+
         if (debug) {
             try {
                 DOMUtils.writeXml(res, System.out);
@@ -107,5 +99,43 @@
             }
         }
         return res;
+    }
+
+    protected byte[] doMethodBytes(String urlStr, String message, String method, String ct)
+        throws MalformedURLException, IOException, SAXException, ParserConfigurationException {
+
+        InputStream is = invoke(urlStr, message, method, ct);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        IOUtils.copy(is, out);
+        out.close();
+        is.close();
+
+        return out.toByteArray();
+    }
+
+    private InputStream invoke(String urlStr, String message, String method, String ct)
+        throws MalformedURLException, IOException, ProtocolException {
+        URL url = new URL(urlStr);
+        HttpURLConnection c = (HttpURLConnection)url.openConnection();
+        c.setRequestMethod(method);
+
+        if (ct != null) {
+            c.setRequestProperty("Content-Type", ct);
+        }
+
+        if (message != null) {
+            c.setDoOutput(true);
+            OutputStream out = c.getOutputStream();
+            InputStream msgIs = getResourceAsStream(message);
+            assertNotNull(msgIs);
+
+            IOUtils.copy(msgIs, out);
+            out.close();
+            msgIs.close();
+        }
+
+        InputStream is = c.getInputStream();
+        return is;
     }
 }

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java (added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java Sun Dec 31 12:35:28 2006
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.binding.http.mtom;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.mail.util.ByteArrayDataSource;
+
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.http.AbstractRestTest;
+import org.apache.cxf.binding.http.HttpBindingFactory;
+import org.apache.cxf.binding.http.HttpBindingInfoFactoryBean;
+import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.person.Person;
+import org.apache.cxf.service.invoker.BeanInvoker;
+
+public class MtomTest extends AbstractRestTest {
+
+    public void testService() throws Exception {
+        BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
+        bfm.registerBindingFactory(HttpBindingFactory.HTTP_BINDING_ID, new HttpBindingFactory());
+
+        PeopleServiceImpl impl = new PeopleServiceImpl();
+
+        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+        sf.setBus(getBus());
+        sf.setServiceBean(impl);
+        sf.getServiceFactory().setInvoker(new BeanInvoker(impl));
+        sf.getServiceFactory().setWrapped(true);
+        sf.setBindingFactory(new HttpBindingInfoFactoryBean());
+        sf.setAddress("http://localhost:9001/");
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put("mtom-enabled", Boolean.TRUE);
+        sf.setProperties(props);
+
+        ServerImpl svr = (ServerImpl)sf.create();
+
+        // TEST POST/GETs
+
+        Person p = new Person();
+        p.setName("Dan");
+        DataHandler handler = new DataHandler(new ByteArrayDataSource("foo".getBytes(),
+                                                                      "application/octet-stream"));
+        p.setPhoto(handler);
+        impl.addPerson(p);
+
+        byte[] res = doMethodBytes("http://localhost:9002/people", null, "GET", null);
+        assertNotNull(res);
+
+        // TODO: Test response
+        // IOUtils.copy(new ByteArrayInputStream(res), System.out);
+
+        String ct = "multipart/related; type=\"application/xop+xml\"; " + "start=\"<addPerson.xml>\"; "
+                    + "start-info=\"text/xml; charset=utf-8\"; "
+                    + "boundary=\"----=_Part_4_701508.1145579811786\"";
+
+        res = doMethodBytes("http://localhost:9002/people", "addPerson", "POST", ct);
+        assertNotNull(res);
+
+        // TODO: Test response
+        // IOUtils.copy(new ByteArrayInputStream(res), System.out);
+
+        assertEquals(2, impl.getPeople().getPerson().size());
+
+        svr.stop();
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java (added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java Sun Dec 31 12:35:28 2006
@@ -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.cxf.binding.http.mtom;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.person.People;
+import org.apache.cxf.person.Person;
+
+@WebService
+public interface PeopleService {
+    People getPeople();
+
+    void addPerson(Person p);
+
+    Person getPerson(String name);
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java (added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java Sun Dec 31 12:35:28 2006
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.cxf.binding.http.mtom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.person.People;
+import org.apache.cxf.person.Person;
+
+@WebService(endpointInterface = "org.apache.cxf.binding.http.mtom.PeopleService")
+public class PeopleServiceImpl implements PeopleService {
+    List<Person> people = new ArrayList<Person>();
+
+    public PeopleServiceImpl() {
+
+    }
+
+    public void addPerson(Person p) {
+        people.add(p);
+    }
+
+    public People getPeople() {
+        People p = new People();
+        p.getPerson().addAll(people);
+        return p;
+    }
+
+    public Person getPerson(String name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/PeopleServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson (added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson Sun Dec 31 12:35:28 2006
@@ -0,0 +1,25 @@
+
+------=_Part_4_701508.1145579811786
+Content-Type: text/xml
+Content-Transfer-Encoding: binary
+Content-ID: <addPerson.xml>
+
+<addPerson xmlns="http://cxf.apache.org/person/"
+  xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime">
+  <Person>
+    <Name>Dan Diephouse</Name>
+    <Photo xmlmime:contentType="application/octet-stream">
+      <xop:Include 
+        xmlns:xop="http://www.w3.org/2004/08/xop/include" 
+        href="cid:xfire_logo.jpg"/>
+    </Photo>
+  </Person>
+</addPerson>
+
+------=_Part_4_701508.1145579811786
+Content-Type: image/jpeg
+Content-Transfer-Encoding: binary
+Content-ID: <xfire_logo.jpg>
+
+foobar
+------=_Part_4_701508.1145579811786--

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/addPerson
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd (added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd Sun Dec 31 12:35:28 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns:tns="http://cxf.apache.org/person/" 
+  xmlns="http://www.w3.org/2001/XMLSchema"
+  xmlns:xmime="http://www.w3.org/2005/05/xmlmime" 
+  targetNamespace="http://cxf.apache.org/person/"
+  elementFormDefault="qualified">
+  <element name="Person">
+    <complexType>
+      <sequence>
+        <element name="Name" type="string" />
+        <element name="Photo" type="base64Binary"
+          xmime:expectedContentTypes="application/octet-stream" />
+      </sequence>
+    </complexType>
+  </element>
+  <element name="People">
+    <complexType>
+      <sequence>
+        <element ref="tns:Person" maxOccurs="unbounded" />
+      </sequence>
+    </complexType>
+  </element>
+</schema>

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/resources/schemas/person.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Sun Dec 31 12:35:28 2006
@@ -55,10 +55,10 @@
 import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.BareInInterceptor;
 import org.apache.cxf.interceptor.BareOutInterceptor;
-import org.apache.cxf.interceptor.MultipartMessageInterceptor;
 import org.apache.cxf.interceptor.StaxInInterceptor;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
 import org.apache.cxf.interceptor.URIMappingInterceptor;
@@ -144,7 +144,7 @@
             throw new RuntimeException("Can not initialize SoapBinding, BindingInfo is not SoapBindingInfo");
         }
 
-        sb.getInInterceptors().add(new MultipartMessageInterceptor());
+        sb.getInInterceptors().add(new AttachmentInInterceptor());
         sb.getInInterceptors().add(new ReadHeadersInterceptor());
         sb.getInInterceptors().add(new MustUnderstandInterceptor());
         sb.getInInterceptors().add(new StaxInInterceptor());        

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBinding.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBinding.java (original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLBinding.java Sun Dec 31 12:35:28 2006
@@ -34,7 +34,9 @@
     }
 
     public Message createMessage(Message m) {
-        m.put(Message.CONTENT_TYPE, "text/xml");
+        if (!m.containsKey(Message.CONTENT_TYPE)) {
+            m.put(Message.CONTENT_TYPE, "text/xml");
+        }
         return new XMLMessage(m);
     }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java Sun Dec 31 12:35:28 2006
@@ -114,17 +114,18 @@
      * @throws IOException
      */
     public void writeAttachments() throws IOException {
-        for (Attachment a : message.getAttachments()) {
-            
-            writer.write("\r\n");
-            writer.write("--");
-            writer.write(bodyBoundary);
-
-            writeHeaders(a.getDataHandler().getContentType(), a.getId());
-            
-            IOUtils.copy(a.getDataHandler().getInputStream(), out);
+        if (message.getAttachments() != null) {
+            for (Attachment a : message.getAttachments()) {
+                
+                writer.write("\r\n");
+                writer.write("--");
+                writer.write(bodyBoundary);
+    
+                writeHeaders(a.getDataHandler().getContentType(), a.getId());
+                
+                IOUtils.copy(a.getDataHandler().getInputStream(), out);
+            }
         }
-        
         writer.write("\r\n");
         writer.write("--");
         writer.write(bodyBoundary);

Copied: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java (from r491080, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MultipartMessageInterceptor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java?view=diff&rev=491479&p1=incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MultipartMessageInterceptor.java&r1=491080&p2=incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MultipartMessageInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java Sun Dec 31 12:35:28 2006
@@ -27,12 +27,12 @@
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 
-public class MultipartMessageInterceptor extends AbstractPhaseInterceptor<Message> {
+public class AttachmentInInterceptor extends AbstractPhaseInterceptor<Message> {
 
     public static final String ATTACHMENT_DIRECTORY = "attachment-directory";
     public static final String ATTACHMENT_MEMORY_THRESHOLD = "attachment-memory-threshold";
     public static final int THRESHHOLD = 1024 * 100;
-    private static final Logger LOG = Logger.getLogger(MultipartMessageInterceptor.class.getName());
+    private static final Logger LOG = Logger.getLogger(AttachmentInInterceptor.class.getName());
 
     /**
      * contruct the soap message with attachments from mime input stream
@@ -40,7 +40,7 @@
      * @param messageParam
      */
     
-    public MultipartMessageInterceptor() {
+    public AttachmentInInterceptor() {
         super();
         setPhase(Phase.RECEIVE);
     }

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java Sun Dec 31 12:35:28 2006
@@ -32,7 +32,7 @@
 import org.apache.cxf.message.MessageImpl;
 
 public class AttachmentDeserializerTest extends TestCase {
-    public void testDeserializer() throws Exception {
+    public void testDeserializerMtom() throws Exception {
         InputStream is = getClass().getResourceAsStream("mimedata");
         String ct = "multipart/related; type=\"application/xop+xml\"; "
                     + "start=\"<soap.xml@xfire.codehaus.org>\"; "
@@ -77,5 +77,51 @@
 //        assertNull(invalid.getDataHandler().getInputStream());
 //        
 //        assertTrue(attIs instanceof ByteArrayInputStream);
+    }
+    
+    public void testDeserializerSwA() throws Exception {
+        InputStream is = getClass().getResourceAsStream("swadata");
+        String ct = "multipart/related; type=\"text/xml\"; "
+            + "start=\"<86048FF3556694F7DA1918466DDF8143>\";    "
+            + "boundary=\"----=_Part_0_14158819.1167275505862\"";
+        
+        MessageImpl msg = new MessageImpl();
+        msg.put(Message.CONTENT_TYPE, ct);
+        msg.setContent(InputStream.class, is);
+        
+        AttachmentDeserializer deserializer = new AttachmentDeserializer(msg);
+        deserializer.initializeAttachments();
+        
+        InputStream attBody = msg.getContent(InputStream.class);
+        assertTrue(attBody != is);
+        assertTrue(attBody instanceof DelegatingInputStream);
+        
+        Collection<Attachment> atts = msg.getAttachments();
+        assertNotNull(atts);
+        
+        Iterator<Attachment> itr = atts.iterator();
+        assertTrue(itr.hasNext());
+        
+        Attachment a = itr.next();
+        assertNotNull(a);
+        
+        InputStream attIs = a.getDataHandler().getInputStream();
+        
+        assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof MimeBodyPartInputStream);
+        assertTrue(((DelegatingInputStream) attBody).getInputStream() instanceof ByteArrayInputStream);
+        
+        // check the cached output stream
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        IOUtils.copy(attBody, out);
+        assertTrue(out.toString().startsWith("<?xml"));
+        
+        // try streaming a character off the wire
+        assertTrue(attIs.read() == 'f');
+        assertTrue(attIs.read() == 'o');
+        assertTrue(attIs.read() == 'o');
+        assertTrue(attIs.read() == 'b');
+        assertTrue(attIs.read() == 'a');
+        assertTrue(attIs.read() == 'r');
+        assertTrue(attIs.read() == -1);
     }
 }

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java Sun Dec 31 12:35:28 2006
@@ -69,6 +69,68 @@
         assertTrue(ct.indexOf("multipart/related;") == 0);
         assertTrue(ct.indexOf("start=\"<root.message@cxf.apache.org>\"") > -1);
         assertTrue(ct.indexOf("start-info=\"application/soap+xml; charset=UTF-8\"") > -1);
+        System.out.println(ct);
+        out.write("<soap:Body/>".getBytes());
+        
+        serializer.writeAttachments();
+        
+        out.flush();
+        
+        Session session = Session.getDefaultInstance(new Properties());
+        MimeMessage inMsg = new MimeMessage(session, new ByteArrayInputStream(out.toByteArray()));
+        inMsg.addHeaderLine("Content-Type: " + ct);
+        
+        MimeMultipart multipart = (MimeMultipart) inMsg.getContent();
+        
+        MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0);
+        assertEquals("application/xop+xml; charset=UTF-8; type=\"application/soap+xml; charset=UTF-8\"", 
+                     part.getHeader("Content-Type")[0]);
+        assertEquals("binary", part.getHeader("Content-Transfer-Encoding")[0]);
+        assertEquals("<root.message@cxf.apache.org>", part.getHeader("Content-ID")[0]);
+        
+        InputStream in = part.getDataHandler().getInputStream();
+        ByteArrayOutputStream bodyOut = new ByteArrayOutputStream();
+        IOUtils.copy(in, bodyOut);
+        out.close();
+        in.close();
+        
+        assertEquals("<soap:Body/>", bodyOut.toString());
+        
+        MimeBodyPart part2 = (MimeBodyPart) multipart.getBodyPart(1);
+        assertEquals("application/octet-stream", part2.getHeader("Content-Type")[0]);
+        assertEquals("binary", part2.getHeader("Content-Transfer-Encoding")[0]);
+        assertEquals("<test.xml>", part2.getHeader("Content-ID")[0]);
+        
+    }
+    
+    public void testMessageMTOM() throws Exception {
+        MessageImpl msg = new MessageImpl();
+        
+        Collection<Attachment> atts = new ArrayList<Attachment>();
+        AttachmentImpl a = new AttachmentImpl("test.xml");
+        
+        InputStream is = getClass().getResourceAsStream("my.wav");
+        ByteArrayDataSource ds = new ByteArrayDataSource(is, "application/octet-stream");
+        a.setDataHandler(new DataHandler(ds));
+        
+        atts.add(a);
+        
+        msg.setAttachments(atts);
+        
+        // Set the SOAP content type
+        msg.put(Message.CONTENT_TYPE, "application/soap+xml");
+        
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        msg.setContent(OutputStream.class, out);
+        
+        AttachmentSerializer serializer = new AttachmentSerializer(msg);
+        
+        serializer.writeProlog();
+
+        String ct = (String) msg.get(Message.CONTENT_TYPE);
+        assertTrue(ct.indexOf("multipart/related;") == 0);
+        assertTrue(ct.indexOf("start=\"<root.message@cxf.apache.org>\"") > -1);
+        assertTrue(ct.indexOf("start-info=\"application/soap+xml; charset=UTF-8\"") > -1);
         
         out.write("<soap:Body/>".getBytes());
         

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java Sun Dec 31 12:35:28 2006
@@ -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.cxf.systest.swa;
+
+import javax.activation.DataHandler;
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.swa.SwAService;
+import org.apache.cxf.swa.SwAServiceInterface;
+import org.apache.cxf.swa.types.DataStruct;
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+
+public class ClientServerSwaTest extends ClientServerTestBase {
+
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(ClientServerSwaTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", launchServer(Server.class));
+            }
+        };
+    }
+   
+    public void testSwa() throws Exception {
+        SwAService service = new SwAService();
+        
+        SwAServiceInterface port = service.getSwAServiceHttpPort();
+        ((SOAPBinding) ((BindingProvider)port).getBinding()).setMTOMEnabled(true);
+        
+        Holder<DataStruct> structHolder = new Holder<DataStruct>();
+        Holder<DataHandler> data = new Holder<DataHandler>();
+        
+        ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
+        DataHandler handler = new DataHandler(source);
+        
+        DataStruct struct = new DataStruct();
+        struct.setDataRef(handler);
+        data.value = handler;
+        
+        structHolder.value = struct;
+        // TODO: Fails currently...
+//         port.echoData(structHlder, data);
+        
+    }
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java Sun Dec 31 12:35:28 2006
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.cxf.systest.swa;
+
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.systest.common.TestServerBase;
+
+public class Server extends TestServerBase {
+
+    protected void run() {
+        Object implementor = new SwAServiceImpl();
+        String address = "http://localhost:9036/swa";
+        try {
+            Endpoint endpoint = Endpoint.publish(address, implementor);
+            ((SOAPBinding)endpoint.getBinding()).setMTOMEnabled(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    public static void main(String args[]) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java Sun Dec 31 12:35:28 2006
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.swa;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.swa.SwAServiceInterface;
+import org.apache.cxf.swa.types.DataStruct;
+
+@WebService(endpointInterface = "org.apache.cxf.swa.SwAServiceInterface", 
+            serviceName = "SwAService", 
+            targetNamespace = "http://cxf.apache.org/swa", 
+            portName = "SwAServiceHttpPort")
+public class SwAServiceImpl implements SwAServiceInterface {
+
+    public void echoData(DataStruct struct, DataHandler data) {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            InputStream is = data.getInputStream();
+            IOUtils.copy(is, bos);
+            is.close();
+            bos.close();
+
+            System.out.println("OUTPUT: " + bos.toString());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Sun Dec 31 12:35:28 2006
@@ -175,6 +175,9 @@
                                     <wsdl>${basedir}/src/main/resources/wsdl/mtom_xop.wsdl</wsdl>
                                 </wsdlOption>
                                 <wsdlOption>
+                                    <wsdl>${basedir}/src/main/resources/wsdl/swa-mime.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
                                     <wsdl>${basedir}/src/main/resources/wsdl/hello_world_xml_bare.wsdl</wsdl>
                                 </wsdlOption>
                                 <wsdlOption>

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java (original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java Sun Dec 31 12:35:28 2006
@@ -48,7 +48,7 @@
     final String className;
 
 
-    private final boolean debug = false;
+    private final boolean debug = true;
     private boolean inProcess = DEFAULT_IN_PROCESS;
     private AbstractTestServerBase inProcessServer;
     

Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl Sun Dec 31 12:35:28 2006
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+  
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions name="SwAService" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+  xmlns:tns="http://cxf.apache.org/swa" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+  xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:types="http://cxf.apache.org/swa/types"
+  xmlns:xmime="http://www.w3.org/2005/05/xmlmime" targetNamespace="http://cxf.apache.org/swa"
+  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
+
+  <wsdl:types>
+    <xsd:schema xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+      targetNamespace="http://cxf.apache.org/swa/types">
+      <xsd:import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>
+      <xsd:element name="DataStruct">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="DataRef" type="wsi:swaRef"
+        xmime:expectedContentTypes="application/octet-stream" />
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      
+    </xsd:schema>
+
+    <xsd:schema targetNamespace="http://ws-i.org/profiles/basic/1.1/xsd"
+      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+      <xsd:simpleType name="swaRef">
+        <xsd:restriction base="xsd:anyURI" />
+      </xsd:simpleType>
+    </xsd:schema>
+  </wsdl:types>
+
+  <wsdl:message name="echoDataRequest">
+    <wsdl:part name="text" element="types:DataStruct" />
+    <wsdl:part name="data" type="xsd:base64Binary"/>
+  </wsdl:message>
+
+  <wsdl:message name="echoDataResponse">
+    <wsdl:part name="text" type="types:DataStruct" />
+    <wsdl:part name="data" element="xsd:base64Binary" />
+  </wsdl:message>
+
+  <wsdl:portType name="SwAServiceInterface">
+
+    <wsdl:operation name="echoData">
+      <wsdl:input message="tns:echoDataRequest" />
+      <wsdl:output message="tns:echoDataResponse" />
+    </wsdl:operation>
+
+  </wsdl:portType>
+
+  <wsdl:binding name="SwAServiceBinding" type="tns:SwAServiceInterface">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+    <wsdl:operation name="echoData">
+      <soap:operation soapAction="" style="literal" />
+      <wsdl:input>
+        <mime:multipartRelated>
+          <mime:part name="body">
+            <soap:body parts="text" use="literal" />
+          </mime:part>
+          <mime:part name="data">
+            <mime:content part="data" type="application/octet-stream" />
+          </mime:part>
+        </mime:multipartRelated>
+      </wsdl:input>
+      <wsdl:output>
+        <mime:multipartRelated>
+          <mime:part name="body">
+            <soap:body parts="text" use="literal" />
+          </mime:part>
+          <mime:part name="data">
+            <mime:content part="data" type="application/octet-stream" />
+          </mime:part>
+        </mime:multipartRelated>
+      </wsdl:output>
+    </wsdl:operation>
+
+  </wsdl:binding>
+
+  <wsdl:service name="SwAService">
+    <wsdl:port name="SwAServiceHttpPort" binding="tns:SwAServiceBinding">
+      <soap:address location="http://localhost:9036/swa" />
+    </wsdl:port>
+  </wsdl:service>
+
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jaxws/JAXWSBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jaxws/JAXWSBinding.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jaxws/JAXWSBinding.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/extensions/jaxws/JAXWSBinding.java Sun Dec 31 12:35:28 2006
@@ -31,7 +31,7 @@
     private boolean enableAsyncMapping;
     
     private boolean isSetMimeEnable;
-    private boolean enableMime;
+    private boolean enableMime = true;
     
     private Element element;
     private boolean required;

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/MIMEProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/MIMEProcessor.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/MIMEProcessor.java (original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/MIMEProcessor.java Sun Dec 31 12:35:28 2006
@@ -53,6 +53,8 @@
                 } else if ("text/xml".equals(mimeContent.getType())
                            || "application/xml".equals(mimeContent.getType())) {
                     return "javax.xml.transform.Source";
+                }  else {
+                    return "javax.activation.DataHandler";
                 }
             }
         }
@@ -82,29 +84,20 @@
                             jp.setClassName(mimeJavaType);
                         }
                     } else if (JavaType.Style.OUT.equals(style)) {
-                        if (mimeParts.size() > 2) {
-                            // more than 1 mime:content part (1 root soap body),
-                            // javaReturn will be set to void and
-                            // all output parameter will be treated as the
-                            // holder class
+                        if (jm.getReturn().getClassName().equals("void")) {
+                            // this is actually an in/out param...
                             String paramName = ProcessorUtil.mangleNameToVariableName(mimeContent.getPart());
                             JavaParameter jp = jm.getParameter(paramName);
                             if (jp == null) {
                                 Message message = new Message("MIMEPART_CANNOT_MAP", LOG, mimeContent
                                     .getPart());
                                 throw new ToolException(message);
-                            } else {
-                                if (!jp.getClassName().equals(mimeJavaType)) {
-                                    // jp.setType(mimeJavaType);
-                                    jp.setClassName(mimeJavaType);
-                                    jp.setHolderClass(mimeJavaType);
-                                }
-                            }
-                        } else {
-                            if (!jm.getReturn().getClassName().equals(mimeJavaType)) {
-                                // jm.getReturn().setType(mimeJavaType);
-                                jm.getReturn().setClassName(mimeJavaType);
-                            }
+                            } 
+                            jp.setClassName(mimeJavaType);
+                            jp.setHolderClass(mimeJavaType);
+                        } else if (!jm.getReturn().getClassName().equals(mimeJavaType)) {
+                            // jm.getReturn().setType(mimeJavaType);
+                            jm.getReturn().setClassName(mimeJavaType);
                         }
                     }
                 }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java (original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java Sun Dec 31 12:35:28 2006
@@ -349,12 +349,8 @@
                 }
             }
             if (obj instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
-                // Commented for future use
-                LOG.warning("The MIME content in wsdl file will be ignored, "
-                            + "current version does not support MIME content");
-                // MIMEProcessor mimeProcessor = new MIMEProcessor(this.env);
-                // mimeProcessor.process(jm, (MIMEMultipartRelated)obj,
-                // JavaType.Style.IN);
+                MIMEProcessor mimeProcessor = new MIMEProcessor(this.env);
+                mimeProcessor.process(jm, (MIMEMultipartRelated)obj, JavaType.Style.IN);
             }
         }
 
@@ -378,7 +374,7 @@
                     }
                     if (Boolean.valueOf((String)env.get(ToolConstants.CFG_EXTRA_SOAPHEADER)).booleanValue()
                         && !found) {
-                        // Header can't be found in java method parameters, in
+                        // Header can3t be found in java method parameters, in
                         // different message
                         // other than messages used in porttype operation
                         ParameterProcessor processor = new ParameterProcessor(this.env);
@@ -389,13 +385,8 @@
                     }
                 }
                 if (obj instanceof MIMEMultipartRelated && jm.getBindingExt().isEnableMime()) {
-                    // Commented for future use
-                    LOG.warning("The MIME content in wsdl file will be ignored, "
-                                + "current version does not support MIME content");
-                    // MIMEProcessor mimeProcessor = new
-                    // MIMEProcessor(this.env);
-                    // mimeProcessor.process(jm, (MIMEMultipartRelated)obj,
-                    // JavaType.Style.OUT);
+                    MIMEProcessor mimeProcessor = new MIMEProcessor(this.env);
+                    mimeProcessor.process(jm, (MIMEMultipartRelated)obj, JavaType.Style.OUT);
 
                 }
             }
@@ -648,6 +639,8 @@
         } else {
             // TBD: There is no extensibilityelement in port type
             bindingExt = new JAXWSBinding();
+            bindingExt.setSetMimeEnable(true);
+            bindingExt.setEnableMime(true);
         }
         jm.setBindingExt(bindingExt);
     }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaMIMETest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaMIMETest.java?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaMIMETest.java (original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaMIMETest.java Sun Dec 31 12:35:28 2006
@@ -19,14 +19,14 @@
 
 package org.apache.cxf.tools.wsdl2java.processor;
 
-//import java.io.File;
-//import java.io.FileReader;
-////import java.io.FileReader;
-//
-//import org.apache.cxf.tools.WSDLToJava;
-//import org.apache.cxf.tools.common.toolspec.ToolException;
+import java.io.File;
+import java.io.FileReader;
+import java.net.URISyntaxException;
+
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.wsdl2java.WSDLToJava;
 
 public class WSDLToJavaMIMETest
     extends ProcessorTestBase {
@@ -36,116 +36,146 @@
         env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
     }
 
-//    public void testHelloWorld() throws Exception {
-//        String[] args = new String[] {"-d", output.getCanonicalPath(),
-//                                      getLocation("/wsdl2java_wsdl/binary_attachment.wsdl")};
-//        WSDLToJava.main(args);
-//        assertNotNull(output);
-//        File org = new File(output, "org");
-//        assertTrue(org.exists());
-//        File apache = new File(org, "apache");
-//        assertTrue(apache.exists());
-//        File helloworldsoaphttp = new File(apache, "binary_attachment");
-//        assertTrue(helloworldsoaphttp.exists());
-//        File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
-//        assertTrue("PortType file is not generated", outputFile.exists());
-//        FileReader fileReader = new FileReader(outputFile);
-//        char[] chars = new char[100];
-//        int size = 0;
-//        StringBuffer sb = new StringBuffer();
-//        while (size < outputFile.length()) {
-//            int readLen = fileReader.read(chars);
-//            sb.append(chars, 0, readLen);
-//            size = size + readLen;
-//        }
-//        String serviceString = new String(sb);
-//        int position1 = serviceString.indexOf("public byte[] echoImage(");
-//        int position2 = serviceString.indexOf("byte[] para0");
-//        int position3 = serviceString.indexOf("java.awt.Image para1,");
-//        int position4 = serviceString
-//            .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
-//        assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0);
-//        assertTrue(position1 < position2 && position2 < position3 && position3 < position4);
-//    }
-//
-//    public void testWithExternalBindingSwitch() throws Exception {
-//        String[] args = new String[] {"-d", output.getCanonicalPath(), "-b",
-//                                      getLocation("/wsdl2java_wsdl/mime_binding.wsdl"),
-//                                      getLocation("/wsdl2java_wsdl/binary_attachment.wsdl")};
-//        WSDLToJava.main(args);
-//        assertNotNull(output);
-//        File org = new File(output, "org");
-//        assertTrue(org.exists());
-//        File apache = new File(org, "apache");
-//        assertTrue(apache.exists());
-//        File helloworldsoaphttp = new File(apache, "binary_attachment");
-//        assertTrue(helloworldsoaphttp.exists());
-//        File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
-//        assertTrue("PortType file is not generated", outputFile.exists());
-//        FileReader fileReader = new FileReader(outputFile);
-//        char[] chars = new char[100];
-//        int size = 0;
-//        StringBuffer sb = new StringBuffer();
-//        while (size < outputFile.length()) {
-//            int readLen = fileReader.read(chars);
-//            sb.append(chars, 0, readLen);
-//            size = size + readLen;
-//        }
-//        String serviceString = new String(sb);
-//        int position1 = serviceString.indexOf("public java.awt.Image echoImage(");
-//        int position2 = serviceString.indexOf("java.awt.Image para0");
-//        int position3 = serviceString.indexOf("public void echoMultipleImage(");
-//        int position4 = serviceString.indexOf("java.awt.Image para1,");
-//        int position5 = serviceString
-//            .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
-////        System.out.println("position1=" + position1 + "; position2=" + position2 + "; position3="
-////                           + position3 + "; position4=" + position4 + "; position5=" + position5);
-//        assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0
-//                   && position5 > 0);
-//        assertTrue(position1 < position2 && position2 < position3 && position3 < position4
-//                   && position4 < position5);
-//    }
-//
-//    public void testMIMEValidationUniqueRoot() throws Exception {
-//        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
-//        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
-//        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_unique_root.wsdl"));
-//        processor.setEnvironment(env);
-//        try {
-//            processor.process();
-//            fail("Do not catch expected tool exception for MIME unique root validation failure!");
-//        } catch (Exception e) {
-//            if (!(e instanceof ToolException && e.toString()
-//                .indexOf("There's more than one soap body mime part in its binding input") >= 0)) {
-//                fail("Do not catch expected tool exception for MIME unique root validation failure,"
-//                     + " catch other unexpected exception!");
-//            }
-//        }
-//    }
-//
-//    public void testMIMEValidationDiffParts() throws Exception {
-//        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
-//        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
-//        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_diff_parts.wsdl"));
-//        processor.setEnvironment(env);
-//        try {
-//            processor.process();
-//            fail("Do not catch expected tool exception for MIME different parts validation failure!");
-//        } catch (Exception e) {
-//            if (!(e instanceof ToolException && e.toString()
-//                .indexOf("Part attribute value for meme:content elements are different") >= 0)) {
-//                fail("Do not catch expected tool exception for MIME different parts validation failure,"
-//                     + " catch other unexpected exception!");
-//            }
-//        }
-//    }
-
-//    private String getLocation(String wsdlFile) {
-//        return WSDLToJavaMIMETest.class.getResource(wsdlFile).getFile();
-//    }
-    
     public void testDummy() {
-        System.out.print("");
+        
+    }
+    
+    public void testMimeInOut() throws Exception {
+        String[] args = new String[] {"-d", 
+                                      output.getAbsolutePath(),
+                                      getLocation("/wsdl2java_wsdl/mime-inout.wsdl")};
+        WSDLToJava.main(args);
+        assertNotNull(output);
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File helloworldsoaphttp = new File(apache, "cxf/swa");
+        assertTrue(helloworldsoaphttp.exists());
+        File outputFile = new File(helloworldsoaphttp, "SwAServiceInterface.java");
+        assertTrue("PortType file is not generated", outputFile.exists());
+        FileReader fileReader = new FileReader(outputFile);
+        char[] chars = new char[100];
+        int size = 0;
+        StringBuffer sb = new StringBuffer();
+        while (size < outputFile.length()) {
+            int readLen = fileReader.read(chars);
+            sb.append(chars, 0, readLen);
+            size = size + readLen;
+        }
+        String serviceString = new String(sb);
+        int position1 = serviceString.indexOf("public void echoData(");
+        int position2 = serviceString.indexOf("Holder<javax.activation.DataHandler> data");
+        assertTrue(position1 > 0 && position2 > 0);
+    }
+    
+    public void testHelloWorld() throws Exception {
+        String[] args = new String[] {"-d", 
+                                      output.getAbsolutePath(),
+                                      getLocation("/wsdl2java_wsdl/binary_attachment.wsdl")};
+        WSDLToJava.main(args);
+        assertNotNull(output);
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File helloworldsoaphttp = new File(apache, "binary_attachment");
+        assertTrue(helloworldsoaphttp.exists());
+        File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
+        assertTrue("PortType file is not generated", outputFile.exists());
+        FileReader fileReader = new FileReader(outputFile);
+        char[] chars = new char[100];
+        int size = 0;
+        StringBuffer sb = new StringBuffer();
+        while (size < outputFile.length()) {
+            int readLen = fileReader.read(chars);
+            sb.append(chars, 0, readLen);
+            size = size + readLen;
+        }
+        String serviceString = new String(sb);
+        int position1 = serviceString.indexOf("public byte[] echoImage(");
+        int position2 = serviceString.indexOf("byte[] para0");
+        int position3 = serviceString.indexOf("java.awt.Image para1,");
+        int position4 = serviceString
+            .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
+        assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0);
+        assertTrue(position1 < position2 && position2 < position3 && position3 < position4);
+    }
+
+    public void xtestWithExternalBindingSwitch() throws Exception {
+        String[] args = new String[] {"-d", output.getCanonicalPath(), "-b",
+                                      getLocation("/wsdl2java_wsdl/mime_binding.wsdl"),
+                                      getLocation("/wsdl2java_wsdl/binary_attachment.wsdl")};
+        WSDLToJava.main(args);
+        assertNotNull(output);
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File helloworldsoaphttp = new File(apache, "binary_attachment");
+        assertTrue(helloworldsoaphttp.exists());
+        File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
+        assertTrue("PortType file is not generated", outputFile.exists());
+        FileReader fileReader = new FileReader(outputFile);
+        char[] chars = new char[100];
+        int size = 0;
+        StringBuffer sb = new StringBuffer();
+        while (size < outputFile.length()) {
+            int readLen = fileReader.read(chars);
+            sb.append(chars, 0, readLen);
+            size = size + readLen;
+        }
+        String serviceString = new String(sb);
+        int position1 = serviceString.indexOf("public java.awt.Image echoImage(");
+        int position2 = serviceString.indexOf("java.awt.Image para0");
+        int position3 = serviceString.indexOf("public void echoMultipleImage(");
+        int position4 = serviceString.indexOf("java.awt.Image para1,");
+        int position5 = serviceString
+            .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
+//        System.out.println("position1=" + position1 + "; position2=" + position2 + "; position3="
+//                           + position3 + "; position4=" + position4 + "; position5=" + position5);
+        assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0
+                   && position5 > 0);
+        assertTrue(position1 < position2 && position2 < position3 && position3 < position4
+                   && position4 < position5);
+    }
+
+    public void xtestMIMEValidationUniqueRoot() throws Exception {
+        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
+        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_unique_root.wsdl"));
+        processor.setEnvironment(env);
+        try {
+            processor.process();
+            fail("Do not catch expected tool exception for MIME unique root validation failure!");
+        } catch (Exception e) {
+            if (!(e instanceof ToolException && e.toString()
+                .indexOf("There's more than one soap body mime part in its binding input") >= 0)) {
+                fail("Do not catch expected tool exception for MIME unique root validation failure,"
+                     + " catch other unexpected exception!");
+            }
+        }
+    }
+
+    public void xtestMIMEValidationDiffParts() throws Exception {
+        WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
+        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_diff_parts.wsdl"));
+        processor.setEnvironment(env);
+        try {
+            processor.process();
+            fail("Do not catch expected tool exception for MIME different parts validation failure!");
+        } catch (Exception e) {
+            if (!(e instanceof ToolException && e.toString()
+                .indexOf("Part attribute value for meme:content elements are different") >= 0)) {
+                fail("Do not catch expected tool exception for MIME different parts validation failure,"
+                     + " catch other unexpected exception!");
+            }
+        }
+    }
+
+    private String getLocation(String wsdlFile) throws URISyntaxException {
+        return WSDLToJavaMIMETest.class.getResource(wsdlFile).getFile();
     }
     
 }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/binary_attachment.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/binary_attachment.wsdl?view=diff&rev=491479&r1=491478&r2=491479
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/binary_attachment.wsdl (original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/binary_attachment.wsdl Sun Dec 31 12:35:28 2006
@@ -59,6 +59,9 @@
         <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
         <wsdl:operation name="echoImage">
             <soap:operation soapAction="urn:AttachmentService/echoImage" style="rpc"/>
+            <jaxws:bindings>
+                <enableMIMEContent>false</enableMIMEContent>
+            </jaxws:bindings>
             <wsdl:input name="echoImageRequest">
                 <mime:multipartRelated>
                     <mime:part name="part1">
@@ -86,10 +89,7 @@
         </wsdl:operation>
         <wsdl:operation name="echoMultipleImage">
             <soap:operation soapAction="urn:AttachmentService/echoMultipleImage" style="rpc"/>
-    	    <jaxws:bindings>
-				<enableMIMEContent>true</enableMIMEContent>
-			</jaxws:bindings>
-            <wsdl:input name="echoMultipleImageRequest">
+    	    <wsdl:input name="echoMultipleImageRequest">
                 <mime:multipartRelated>
                     <mime:part name="part1">
                         <soap:body 

Added: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl?view=auto&rev=491479
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl (added)
+++ incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl Sun Dec 31 12:35:28 2006
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+  
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions name="SwAService" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+  xmlns:tns="http://cxf.apache.org/swa" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+  xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:types="http://cxf.apache.org/swa/types"
+  xmlns:xmime="http://www.w3.org/2005/05/xmlmime" targetNamespace="http://cxf.apache.org/swa"
+  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
+
+  <wsdl:types>
+    <xsd:schema xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+      targetNamespace="http://cxf.apache.org/swa/types">
+      <xsd:import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>
+      <xsd:element name="DataStruct">
+        <xsd:complexType>
+          <xsd:sequence>
+            <xsd:element name="DataRef" type="wsi:swaRef"
+        xmime:expectedContentTypes="application/octet-stream" />
+          </xsd:sequence>
+        </xsd:complexType>
+      </xsd:element>
+      
+    </xsd:schema>
+
+    <xsd:schema targetNamespace="http://ws-i.org/profiles/basic/1.1/xsd"
+      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+      <xsd:simpleType name="swaRef">
+        <xsd:restriction base="xsd:anyURI" />
+      </xsd:simpleType>
+    </xsd:schema>
+  </wsdl:types>
+
+  <wsdl:message name="echoDataRequest">
+    <wsdl:part name="text" element="types:DataStruct" />
+    <wsdl:part name="data" type="xsd:base64Binary"/>
+  </wsdl:message>
+
+  <wsdl:message name="echoDataResponse">
+    <wsdl:part name="text" type="xsd:string" />
+    <wsdl:part name="data" element="xsd:base64Binary" />
+  </wsdl:message>
+
+  <wsdl:portType name="SwAServiceInterface">
+
+    <wsdl:operation name="echoData">
+      <wsdl:input message="tns:echoDataRequest" />
+      <wsdl:output message="tns:echoDataRequest" />
+    </wsdl:operation>
+
+  </wsdl:portType>
+
+  <wsdl:binding name="SwAServiceBinding" type="tns:SwAServiceInterface">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+    <wsdl:operation name="echoData">
+      <soap:operation soapAction="" style="literal" />
+      <wsdl:input>
+        <mime:multipartRelated>
+          <mime:part name="body">
+            <soap:body parts="text" use="literal" />
+          </mime:part>
+          <mime:part name="data">
+            <mime:content part="data" type="application/octet-stream" />
+          </mime:part>
+        </mime:multipartRelated>
+      </wsdl:input>
+      <wsdl:output>
+        <mime:multipartRelated>
+          <mime:part name="body">
+            <soap:body parts="text" use="literal" />
+          </mime:part>
+          <mime:part name="data">
+            <mime:content part="data" type="application/octet-stream" />
+          </mime:part>
+        </mime:multipartRelated>
+      </wsdl:output>
+    </wsdl:operation>
+
+  </wsdl:binding>
+
+  <wsdl:service name="SwAService">
+    <wsdl:port name="SwAServiceHttpPort" binding="tns:SwAServiceBinding">
+      <soap:address location="http://localhost:9036/swa" />
+    </wsdl:port>
+  </wsdl:service>
+
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/wsdl2java/src/test/resources/wsdl2java_wsdl/mime-inout.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message