Author: tho...@jb...
Date: 2006-06-28 06:05:07 -0400 (Wed, 28 Jun 2006)
New Revision: 503
Added:
branches/jbossws-1.0/src/test/resources/samples/mtom/disguised_jpeg.xcf
Modified:
branches/jbossws-1.0/.classpath
branches/jbossws-1.0/src/main/etc/jbossws14-component-info.xml
branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentMarshallerImpl.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentUnmarshallerImpl.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBDeserializer.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/SimpleDeserializer.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/CIDGenerator.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MimeConstants.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MultipartRelatedXOPEncoder.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/WSDLToJava.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/utils/MimeUtils.java
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/soap/SOAPEnvelopeTestCase.java
branches/jbossws-1.0/src/test/resources/samples-override/mtom/WEB-INF/wsdl/TestService.wsdl
branches/jbossws-1.0/version.properties
Log:
merge from trunk
Modified: branches/jbossws-1.0/.classpath
===================================================================
--- branches/jbossws-1.0/.classpath 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/.classpath 2006-06-28 10:05:07 UTC (rev 503)
@@ -28,5 +28,9 @@
<classpathentry kind="lib" path="thirdparty/jaxb-api.jar"/>
<classpathentry kind="lib" path="thirdparty/jaxb-impl.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jboss-4.0.x"/>
+ <classpathentry kind="lib" path="thirdparty/jboss-common.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jboss-jmx.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jboss-system.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified: branches/jbossws-1.0/src/main/etc/jbossws14-component-info.xml
===================================================================
--- branches/jbossws-1.0/src/main/etc/jbossws14-component-info.xml 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/etc/jbossws14-component-info.xml 2006-06-28 10:05:07 UTC (rev 503)
@@ -9,7 +9,6 @@
<artifact id="jbossws14-client.jar"/>
<import componentref="apache-xmlsec">
- <compatible version="1.2.97"/>
<compatible version="@apache-xmlsec@"/>
</import>
<import componentref="javassist">
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentMarshallerImpl.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentMarshallerImpl.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentMarshallerImpl.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -21,7 +21,10 @@
*/
package org.jboss.ws.binding;
+// $Id: $
+
import javax.activation.DataHandler;
+import javax.xml.bind.attachment.AttachmentMarshaller;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
@@ -46,10 +49,14 @@
* @author Heiko Braun <hei...@jb...>
* @since May 9, 2006
*/
-public class AttachmentMarshallerImpl
+public class AttachmentMarshallerImpl extends AttachmentMarshaller
{
private static final Logger log = Logger.getLogger(AttachmentMarshallerImpl.class);
+ public AttachmentMarshallerImpl()
+ {
+ }
+
public boolean isXOPPackage()
{
return AttachmentMarshallerSupport.isXOPPackage();
@@ -70,10 +77,12 @@
StringBuilder xopInclude = new StringBuilder("<" + Constants.PREFIX_XOP + ":Include ");
xopInclude.append("xmlns:" + Constants.PREFIX_XOP + "='" + Constants.NS_XOP + "' ");
String cid = soapMessage.getCidGenerator().generateFromName(xmlName.getLocalPart());
- xopInclude.append("href='" + cid + "'/>");
+ // RFC2392 requires the 'cid:' prefix to be added to the XML element
+ xopInclude.append("href='cid:" + cid + "'/>");
+
AttachmentPart xopPart = soapMessage.createAttachmentPart(dataHandler);
- xopPart.addMimeHeader(MimeConstants.CONTENT_ID, cid);
+ xopPart.addMimeHeader(MimeConstants.CONTENT_ID, '<' + cid + '>'); // RFC2392 requirement
soapMessage.addAttachmentPart(xopPart);
return xopInclude.toString();
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentUnmarshallerImpl.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentUnmarshallerImpl.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/AttachmentUnmarshallerImpl.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -21,11 +21,15 @@
*/
package org.jboss.ws.binding;
+// $Id: $
+
import javax.activation.DataHandler;
+import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPException;
import org.jboss.logging.Logger;
+import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
import org.jboss.ws.soap.MessageContextAssociation;
import org.jboss.ws.soap.SOAPMessageContextImpl;
@@ -42,10 +46,15 @@
* @author Heiko Braun <hei...@jb...>
* @since May 9, 2006
*/
-public class AttachmentUnmarshallerImpl
+public class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller
{
+
private static final Logger log = Logger.getLogger(AttachmentUnmarshallerImpl.class);
+ public AttachmentUnmarshallerImpl()
+ {
+ }
+
public boolean isXOPPackage()
{
return AttachmentMarshallerSupport.isXOPPackage();
@@ -58,11 +67,18 @@
{
SOAPMessageContextImpl msgContext = MessageContextAssociation.peekMessageContext();
SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getMessage();
+
+ // RFC2392 requires the 'cid:' part to be stripped from the cid
+ if (cid.startsWith("cid:"))
+ cid = cid.substring(4);
+ cid = '<' + cid + '>'; // RFC2392 requirement
+
AttachmentPart part = soapMessage.getAttachmentByContentId(cid);
if (part == null)
throw new WSException("Cannot find attachment part for: " + cid);
- return part.getDataHandler();
+ DataHandler dataHandler = part.getDataHandler();
+ return dataHandler;
}
catch (SOAPException ex)
{
@@ -73,7 +89,6 @@
public byte[] getAttachmentAsByteArray(String cid)
{
- throw new IllegalArgumentException("Not yet implemented");
+ throw new NotImplementedException();
}
-
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -613,12 +613,12 @@
if (paramMetaData.isSwA())
{
- String swaCID = "<" + partName + "=" + cidGenerator.generateFromCount() + ">";
+ String swaCID = '<' + partName + "=" + cidGenerator.generateFromCount() + '>';
part.setContentId(swaCID);
}
if (paramMetaData.isXOP())
{
- String xopCID = "<" + cidGenerator.generateFromName(partName) + ">";
+ String xopCID = '<' + cidGenerator.generateFromName(partName) + '>';
part.setContentId(xopCID);
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBDeserializer.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBDeserializer.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBDeserializer.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -76,25 +76,31 @@
Object value = null;
String typeName = xmlType.getLocalPart();
- AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl();
// Currently we intercept xsd:base64Binary types to allow callback for
// XOP processing. This should actually be moved to jbossxb once it supports
// the AttachMarshaller and Unmarshaller interfaces.
-
- if (attachmentUnmarshaller.isXOPPackage() && ("base64Binary".equals(typeName)))
+
+ boolean isXOPPackage = false;
+ if ("base64Binary".equals(typeName))
{
- try
+ AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl();
+ isXOPPackage = attachmentUnmarshaller.isXOPPackage();
+ if (isXOPPackage)
{
- DataHandler dataHandler = attachmentUnmarshaller.getAttachmentAsDataHandler(val);
- value = dataHandler.getContent();
+ try
+ {
+ DataHandler dataHandler = attachmentUnmarshaller.getAttachmentAsDataHandler(val);
+ value = dataHandler.getContent();
+ }
+ catch (IOException e)
+ {
+ throw new BindingException("Failed to unmarshal XOP content: " + e.getMessage());
+ }
}
- catch (IOException e)
- {
- throw new BindingException("Failed to unmarshal XOP content: " + e.getMessage());
- }
}
- else
+
+ if (isXOPPackage == false)
{
try
{
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/SimpleDeserializer.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/SimpleDeserializer.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/jaxrpc/encoding/SimpleDeserializer.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -50,20 +50,26 @@
Object value = null;
String typeName = xmlType.getLocalPart();
- AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl();
- if (attachmentUnmarshaller.isXOPPackage() && ("base64Binary".equals(typeName) || "hexBinary".equals(typeName)))
+
+ boolean isXOPPackage = false;
+ if ("base64Binary".equals(typeName))
{
- try
+ AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl();
+ isXOPPackage = attachmentUnmarshaller.isXOPPackage();
+ if (isXOPPackage)
{
- DataHandler dataHandler = attachmentUnmarshaller.getAttachmentAsDataHandler(xmlFragment);
- value = dataHandler.getContent();
+ try
+ {
+ DataHandler dataHandler = attachmentUnmarshaller.getAttachmentAsDataHandler(xmlFragment);
+ value = dataHandler.getContent();
+ }
+ catch (IOException e)
+ {
+ throw new BindingException("Failed to unmarshal XOP content: " + e.getMessage());
+ }
}
- catch (IOException e)
- {
- throw new BindingException(e.getMessage());
- }
}
-
+
String valueStr = unwrapValueStr(xmlFragment);
if (valueStr != null)
{
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -31,6 +31,7 @@
import org.jboss.ws.jaxrpc.encoding.*;
import org.jboss.ws.metadata.ParameterMetaData;
import org.jboss.ws.utils.JavaUtils;
+import org.jboss.ws.utils.MimeUtils;
import org.w3c.dom.*;
import javax.xml.namespace.QName;
@@ -41,6 +42,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Iterator;
+import java.io.ByteArrayInputStream;
/**
* A SOAPElement that gives access to its content as XML fragment or Java object.
@@ -259,8 +261,8 @@
}
else
{
- // if the fragment did not indicate a null return
- // by an xsi:nil we return an empty array
+ // if the fragment did not indicate a null return
+ // by an xsi:nil we return an empty array
Class componentType = javaType.getComponentType();
obj = Array.newInstance(componentType, 0);
}
@@ -274,7 +276,25 @@
}
if (isAssignable == false)
- throw new WSException("Java type '" + javaType + "' is not assignable from: " + objType.getName());
+ {
+ // MSFT hack
+ Object convertedObj = null;
+ if(obj instanceof ByteArrayInputStream)
+ {
+ MimeUtils utils = new MimeUtils();
+ MimeUtils.ByteArrayConverter converter = utils.getConverterFor(javaType);
+ convertedObj = converter.convert( (ByteArrayInputStream)obj );
+ }
+
+ if(null == convertedObj) // conversion failed
+ {
+ throw new WSException("Java type '" + javaType + "' is not assignable from: " + objType.getName());
+ }
+ else
+ {
+ obj = convertedObj;
+ }
+ }
}
this.objectValue = obj;
@@ -312,7 +332,7 @@
throw new IllegalArgumentException("Invalid null xmime:contentType");
log.debug("xmime:contentType=" + contentType);
-
+
// Mark the associated SOAPMessage as XOP message
SOAPMessageImpl soapMessage = (SOAPMessageImpl)((SOAPEnvelopeImpl)getSOAPEnvelope()).getSOAPMessage();
soapMessage.setXOPMessage(true);
@@ -366,7 +386,7 @@
}
}
- // Get the serializer factory for a given javaType and xmlType
+ // Get the serializer factory for a given javaType and xmlType
private SerializerFactoryBase getSerializerFactory(TypeMappingImpl typeMapping, Class javaType, QName xmlType)
{
SerializerFactoryBase serializerFactory = (SerializerFactoryBase)typeMapping.getSerializer(javaType, xmlType);
@@ -399,7 +419,7 @@
return serializerFactory;
}
- // Get the deserializer factory for a given javaType and xmlType
+ // Get the deserializer factory for a given javaType and xmlType
private DeserializerFactoryBase getDeserializerFactory(TypeMappingImpl typeMapping, Class javaType, QName xmlType)
{
DeserializerFactoryBase deserializerFactory = (DeserializerFactoryBase)typeMapping.getDeserializer(javaType, xmlType);
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/CIDGenerator.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/CIDGenerator.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/CIDGenerator.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -40,7 +40,7 @@
// provide logging
private static Logger log = Logger.getLogger(CIDGenerator.class);
- private int count = 0;
+ private int count = 0;
public String generateFromCount()
{
@@ -56,6 +56,9 @@
public String generateFromName(String name)
{
+
+ // See http://www.ietf.org/rfc/rfc2392.txt on rules howto create cid's
+ // TODO: URL decode when cid's are received
try
{
name = URLEncoder.encode(name, "UTF-8");
@@ -65,7 +68,7 @@
log.error("Cannot encode name for cid: " + ex);
}
- String cid = "cid:" + name + "-" + UUIDGenerator.generateRandomUUIDString() + "@" + MimeConstants.CID_DOMAIN;
+ String cid = name + "-" + UUIDGenerator.generateRandomUUIDString() + "@" + MimeConstants.CID_DOMAIN;
log.debug("generateFromName: " + cid);
return cid;
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MimeConstants.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MimeConstants.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MimeConstants.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -54,4 +54,5 @@
// Misc
public static final String CID_DOMAIN = "ws.jboss.org";
public static final String ROOTPART_CID = "<rootpart@" + CID_DOMAIN + ">";
+ public static final String START_INFO_XOP = "text/xml";
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MultipartRelatedXOPEncoder.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MultipartRelatedXOPEncoder.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/soap/attachment/MultipartRelatedXOPEncoder.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -59,7 +59,8 @@
ParameterList p = new ParameterList();
p.set("type", MimeConstants.TYPE_APPLICATION_XOP_XML);
p.set("start", MimeConstants.ROOTPART_CID);
-
+ p.set("start-info", MimeConstants.START_INFO_XOP);
+
MimeMultipart multipart = new MimeMultipart("related" + p);
MimeBodyPart rootPart = new MimeBodyPart();
@@ -74,7 +75,7 @@
rootPart.setText(envStr, "UTF-8");
rootPart.setContentID(MimeConstants.ROOTPART_CID);
- rootPart.setHeader(MimeConstants.CONTENT_TYPE, MimeConstants.TYPE_APPLICATION_XOP_XML);
+ rootPart.setHeader(MimeConstants.CONTENT_TYPE, MimeConstants.TYPE_APPLICATION_XOP_XML + "; type=\"text/xml\"");
rootPart.setHeader(MimeConstants.CONTENT_TRANSFER_ENCODING, MimeConstants.TEXT_8BIT_ENCODING);
multipart.addBodyPart(rootPart);
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -358,7 +358,7 @@
if (! xt.getAnonymous())
xt = xsmodel.getTypeDefinition(xt.getName(), xt.getNamespace());
if(xt instanceof XSComplexTypeDefinition)
- generateJavaSource((XSComplexTypeDefinition)xt,xsmodel, faultXMLName.getLocalPart(), true);
+ generateJavaSourceForException((XSComplexTypeDefinition)xt,xsmodel);
Class cl = getJavaType(faultXMLType, false);
if (cl == null)
@@ -563,13 +563,15 @@
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel, String containingElement) throws IOException
{
- generateJavaSource(xt, xsmodel, containingElement, false);
+ XSDTypeToJava xtj = new XSDTypeToJava();
+ xtj.setTypeMapping(this.typeMapping);
+ xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement, getLocationForJavaGeneration(), seiPkgName, xsmodel, false);
}
- private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel, String containingElement, boolean exception) throws IOException
+ private void generateJavaSourceForException(XSComplexTypeDefinition xt, JBossXSModel xsmodel) throws IOException
{
XSDTypeToJava xtj = new XSDTypeToJava();
xtj.setTypeMapping(this.typeMapping);
- xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement, getLocationForJavaGeneration(), seiPkgName, xsmodel, exception);
+ xtj.createJavaFile((XSComplexTypeDefinition)xt, null,getLocationForJavaGeneration(),seiPkgName,xsmodel,true);
}
-}
\ No newline at end of file
+}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/utils/MimeUtils.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/utils/MimeUtils.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/utils/MimeUtils.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -28,13 +28,18 @@
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
+import java.io.ByteArrayInputStream;
+import java.awt.image.BufferedImage;
import javax.mail.internet.ContentType;
import javax.mail.internet.ParseException;
import javax.mail.internet.MimeMultipart;
import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
import org.jboss.ws.Constants;
+import com.sun.image.codec.jpeg.JPEGImageDecoder;
+import com.sun.image.codec.jpeg.JPEGCodec;
/**
* Generic mime utility class.
@@ -164,4 +169,87 @@
}
return mimeType;
}
+
+ public ByteArrayConverter getConverterFor(Class targetClazz)
+ {
+ ByteArrayConverter converter = null;
+ if(JavaUtils.isAssignableFrom(targetClazz, java.awt.Image.class))
+ converter = new ImageConverter();
+ else if (JavaUtils.isAssignableFrom(targetClazz, javax.xml.transform.Source.class))
+ converter = new SourceConverter();
+ else if (JavaUtils.isAssignableFrom(targetClazz, java.lang.String.class))
+ converter = new StringConverter();
+
+ if(null == converter)
+ throw new IllegalArgumentException("Unable to resolve conversion strategy for: " + targetClazz);
+
+ return converter;
+ }
+
+ public class ImageConverter implements ByteArrayConverter
+ {
+ public Object convert(ByteArrayInputStream in) {
+ Object converted = null;
+ try
+ {
+ JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
+ BufferedImage bim = dec.decodeAsBufferedImage();
+ converted = bim;
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+
+ return converted;
+ }
+
+ }
+
+ public class SourceConverter implements ByteArrayConverter
+ {
+ public Object convert(ByteArrayInputStream in) {
+
+ Object converted = null;
+ try
+ {
+ converted = new StreamSource(in);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+
+ return converted;
+ }
+ }
+
+ public class StringConverter implements ByteArrayConverter
+ {
+ public Object convert(ByteArrayInputStream in) {
+ Object converted = null;
+ try
+ {
+ StringBuffer sb = new StringBuffer();
+ while(in.available()>0)
+ {
+ sb.append(in.read());
+ }
+ converted = sb.toString();
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+
+ return converted;
+ }
+ }
+
+ public interface ByteArrayConverter
+ {
+ Object convert(ByteArrayInputStream in);
+ }
+
+
}
\ No newline at end of file
Modified: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java
===================================================================
--- branches/jbossws-1.0/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -28,6 +28,8 @@
import org.jboss.ws.jaxrpc.ServiceFactoryImpl;
import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.naming.InitialContext;
@@ -37,8 +39,9 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.Source;
import java.awt.*;
-import java.io.File;
-import java.io.FileInputStream;
+import java.awt.image.PixelGrabber;
+import java.awt.image.MemoryImageSource;
+import java.io.*;
import java.net.URL;
/**
@@ -109,6 +112,17 @@
}
}
+ /** Send uknown file that actually is a jpeg that will turns into octet-stream
+ */
+ public void testSendDisguised() throws Exception
+ {
+ Object value = port.sendMimeImageGIF("Some text message", new DataHandler(
+ new FileDataSource("resources/samples/mtom/disguised_jpeg.xcf")
+ ));
+ assertNotNull(value);
+ assertTrue("Wrong return value type", value instanceof Image);
+ }
+
/** Send a multipart message with a text/plain attachment part
*/
public void testSendMimeImageJPEG() throws Exception
@@ -184,4 +198,48 @@
assertNotNull(value);
assertTrue("Wrong return value type", value instanceof Source);
}
+
+ private class ObjectDataSource implements DataSource
+ {
+ private Object obj;
+ private byte[] bytes;
+
+ public ObjectDataSource(Object obj) {
+
+ if(! (obj instanceof Serializable) )
+ throw new IllegalArgumentException("Object must be serializable");
+
+ this.obj = obj;
+
+ try
+ {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream os = new ObjectOutputStream(bout);
+ os.writeObject(obj);
+ this.bytes = bout.toByteArray();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e.getMessage());
+ }
+ }
+
+ public String getContentType() {
+ return "application/octet-stream";
+ }
+
+ public InputStream getInputStream() throws IOException {
+ ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ return new ObjectInputStream(in);
+ }
+
+ public String getName() {
+ return obj.getClass().getName();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ return new ObjectOutputStream(out) ;
+ }
+ }
}
Modified: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/soap/SOAPEnvelopeTestCase.java
===================================================================
--- branches/jbossws-1.0/src/test/java/org/jboss/test/ws/soap/SOAPEnvelopeTestCase.java 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/test/java/org/jboss/test/ws/soap/SOAPEnvelopeTestCase.java 2006-06-28 10:05:07 UTC (rev 503)
@@ -21,23 +21,21 @@
*/
package org.jboss.test.ws.soap;
-import org.jboss.test.ws.JBossWSTest;
-import org.jboss.util.xml.DOMUtils;
-import org.jboss.util.xml.DOMWriter;
-import org.jboss.ws.Constants;
-import org.jboss.ws.soap.MessageFactoryImpl;
-import org.w3c.dom.Element;
+import java.io.ByteArrayInputStream;
+import java.util.Iterator;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
-import java.io.ByteArrayInputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.util.Iterator;
+import org.jboss.test.ws.JBossWSTest;
+import org.jboss.util.xml.DOMUtils;
+import org.jboss.ws.Constants;
+import org.jboss.ws.soap.MessageFactoryImpl;
+import org.w3c.dom.Element;
+
/**
* Test the SOAPEnvelope
*
@@ -141,11 +139,6 @@
SOAPEnvelope wasEnv = soapMsg.getSOAPPart().getEnvelope();
Element expEnv = DOMUtils.parse(envStr);
-
- System.out.println("EXP " + DOMWriter.printNode(expEnv, true));
- System.out.println("");
- System.out.println("WAS "+DOMWriter.printNode(wasEnv, true));
-
assertEquals(expEnv, wasEnv);
}
}
Added: branches/jbossws-1.0/src/test/resources/samples/mtom/disguised_jpeg.xcf
===================================================================
(Binary files differ)
Property changes on: branches/jbossws-1.0/src/test/resources/samples/mtom/disguised_jpeg.xcf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/jbossws-1.0/src/test/resources/samples-override/mtom/WEB-INF/wsdl/TestService.wsdl
===================================================================
--- branches/jbossws-1.0/src/test/resources/samples-override/mtom/WEB-INF/wsdl/TestService.wsdl 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/src/test/resources/samples-override/mtom/WEB-INF/wsdl/TestService.wsdl 2006-06-28 10:05:07 UTC (rev 503)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="XOPTest" targetNamespace="http://org.jboss.ws/samples/mtom" xmlns:tns="http://org.jboss.ws/samples/mtom" xmlns="http://schemas.xmlsoap.org/wsdl/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://org.jboss.ws/samples/mtom"
@@ -21,10 +21,10 @@
<message name="XOPTest_sendMimeImageGIF">
<part name="message" type="xsd:string"/>
- <part name="xoppart" element="tns:imagegif"/>
+ <part name="xoppart" type="xmime:base64Binary"/>
</message>
<message name="XOPTest_sendMimeImageGIFResponse">
- <part name="result" element="tns:imagegif"/>
+ <part name="result" type="xmime:base64Binary"/>
</message>
<message name="XOPTest_sendMimeImageJPEG">
Modified: branches/jbossws-1.0/version.properties
===================================================================
--- branches/jbossws-1.0/version.properties 2006-06-28 02:58:55 UTC (rev 502)
+++ branches/jbossws-1.0/version.properties 2006-06-28 10:05:07 UTC (rev 503)
@@ -3,7 +3,7 @@
specification.vendor=JBoss (http://www.jboss.org)
specification.version=jbossws-1.0
-version.id=1.0.1.GA
+version.id=1.0.2.DEV
implementation.title=JBoss Web Services (JBossWS)
implementation.url=http://www.jboss.org/products/jbossws
|