Author: alessio.soldano(a)jboss.com
Date: 2008-11-18 03:42:38 -0500 (Tue, 18 Nov 2008)
New Revision: 8747
Modified:
stack/native/branches/asoldano/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java
Log:
Rebuild message when not a message abstraction
Modified:
stack/native/branches/asoldano/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java
===================================================================
---
stack/native/branches/asoldano/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java 2008-11-18
08:40:52 UTC (rev 8746)
+++
stack/native/branches/asoldano/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java 2008-11-18
08:42:38 UTC (rev 8747)
@@ -23,16 +23,23 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.binding.SerializationContext;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.attachment.SwapableMemoryDataSource;
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.jboss.wsf.common.DOMUtils;
import org.jboss.xb.binding.NamespaceRegistry;
+import org.w3c.dom.Element;
import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext.Scope;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -122,15 +129,45 @@
public SOAPMessage getSOAPMessage()
{
if(message!=null && ((message instanceof SOAPMessage) == false))
- throw new UnsupportedOperationException("No SOAPMessage avilable. Current
message context carries " + message.getClass());
+ throw new UnsupportedOperationException("No SOAPMessage available. Current
message context carries " + message.getClass());
return (SOAPMessage)message;
}
public void setSOAPMessage(SOAPMessage soapMessage)
{
- this.message = (MessageAbstraction)soapMessage;
+ if (soapMessage instanceof MessageAbstraction)
+ {
+ this.message = (MessageAbstraction)soapMessage;
+ }
+ else
+ {
+ try
+ {
+ this.message = rebuild(soapMessage);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+
+ }
+// this.message = (MessageAbstraction)soapMessage;
this.setModified(true);
}
+
+ private static MessageAbstraction rebuild(SOAPMessage message) throws Exception
+ {
+ if (message == null)
+ return null;
+ //TODO!!!! do this better...
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ message.writeTo(baos);
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+ String mex = baos.toString("UTF-8");
+ System.out.println("REBUILDO!!!");
+ return (MessageAbstraction)factory.createMessage(message.getMimeHeaders(), new
ByteArrayInputStream(mex.getBytes("UTF-8")));
+ }
public MessageAbstraction getMessageAbstraction()
{