[jboss-svn-commits] JBossWS SVN: r720 - in branches/jbossws-1.0_Heiko/src: main/java/org/jboss/ws/binding main/java/org/jboss/ws/binding/soap main/java/org/jboss/ws/handler main/java/org/jboss/ws/jaxb main/java/org/jboss/ws/jaxrpc main/java/org/jboss/ws/jaxrpc/encoding main/java/org/jboss/ws/soap main/java/org/jboss/ws/soap/attachment main/java/org/jboss/ws/tools main/java/org/jboss/ws/utils main/java/org/jboss/ws/wsse main/java/org/jboss/ws/xop test/java/org/jboss/test/ws/addressing test/java/org/jboss/test/ws/jbws801 test/java/org/jboss/test/ws/samples/dynamichandler test/java/org/jboss/test/ws/samples/mtom test/java/org/jboss/test/ws/xop/doclit
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 10 06:51:59 EDT 2006
Author: heiko.braun at jboss.com
Date: 2006-08-10 06:51:21 -0400 (Thu, 10 Aug 2006)
New Revision: 720
Modified:
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPMessageMarshaller.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/handler/HandlerChainBaseImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxb/SchemaBindingBuilder.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/StubExt.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBSerializer.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/NodeImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPEnvelopeImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPFactoryImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPHeaderImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/attachment/ByteArrayContentHandler.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/WSDLToJava.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/IOUtils.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/JavaUtils.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/MimeUtils.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/DecodingOperation.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/TokenOperation.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPContext.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java
branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/addressing/SOAPAddressingPropertiesTestCase.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/jbws801/JBWS801TestCase.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/dynamichandler/DynamicHandlerTestCase.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/InlineHandler.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsg.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsgResponse.java
branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/XOPElementDoclitTestCase.java
Log:
Finished XOP inline
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/EndpointInvocation.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/EndpointInvocation.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/EndpointInvocation.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -239,7 +239,7 @@
}
/** Synchronize the operation IN, INOUT paramters with the call input parameters.
- * Essetially it unwrapps holders and converts primitives to wrapper types.
+ * Essentially it unwrapps holders and converts primitives to wrapper types.
*/
public void initInputParams(Object[] inputParams)
{
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPBindingProvider.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -90,7 +90,9 @@
SOAPMessageImpl reqMessage = (SOAPMessageImpl)createMessage(opMetaData);
msgContext.setMessage(reqMessage);
- SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
+ SOAPEnvelopeImpl soapEnvelope = (SOAPEnvelopeImpl)reqMessage.getSOAPPart().getEnvelope();
+ soapEnvelope.setDomExpansionEnabled(false);
+
SOAPBody soapBody = soapEnvelope.getBody();
SOAPHeader soapHeader = soapEnvelope.getHeader();
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPMessageMarshaller.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPMessageMarshaller.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/binding/soap/SOAPMessageMarshaller.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -44,7 +44,7 @@
private static Logger log = Logger.getLogger(SOAPMessageMarshaller.class);
/**
- * Marshaller will need to take the dataObject and convert
+ * Marshaller will need to take the dataObject and readFrom
* into primitive java data types and write to the
* given output.
*
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/handler/HandlerChainBaseImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/handler/HandlerChainBaseImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/handler/HandlerChainBaseImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -241,9 +241,7 @@
currHandler = ((HandlerEntry)handlers.get(handlerIndex)).getHandler();
log.debug("Handle request: " + currHandler);
- XOPContext.setInlineBase64();
doNext = currHandler.handleRequest(msgContext);
- XOPContext.unsetInlineBase64();
if (log.isTraceEnabled())
{
@@ -309,9 +307,7 @@
currHandler = ((HandlerEntry)handlers.get(handlerIndex)).getHandler();
log.debug("Handle response: " + currHandler);
- XOPContext.setInlineBase64();
- doNext = currHandler.handleResponse(msgContext);
- XOPContext.unsetInlineBase64();
+ doNext = currHandler.handleResponse(msgContext);
if (log.isTraceEnabled())
{
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxb/SchemaBindingBuilder.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxb/SchemaBindingBuilder.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxb/SchemaBindingBuilder.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -298,6 +298,20 @@
if (log.isTraceEnabled())
log.trace("Bound element " + xmlName + " to property " + prop.getName());
}
+
+ // XOP elements that derive from xmlmime namespace
+ // need to be declared 'simple' in order for XB to
+ // treat them as simple base64Binaries.
+ QName elementType = element.getType().getQName();
+ if(elementType!=null)
+ {
+ String elementTypeNS = elementType.getNamespaceURI() != null ? elementType.getNamespaceURI() : "";
+ String elementTypeName = elementType.getLocalPart() != null ? elementType.getLocalPart() : "";
+ if(elementTypeNS.equals(Constants.NS_XML_MIME) && elementTypeName.equals("base64Binary"))
+ {
+ element.getType().setSimple(true);
+ }
+ }
}
private void processWildcard(TypeBinding typeBinding, VariableMapping varMapping)
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/StubExt.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/StubExt.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/StubExt.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -56,6 +56,8 @@
static final String PROPERTY_AUTH_TYPE_BASIC = "org.jboss.ws.authType.basic";
/** Authentication type, WSEE */
static final String PROPERTY_AUTH_TYPE_WSSE = "org.jboss.ws.authType.wsse";
+ /** MTOM enabled? */
+ static final String PROPERTY_MTOM_ENABLED= "org.jboss.ws.mtom.enabled";
// if you add a property here, make sure its registered in CallProxy
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBSerializer.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBSerializer.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/jaxrpc/encoding/JAXBSerializer.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -113,6 +113,7 @@
}
catch (RuntimeException e)
{
+ log.error("", e);
throw e;
}
catch (Exception e)
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/NodeImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/NodeImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/NodeImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -264,7 +264,7 @@
}
catch (SOAPException ex)
{
- throw new DOMException(DOMException.INVALID_STATE_ERR, "Could not convert a document fragment to a node");
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "Could not readFrom a document fragment to a node");
}
return list;
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -26,7 +26,7 @@
import org.jboss.util.xml.DOMWriter;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
-import org.jboss.ws.xop.XOPUnmarshallerImpl;
+import org.jboss.ws.xop.XOPContext;
import org.jboss.ws.binding.BindingException;
import org.jboss.ws.jaxrpc.TypeMappingImpl;
import org.jboss.ws.jaxrpc.encoding.*;
@@ -45,7 +45,6 @@
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Iterator;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Writer;
@@ -148,7 +147,7 @@
SerializerSupport ser;
if (objectValue != null)
- {
+ {
SerializerFactoryBase serializerFactory = getSerializerFactory(typeMapping, javaType, xmlType);
ser = (SerializerSupport)serializerFactory.getSerializer();
}
@@ -159,7 +158,7 @@
addNamespaceDeclaration(Constants.PREFIX_XSI, Constants.NS_SCHEMA_XSI);
}
- xmlFragment = ser.serialize(xmlName, xmlType, objectValue, serContext, null);
+ xmlFragment = ser.serialize(xmlName, xmlType, getObjectValue(), serContext, null);
// Add the arrayType namespace declaration
QName compXmlType = paramMetaData.getSOAPArrayCompType();
@@ -281,11 +280,11 @@
Object convertedObj = null;
if(obj instanceof DataHandler)
{
- MimeUtils utils = new MimeUtils();
- MimeUtils.ByteArrayConverter converter = utils.getConverterFor(javaType);
+ // converter for the expected target java type
+ MimeUtils.ByteArrayConverter converter = MimeUtils.getConverterFor(javaType);
try
{
- convertedObj = converter.convert( ((DataHandler)obj).getInputStream() );
+ convertedObj = converter.readFrom( ((DataHandler)obj).getInputStream() );
}
catch (IOException e)
{
@@ -977,7 +976,9 @@
public String write(Writer writer, boolean pretty) {
try
- {
+ {
+ handleMTOMTransitions();
+
if(isDOMValid)
{
DOMWriter dw = new DOMWriter(writer);
@@ -994,9 +995,31 @@
}
catch (Exception e)
{
- log.error(e);
+ log.error("Failed to write SOAPContentElement ", e);
}
return null;
- }
+ }
+
+ private void handleMTOMTransitions() {
+
+ boolean isXOPParameter = paramMetaData != null && paramMetaData.isXOP();
+ boolean mtomEnabled = isXOPParameter && XOPContext.isMTOMEnabled();
+
+ if( mtomEnabled == false )
+ {
+ // If MTOM is disabled, we force dom expansion.
+ // This will inline any XOP include element
+ // and remove the attachment part when transitioning.
+ // See SOAPFactoryImpl for details.
+ expandToDOM();
+ }
+ else if(isDOMValid && mtomEnabled )
+ {
+ // When the DOM representation is valid,
+ // but MTOM is enabled we need to convert the inlined
+ // element back to an xop:Include element and create the attachment part
+ XOPContext.optimizeXOPData(this);
+ }
+ }
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPEnvelopeImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPEnvelopeImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPEnvelopeImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -56,6 +56,8 @@
// Reference the enclosing SOAPPart, so that getOwnerDocument() works correctly
private SOAPPartImpl soapPart;
+ private boolean domExpansionEnabled = false;
+
// A registry of namespaces in this envelope
private NamespaceRegistry namespaceRegistry = new NamespaceRegistry();
@@ -192,16 +194,15 @@
{
return soapPart;
}
-
- /*public String getNamespaceURI(String prefix)
- {
- String nsURI = getAttribute("xmlns:" + prefix);
- if (nsURI.length() == 0 && namespaceRegistry != null)
- return namespaceRegistry.getNamespaceURI(prefix);
- return (nsURI.length() > 0 ? nsURI : null);
- }*/
+ public boolean isDomExpansionEnabled() {
+ return domExpansionEnabled;
+ }
+ public void setDomExpansionEnabled(boolean domExpansionEnabled) {
+ this.domExpansionEnabled = domExpansionEnabled;
+ }
+
public String write(Writer writer, boolean pretty) {
try
{
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPFactoryImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPFactoryImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPFactoryImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -31,6 +31,8 @@
import org.jboss.logging.Logger;
import org.jboss.util.xml.DOMUtils;
+import org.jboss.ws.Constants;
+import org.jboss.ws.xop.XOPContext;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -69,8 +71,8 @@
throw new IllegalArgumentException("Source node cannot be null");
String localName = domNode.getLocalName();
- String prefix = domNode.getPrefix();
- String nsURI = domNode.getNamespaceURI();
+ String prefix = domNode.getPrefix() != null ? domNode.getPrefix() : "";
+ String nsURI = domNode.getNamespaceURI() != null ? domNode.getNamespaceURI() : "";
SOAPElementImpl soapElement = new SOAPElementImpl(localName, prefix, nsURI);
@@ -89,6 +91,13 @@
{
SOAPElementImpl soapChild = createElement((Element)child, true);
soapElement.addChildElement(soapChild);
+
+ String ns = soapChild.getNamespaceURI() != null ? soapChild.getNamespaceURI() : "";
+ String name = soapChild.getLocalName();
+ if(ns.equals(Constants.NS_XOP) && name.equals("Include"))
+ {
+ XOPContext.inlineXOPData(soapElement);
+ }
}
else if (nodeType == Node.TEXT_NODE)
{
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPHeaderImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPHeaderImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPHeaderImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -59,7 +59,7 @@
SOAPElementImpl element = (SOAPElementImpl) node;
- // convert to SOAPHeaderElement
+ // readFrom to SOAPHeaderElement
element.detachNode();
return new SOAPHeaderElementImpl(element);
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -24,6 +24,7 @@
// $Id$
import org.jboss.ws.WSException;
+import org.jboss.ws.xop.XOPContext;
import org.jboss.ws.metadata.EndpointMetaData;
import org.jboss.ws.metadata.OperationMetaData;
import org.jboss.ws.soap.attachment.*;
@@ -108,6 +109,21 @@
return null;
}
+ public AttachmentPart removeAttachmentByContentId(String cid)
+ {
+ for (AttachmentPart part : attachments)
+ {
+ String contentId = part.getContentId();
+ if (contentId.equals(cid))
+ {
+ attachments.remove(part);
+ return part;
+ }
+ }
+
+ return null;
+ }
+
public AttachmentPart getAttachmentByPartName(String partName)
{
for (AttachmentPart part : attachments)
@@ -186,7 +202,7 @@
try
{
String contentType;
- if (isXOPMessage())
+ if (isXOPMessage() && XOPContext.isMTOMEnabled())
{
multipartRelatedEncoder = new MultipartRelatedXOPEncoder(this);
multipartRelatedEncoder.encodeMultipartRelatedMessage();
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/attachment/ByteArrayContentHandler.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/attachment/ByteArrayContentHandler.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/soap/attachment/ByteArrayContentHandler.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -21,17 +21,17 @@
*/
package org.jboss.ws.soap.attachment;
-import org.jboss.ws.WSException;
+import org.jboss.ws.utils.MimeUtils;
+import javax.activation.ActivationDataFlavor;
import javax.activation.DataContentHandler;
import javax.activation.DataSource;
-import javax.activation.ActivationDataFlavor;
-import javax.xml.transform.stream.StreamSource;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.ByteArrayInputStream;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.UnsupportedFlavorException;
/**
* @author Heiko Braun <heiko.braun at jboss.com>
@@ -58,6 +58,7 @@
}
public void writeTo(Object object, String string, OutputStream outputStream) throws IOException {
- throw new WSException("The current implementation is read-only");
+ MimeUtils.ByteArrayConverter converter = MimeUtils.getConverterFor(object.getClass());
+ converter.writeTo(object, outputStream);
}
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -228,7 +228,7 @@
}
/**
- * Given a domain name split it into the corresponding parts, and convert
+ * Given a domain name split it into the corresponding parts, and readFrom
* into the order suitable for creating a package name.
*
* The transposition is only performed if the last element is a top level domain
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -36,7 +36,6 @@
import org.apache.xerces.xs.XSComplexTypeDefinition;
import org.apache.xerces.xs.XSElementDeclaration;
import org.apache.xerces.xs.XSModelGroup;
-import org.apache.xerces.xs.XSObject;
import org.apache.xerces.xs.XSObjectList;
import org.apache.xerces.xs.XSParticle;
import org.apache.xerces.xs.XSSimpleTypeDefinition;
@@ -195,7 +194,7 @@
*/
public void setPackageNamespaceMap(Map<String, String> map)
{
- //Lets convert the package->namespace map to namespace->package map
+ //Lets readFrom the package->namespace map to namespace->package map
Set keys = map.keySet();
Iterator<String> iter = keys.iterator();
while(iter != null && iter.hasNext())
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/IOUtils.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/IOUtils.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/IOUtils.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -21,16 +21,13 @@
*/
package org.jboss.ws.utils;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
+import java.io.*;
import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import javax.activation.DataHandler;
+
/**
* IO utilites
*
@@ -62,4 +59,18 @@
r = ins.read(bytes);
}
}
+
+ public static byte[] convertToBytes(DataHandler dh)
+ {
+ try
+ {
+ ByteArrayOutputStream buffOS= new ByteArrayOutputStream();
+ dh.writeTo(buffOS);
+ return buffOS.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Unable to convert DataHandler to byte[]: " + e.getMessage());
+ }
+ }
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/JavaUtils.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/JavaUtils.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/JavaUtils.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -27,7 +27,6 @@
import java.util.HashMap;
import org.jboss.logging.Logger;
-import org.jboss.ws.metadata.wsdl.WSDLUtils;
/** Java utilities
*
@@ -391,7 +390,7 @@
public static String convertJVMNameToSourceName(String typeName, ClassLoader loader)
{
- // TODO Don't use a ClassLoader for this, we need to just convert it
+ // TODO Don't use a ClassLoader for this, we need to just readFrom it
try
{
Class javaType = loadJavaType(typeName, loader);
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/MimeUtils.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/MimeUtils.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/MimeUtils.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -27,6 +27,7 @@
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
import org.jboss.ws.Constants;
import javax.mail.internet.ContentType;
@@ -34,8 +35,13 @@
import javax.mail.internet.ParseException;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.Source;
import java.awt.image.BufferedImage;
+import java.awt.*;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -66,7 +72,7 @@
/**
* Converts a MIME type into a proprietary JBossWS attachment xml type.
*
- * @param mimeType the MIME type string to convert
+ * @param mimeType the MIME type string to readFrom
* @return the xml type that this mime type corresponds to
*/
public static QName convertMimeTypeToXmlType(String mimeType)
@@ -169,25 +175,27 @@
return mimeType;
}
- public ByteArrayConverter getConverterFor(Class targetClazz)
+ public static ByteArrayConverter getConverterFor(Class targetClazz)
{
ByteArrayConverter converter = null;
- if(JavaUtils.isAssignableFrom(targetClazz, java.awt.Image.class))
+ if(JavaUtils.isAssignableFrom(java.awt.Image.class, targetClazz))
converter = new ImageConverter();
- else if (JavaUtils.isAssignableFrom(targetClazz, javax.xml.transform.Source.class))
+ else if (JavaUtils.isAssignableFrom(javax.xml.transform.Source.class, targetClazz))
converter = new SourceConverter();
- else if (JavaUtils.isAssignableFrom(targetClazz, java.lang.String.class))
+ else if (JavaUtils.isAssignableFrom(java.lang.String.class, targetClazz))
converter = new StringConverter();
+ else if (JavaUtils.isAssignableFrom(java.io.InputStream.class, targetClazz))
+ converter = new StreamConverter();
if(null == converter)
- throw new IllegalArgumentException("Unable to resolve conversion strategy for: " + targetClazz);
+ throw new IllegalArgumentException("No ByteArrayConverter for : " + targetClazz.getName());
return converter;
}
- public class ImageConverter implements ByteArrayConverter
+ public static class ImageConverter implements ByteArrayConverter
{
- public Object convert(InputStream in) {
+ public Object readFrom(InputStream in) throws IOException {
Object converted = null;
try
{
@@ -203,11 +211,24 @@
return converted;
}
+ public void writeTo(Object obj, OutputStream out) throws IOException {
+ if(obj instanceof BufferedImage)
+ {
+ JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(out);
+ enc.encode((BufferedImage)obj);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unable to convert " + obj.getClass());
+ }
+
+ }
+
}
- public class SourceConverter implements ByteArrayConverter
+ public static class SourceConverter implements ByteArrayConverter
{
- public Object convert(InputStream in) {
+ public Object readFrom(InputStream in) throws IOException {
Object converted = null;
try
@@ -221,11 +242,23 @@
return converted;
}
+
+ public void writeTo(Object obj, OutputStream out) throws IOException {
+ if(obj instanceof StreamSource)
+ {
+ StreamSource s = (StreamSource)obj;
+ IOUtils.copyStream(out, s.getInputStream());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unable to convert " + obj.getClass());
+ }
+ }
}
- public class StringConverter implements ByteArrayConverter
+ public static class StringConverter implements ByteArrayConverter
{
- public Object convert(InputStream in) {
+ public Object readFrom(InputStream in) throws IOException {
Object converted = null;
try
{
@@ -243,11 +276,37 @@
return converted;
}
+
+ public void writeTo(Object obj, OutputStream out) throws IOException {
+ if(obj instanceof String)
+ {
+ String s = (String)obj;
+ out.write(s.getBytes("UTF-8"));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unable to convert " + obj.getClass());
+ }
+ }
}
+ public static class StreamConverter implements ByteArrayConverter
+ {
+ public Object readFrom(InputStream in) throws IOException {
+ return in;
+ }
+
+ public void writeTo(Object obj, OutputStream out) throws IOException {
+ if(obj instanceof InputStream)
+ {
+ IOUtils.copyStream(out, (InputStream)obj);
+ }
+ }
+ }
public interface ByteArrayConverter
{
- Object convert(InputStream in);
+ Object readFrom(InputStream in) throws IOException;
+ void writeTo(Object obj, OutputStream out) throws IOException;
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -29,17 +29,6 @@
*/
private static InheritableThreadLocal<SecurityStore> strTransformAssoc = new InheritableThreadLocal<SecurityStore>();
- /**
- * Stores XOP callee information
- * @see org.jboss.ws.xop.XOPContext#doInlineBase64
- */
- private static ThreadLocal<Boolean> XOPInlineAssoc = new ThreadLocal<Boolean>()
- {
- protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
-
private static ThreadLocal<Boolean> DOMExpansionAssoc = new ThreadLocal<Boolean>()
{
protected Boolean initialValue() {
@@ -59,11 +48,6 @@
return strTransformAssoc;
}
- public static ThreadLocal<Boolean> localXOPCalleeAssoc()
- {
- return XOPInlineAssoc;
- }
-
public static ThreadLocal<Boolean> localDomExpansion()
{
return DOMExpansionAssoc;
@@ -72,8 +56,7 @@
public static void clear() {
invokerMDBAssoc.set(null);
msgContextAssoc.set(null);
- strTransformAssoc.set(null);
- XOPInlineAssoc.set(Boolean.FALSE);
+ strTransformAssoc.set(null);
DOMExpansionAssoc.set(Boolean.FALSE);
}
}
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/DecodingOperation.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/DecodingOperation.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/DecodingOperation.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -28,7 +28,7 @@
/**
* <code>DecodingOperation</code> represents an operation that is applied to a
- * WS-Security encoded message to both convert and verify the contents of the
+ * WS-Security encoded message to both readFrom and verify the contents of the
* message.
*
* @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/TokenOperation.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/TokenOperation.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/wsse/TokenOperation.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -26,7 +26,7 @@
/**
* <code>DecodingOperation</code> represents an operation that is applied to a
- * WS-Security encoded message to both convert and verify the contents of the
+ * WS-Security encoded message to both readFrom and verify the contents of the
* message.
*
* @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPContext.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPContext.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPContext.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -22,17 +22,26 @@
package org.jboss.ws.xop;
import org.jboss.util.xml.DOMUtils;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.jaxrpc.StubExt;
import org.jboss.ws.soap.MessageContextAssociation;
import org.jboss.ws.soap.SOAPMessageContextImpl;
import org.jboss.ws.soap.SOAPMessageImpl;
+import org.jboss.ws.soap.NameImpl;
import org.jboss.ws.utils.ThreadLocalAssociation;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
+import org.jboss.xb.binding.sunday.xop.XOPObject;
import org.jboss.xb.binding.sunday.xop.XOPUnmarshaller;
-import org.jboss.xb.binding.SimpleTypeBindings;
-import org.w3c.dom.Element;
-import javax.xml.soap.SOAPElement;
import javax.activation.DataHandler;
import javax.activation.DataSource;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.namespace.QName;
+import java.io.ByteArrayOutputStream;
import java.util.Iterator;
/**
@@ -47,6 +56,7 @@
public class XOPContext {
public static final String CID_PREFIX = "cid:";
+ private static final String NS_XOP_JBOSSWS = "http://org.jboss.ws/xop";
public static boolean isXOPPackage() {
boolean isXOP = false;
@@ -59,34 +69,20 @@
}
/**
- * Force inline representation.
+ * Check if MTOM is disabled through a message context property.
+ * (<code>org.jboss.ws.mtom.enabled</code>)
+ * Defaults to TRUE if the property is not set.
*/
- public static void setInlineBase64()
+ public static boolean isMTOMEnabled()
{
- ThreadLocalAssociation.localXOPCalleeAssoc().set(Boolean.TRUE);
+ SOAPMessageContextImpl msgContext = MessageContextAssociation.peekMessageContext();
+ boolean mtomEnabled = msgContext.getProperty(StubExt.PROPERTY_MTOM_ENABLED) == null ?
+ true :
+ ((String)msgContext.getProperty(StubExt.PROPERTY_MTOM_ENABLED)).equalsIgnoreCase("true");
+ return mtomEnabled;
}
/**
- * Unset inline representation flag.
- */
- public static void unsetInlineBase64()
- {
- ThreadLocalAssociation.localXOPCalleeAssoc().set(Boolean.FALSE);
- }
-
- /**
- * Should the current message be inlined?
- * An inlined message contains the base64 representation instead
- * if the <code>xop:Include</code> element.
- */
- public static boolean doInlineBase64()
- {
- Boolean b = ThreadLocalAssociation.localXOPCalleeAssoc().get() != null ?
- ThreadLocalAssociation.localXOPCalleeAssoc().get():Boolean.FALSE;
- return b.booleanValue();
- }
-
- /**
* Replace all <code>xop:Include</code> elements with it's base64 representation
*/
public static void inlineXOPData(SOAPElement xopElement)
@@ -97,7 +93,7 @@
SOAPElement childElement = (SOAPElement)it.next();
String ns = childElement.getNamespaceURI()!=null ? childElement.getNamespaceURI(): "";
String localName = childElement.getLocalName();
- if(ns.equals("http://www.w3.org/2004/08/xop/include") && localName.equals("Include"))
+ if(ns.equals(Constants.NS_XOP) && localName.equals("Include"))
{
replaceXOPInclude(xopElement, childElement);
}
@@ -108,23 +104,113 @@
}
}
+ public static void optimizeXOPData(SOAPElement xopElement)
+ {
+ String contentType = xopElement.getAttributeNS(NS_XOP_JBOSSWS, "content-type");
+ if(contentType != null && contentType.length()>0)
+ {
+ createXOPInclude(xopElement, contentType);
+ xopElement.removeAttribute(new NameImpl(new QName(NS_XOP_JBOSSWS, "content-type")));
+ }
+ else
+ {
+ Iterator it = DOMUtils.getChildElements(xopElement);
+ while(it.hasNext())
+ {
+ SOAPElement childElement = (SOAPElement)it.next();
+ optimizeXOPData(childElement);
+ }
+ }
+ }
+
+ private static void createXOPInclude(SOAPElement xopElement, String contentType) {
+
+ String base64 = xopElement.getValue();
+ byte[] data = SimpleTypeBindings.unmarshalBase64(base64);
+ XOPObject xopObject = new XOPObject(data);
+ xopObject.setContentType(contentType);
+
+ XOPMarshaller xopMarshaller = new XOPMarshallerImpl();
+ String cid = xopMarshaller.addMtomAttachment(xopObject, xopElement.getNamespaceURI(), xopElement.getLocalName());
+
+ // remove base64 node with the xop:Include element
+ org.w3c.dom.Node child = (org.w3c.dom.Node)xopElement.getFirstChild();
+ xopElement.removeChild(child);
+
+ try
+ {
+ SOAPElement xopInclude = xopElement.addChildElement("Include", "xop", Constants.NS_XOP);
+ xopInclude.setAttribute("href", cid);
+ }
+ catch (SOAPException e)
+ {
+ throw new WSException("Failed to create XOP include element", e);
+ }
+
+ }
+
private static void replaceXOPInclude(SOAPElement parent, SOAPElement child)
{
String cid = child.getAttribute("href");
- if(cid!=null)
+
+ XOPUnmarshaller unm = new XOPUnmarshallerImpl();
+ byte[] data;
+ String contentType;
+
+ try
{
- XOPUnmarshaller unm = new XOPUnmarshallerImpl();
- byte[] data = unm.getAttachmentAsByteArray(cid);
- String base64 = SimpleTypeBindings.marshalBase64(data);
- parent.removeChild(child);
- parent.setValue(base64);
+ AttachmentPart part = XOPContext.getAttachmentByCID(cid);
+ DataHandler dh = part.getDataHandler();
+ contentType = dh.getContentType();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ dh.writeTo(bout);
+ data = bout.toByteArray();
}
+ catch (Exception e)
+ {
+ throw new WSException("Failed to inline XOP data", e);
+ }
+
+ // create base64 contents
+ String base64 = SimpleTypeBindings.marshalBase64(data);
+ parent.removeChild(child);
+ parent.setValue(base64);
+ parent.setAttributeNS(NS_XOP_JBOSSWS, "content-type", contentType);
+
+ // cleanup the attachment part
+ SOAPMessageContextImpl msgContext = (SOAPMessageContextImpl)MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getMessage();
+
+ if(cid.startsWith("cid:")) cid = cid.substring(4);
+ cid = '<'+cid+'>';
+
+ AttachmentPart removedPart = soapMessage.removeAttachmentByContentId(cid);
+ if(null == removedPart)
+ throw new WSException("Unable to remove attachment part for cid " + cid);
+
}
+ public static AttachmentPart getAttachmentByCID(String cid) throws SOAPException
+ {
+ 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+'>';
+
+ AttachmentPart part = soapMessage.getAttachmentByContentId(cid);
+ if (part == null)
+ throw new WSException("Cannot find attachment part for: " + cid);
+
+ return part;
+ }
+
public static DataHandler getDataHandler(Object o)
{
DataHandler dataHandler;
- // todo: contentType
+
if(o instanceof java.awt.Image)
{
dataHandler = new DataHandler(o, "image/jpeg");
@@ -139,7 +225,7 @@
}
else if(o instanceof DataHandler)
{
- dataHandler = (DataHandler)o;//new DataHandler(o, "application/octet-stream");
+ dataHandler = (DataHandler)o;
}
else
{
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -28,6 +28,7 @@
import org.jboss.ws.soap.SOAPMessageImpl;
import org.jboss.ws.soap.attachment.MimeConstants;
import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
+import org.jboss.ws.jaxrpc.StubExt;
import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
import org.jboss.xb.binding.sunday.xop.XOPObject;
@@ -35,6 +36,7 @@
import javax.activation.DataSource;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
+import javax.xml.rpc.handler.MessageContext;
/**
* The XOPMarshallerImpl allows callbacks from the binding layer towards the
@@ -57,7 +59,7 @@
// Load JAF content handlers
ContentHandlerRegistry.register();
}
-
+
public boolean isXOPPackage()
{
return XOPContext.isXOPPackage();
@@ -66,17 +68,17 @@
public String addMtomAttachment(XOPObject obj, String elementNamespace, String elementName)
{
+ SOAPMessageContextImpl msgContext = (SOAPMessageContextImpl)MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getMessage();
+
QName xmlName = new QName(elementNamespace, elementName);
log.debug("serialize: [xmlName=" + xmlName + "]");
- SOAPMessageContextImpl msgContext = (SOAPMessageContextImpl)MessageContextAssociation.peekMessageContext();
- SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getMessage();
-
String cid = soapMessage.getCidGenerator().generateFromName(xmlName.getLocalPart());
DataHandler dataHandler = XOPContext.getDataHandler(obj.getContent());
obj.setContentType(dataHandler.getContentType());
-
+
AttachmentPart xopPart = soapMessage.createAttachmentPart(dataHandler);
xopPart.addMimeHeader(MimeConstants.CONTENT_ID, '<'+cid+'>'); // RFC2392 requirement
soapMessage.addAttachmentPart(xopPart);
Modified: branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -68,7 +68,7 @@
{
try
{
- AttachmentPart part = getAttachementByCID(cid);
+ AttachmentPart part = XOPContext.getAttachmentByCID(cid);
// Let JAF do the conversion
Object content = part.getDataHandler().getContent();
@@ -100,7 +100,7 @@
{
try
{
- AttachmentPart part = getAttachementByCID(cid);
+ AttachmentPart part = XOPContext.getAttachmentByCID(cid);
DataHandler dh = part.getDataHandler();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
dh.writeTo(bout);
@@ -117,20 +117,4 @@
}
}
-
- private AttachmentPart getAttachementByCID(String cid) throws SOAPException
- {
- 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+'>';
-
- AttachmentPart part = soapMessage.getAttachmentByContentId(cid);
- if (part == null)
- throw new WSException("Cannot find attachment part for: " + cid);
-
- return part;
- }
}
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/addressing/SOAPAddressingPropertiesTestCase.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/addressing/SOAPAddressingPropertiesTestCase.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/addressing/SOAPAddressingPropertiesTestCase.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -37,6 +37,9 @@
import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
import org.jboss.test.ws.JBossWSTest;
+import org.jboss.ws.soap.SAAJElementWriter;
+import org.jboss.ws.soap.SOAPElementImpl;
+import org.jboss.ws.utils.ThreadLocalAssociation;
/**
* Test the SOAPAddressingProperties
@@ -44,26 +47,26 @@
* @author Thomas.Diesler at jboss.org
* @since 13-Nov-2005
*/
-public class SOAPAddressingPropertiesTestCase extends JBossWSTest
+public class SOAPAddressingPropertiesTestCase extends JBossWSTest
{
private SOAPAddressingProperties addrProps;
-
- private String reqEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>"
- + " <env:Header xmlns:wsa='http://www.w3.org/2005/08/addressing'>"
+
+ private String reqEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>"
+ + " <env:Header xmlns:wsa='http://www.w3.org/2005/08/addressing'>"
+ " <wsa:To>http://fabrikam123.example/Purchasing</wsa:To>"
- + " <wsa:ReplyTo>"
- + " <wsa:Address>http://business456.example/client1</wsa:Address>"
- + " <wsa:ReferenceParameters>"
- + " <ns1:sessionid xmlns:ns1='http://somens'>someuniqueid</ns1:sessionid>"
- + " </wsa:ReferenceParameters>"
- + " </wsa:ReplyTo>"
+ + " <wsa:ReplyTo>"
+ + " <wsa:Address>http://business456.example/client1</wsa:Address>"
+ + " <wsa:ReferenceParameters>"
+ + " <ns1:sessionid xmlns:ns1='http://somens'>someuniqueid</ns1:sessionid>"
+ + " </wsa:ReferenceParameters>"
+ + " </wsa:ReplyTo>"
+ " <wsa:Action>http://fabrikam123.example/SubmitPO</wsa:Action>"
+ " <wsa:MessageID>uuid:6B29FC40-CA47-1067-B31D-00DD010662DA</wsa:MessageID>"
- + " </env:Header>"
- + " <env:Body/>"
+ + " </env:Header>"
+ + " <env:Body/>"
+ "</env:Envelope>";
- private String resEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ private String resEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <env:Header xmlns:wsa='http://www.w3.org/2005/08/addressing'>" +
" <wsa:To>http://business456.example/client1</wsa:To>" +
" <wsa:Action>http://fabrikam123.example/ReplyPO</wsa:Action>" +
@@ -76,16 +79,18 @@
public void setUp() throws Exception
{
super.setUp();
-
+
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(reqEnvStr.getBytes()));
AddressingBuilder addrBuilder = SOAPAddressingBuilder.getAddressingBuilder();
addrProps = (SOAPAddressingProperties)addrBuilder.newAddressingProperties();
addrProps.readHeaders(soapMessage);
+
+ ThreadLocalAssociation.localDomExpansion().set(Boolean.TRUE);
}
-
- public void testReadHeaders() throws Exception
+
+ public void testReadHeaders() throws Exception
{
assertEquals(new URI("uuid:6B29FC40-CA47-1067-B31D-00DD010662DA"), addrProps.getMessageID().getURI());
assertEquals(new URI("http://business456.example/client1"), addrProps.getReplyTo().getAddress().getURI());
@@ -111,7 +116,7 @@
SOAPAddressingProperties replyProps = (SOAPAddressingProperties)addrBuilder.newAddressingProperties();
replyProps.initializeAsReply(addrProps, false);
replyProps.setAction(addrBuilder.newURI("http://fabrikam123.example/ReplyPO"));
-
+
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapMessage = factory.createMessage();
replyProps.writeHeaders(soapMessage);
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/jbws801/JBWS801TestCase.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/jbws801/JBWS801TestCase.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/jbws801/JBWS801TestCase.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -47,6 +47,7 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
+import org.jboss.ws.utils.ThreadLocalAssociation;
public class JBWS801TestCase extends JBossWSTest
{
@@ -60,6 +61,10 @@
return JBossWSTestSetup.newTestSetup(JBWS801TestCase.class, "jbossws-jbws801.war");
}
+ protected void setUp() throws Exception {
+ ThreadLocalAssociation.localDomExpansion().set(Boolean.TRUE);
+ }
+
public void testLargeFile() throws Exception
{
long size = 6L * 1024L * 1024L;
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/dynamichandler/DynamicHandlerTestCase.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/dynamichandler/DynamicHandlerTestCase.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/dynamichandler/DynamicHandlerTestCase.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -69,7 +69,7 @@
endpoint = (HandlerTestService)service.getPort(HandlerTestService.class);
}
- ((Stub)endpoint)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8081/jbossws-samples-dynamichandler");
+ //((Stub)endpoint)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8081/jbossws-samples-dynamichandler");
}
public void testStaticHandlers() throws Exception
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/samples/mtom/XOPRpcTestCase.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -84,33 +84,6 @@
//((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://" + getServerHost() + ":8081/jbossws-samples-mtom");
}
- /** Send a multipart message with a image/gif attachment part
- */
- /*public void testSendMimeImageGIF() throws Exception
- {
- URL url = new File("resources/samples/mtom/attach.gif").toURL();
-
- // On Linux the X11 server must be installed properly to create images successfully.
- // If the image cannot be created in the test VM, we assume it cannot be done on the
- // server either, so we just skip the test
- Image image = null;
- try
- {
- image = Toolkit.getDefaultToolkit().createImage(url);
- }
- catch (Throwable th)
- {
- //log.warn("Cannot create Image: " + th);
- }
-
- if (image != null)
- {
- Object value = port.sendMimeImageGIF("Some text message", new DataHandler(url));
- assertNotNull(value);
- assertTrue("Wrong return value type", value instanceof Image);
- }
- } */
-
/** Send unknown file that actually is converted into a DataHandler
*/
public void testSendOctets() throws Exception
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/InlineHandler.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/InlineHandler.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/InlineHandler.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -1,17 +1,16 @@
package org.jboss.test.ws.xop.doclit;
import org.jboss.logging.Logger;
-import org.jboss.util.xml.DOMWriter;
import org.jboss.ws.soap.NameImpl;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.GenericHandler;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPMessage;
+import java.io.ByteArrayOutputStream;
/**
* @author Heiko Braun <heiko.braun at jboss.com>
@@ -26,7 +25,7 @@
}
public boolean handleRequest(MessageContext messageContext) {
- //dumpMessage(messageContext);
+ dumpMessage(messageContext);
return true;
}
@@ -41,12 +40,9 @@
SOAPMessage soapMessage = ((SOAPMessageContext)messageContext).getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
- String msg = DOMWriter.printNode(soapBody, true);
- log.info(msg);
-
SOAPElement response = (SOAPElement) soapBody.getChildElements().next();
SOAPElement xopElement = (SOAPElement)response.getChildElements(new NameImpl("imagejpeg")).next();
- messageContext.setProperty("xop.expected", xopElement.getFirstChild().getNodeValue());
+ messageContext.setProperty("xop.inline.value", xopElement.getFirstChild().getNodeValue());
}
catch (Exception e)
{
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsg.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsg.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsg.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -7,17 +7,16 @@
package org.jboss.test.ws.xop.doclit;
-import java.awt.*;
-
-
public class PingMsg
{
protected String message;
- protected Image imagejpeg;
+ protected Object imagejpeg;
+ private Object _value;
+
public PingMsg(){}
- public PingMsg(String message, Image img){
+ public PingMsg(String message, Object img){
this.message=message;
this.imagejpeg = img;
}
@@ -26,11 +25,15 @@
public void setMessage(java.lang.String message){ this.message=message; }
- public Image getImagejpeg() {
+ public Object getImagejpeg() {
return imagejpeg;
}
- public void setImagejpeg(Image imagejpeg) {
+ public void setImagejpeg(Object imagejpeg) {
this.imagejpeg = imagejpeg;
}
+
+ public Object get_value() {
+ return this.imagejpeg;
+ }
}
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsgResponse.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsgResponse.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/PingMsgResponse.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -12,20 +12,20 @@
public class PingMsgResponse
{
- protected Image imagejpeg;
+ protected Object imagejpeg;
public PingMsgResponse(){
}
- public PingMsgResponse(Image image) {
+ public PingMsgResponse(Object image) {
this.imagejpeg = image;
}
- public Image getImagejpeg() {
+ public Object getImagejpeg() {
return imagejpeg;
}
- public void setImagejpeg(Image imagejpeg) {
+ public void setImagejpeg(Object imagejpeg) {
this.imagejpeg = imagejpeg;
}
}
Modified: branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/XOPElementDoclitTestCase.java
===================================================================
--- branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/XOPElementDoclitTestCase.java 2006-08-09 17:30:10 UTC (rev 719)
+++ branches/jbossws-1.0_Heiko/src/test/java/org/jboss/test/ws/xop/doclit/XOPElementDoclitTestCase.java 2006-08-10 10:51:21 UTC (rev 720)
@@ -27,14 +27,14 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.ws.jaxrpc.StubExt;
import javax.activation.DataHandler;
import javax.naming.InitialContext;
import javax.xml.rpc.Service;
import javax.xml.rpc.Stub;
import java.awt.*;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
+import java.io.*;
import java.net.URL;
/**
@@ -60,50 +60,61 @@
Service service = (Service)iniCtx.lookup("java:comp/env/service/TestService");
port = (TestService_PortType)service.getPort(TestService_PortType.class);
}
+
+ //((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8081/jbossws-xop-doclit");
}
- public void testPingMsg() throws Exception {
+ public void testPingMsgInlined() throws Exception {
+
URL url = new File("resources/samples/mtom/attach.jpeg").toURL();
- // On Linux the X11 server must be installed properly to create images successfully.
- // If the image cannot be created in the test VM, we assume it cannot be done on the
- // server either, so we just skip the test
- Image image = null;
- try
- {
- image = Toolkit.getDefaultToolkit().createImage(url);
- }
- catch (Throwable th)
- {
- //log.warn("Cannot create Image: " + th);
- }
+ DataHandler dh = new DataHandler(url);
+ PingMsgResponse value = port.ping(new PingMsg("Some text message", dh));
+ assertNotNull("Return value was null",value);
+ assertNotNull("Return image was null", value.getImagejpeg());
- if (image != null)
- {
- PingMsgResponse value = port.ping(new PingMsg("Some text message", image));
- assertNotNull("Return value was null",value);
- assertNotNull("Return image was null", value.getImagejpeg());
+ // check inline values
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ dh.writeTo(bout);
- // check inline values
+ byte[] imageBytes = bout.toByteArray();
+ String expected = SimpleTypeBindings.marshalBase64(imageBytes);
- System.out.println("FIXME: JBWS-660");
+ String was = (String)((Stub) port)._getProperty("xop.inline.value");
+ assertNotNull("base64 value not found", was);
+ //assertEquals(expected, was);
- /*
- DataHandler dh = new DataHandler(url);
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- dh.writeTo(bout);
+ System.out.println("FIXME: Compare base64 values");
+ }
- byte[] imageBytes = bout.toByteArray();
- String expected = SimpleTypeBindings.marshalBase64(imageBytes);
+ public void testMTOMDisabled() throws Exception {
- String was = (String)((Stub) port)._getProperty("xop.expected");
- assertNotNull("bas64 value not found", was);
- assertEquals(expected, was);
- */
- }
+ byte[] bytes = getBytesFromFile(new File("resources/samples/mtom/attach.jpeg"));
+ DataHandler dh = new DataHandler(new ByteArrayInputStream(bytes), "application/octet-stream");
- //System.out.println("FIXME: JBXB-62");
+ // force disable MTOM
+ ((Stub)port)._setProperty(StubExt.PROPERTY_MTOM_ENABLED, "false");
+ PingMsgResponse value = port.ping(new PingMsg("Some text message", dh));
+ assertNotNull("Return value was null",value);
+ assertNotNull("Return image was null", value.getImagejpeg());
}
+
+ public static byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+
+ long length = file.length();
+ byte[] bytes = new byte[(int)length];
+
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+
+ is.close();
+ return bytes;
+ }
}
More information about the jboss-svn-commits
mailing list