Author: thomas.diesler(a)jboss.com
Date: 2006-12-06 19:50:28 -0500 (Wed, 06 Dec 2006)
New Revision: 1589
Added:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBindingProvider.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP11Binding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP12Binding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAPBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
Removed:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonClient.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/BindingProviderImpl.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/HTTPBindingJAXWS.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/MessageBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/PayloadBinding.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP11BindingJAXWS.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP12BindingJAXWS.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/metadata/builder/MetaDataBuilder.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageContextAssociation.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/security/STRTransform.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/xop/XOPContext.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/binding/SOAPBindingTestCase.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/soap/attachment/GenericAttachmentTestCase.java
Log:
Deleted: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.metadata.umdm.OperationMetaData;
-import org.jboss.ws.core.soap.UnboundHeader;
-
-/**
- * The base interface for protocol bindings.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Jul-2006
- */
-public interface CommonBinding
-{
- /** On the client side, generate the Object from IN parameters. */
- Object bindRequestMessage(OperationMetaData opMetaData, EndpointInvocation epInv,
Map<QName, UnboundHeader> unboundHeaders) throws BindingException;
-
- /** On the server side, extract the IN parameters from the Object and populate an
Invocation object */
- EndpointInvocation unbindRequestMessage(OperationMetaData opMetaData, Object
reqMessage) throws BindingException;
-
- /** On the server side, generate the Object from OUT parameters in the Invocation
object. */
- Object bindResponseMessage(OperationMetaData opMetaData, EndpointInvocation epInv)
throws BindingException;
-
- /** On the client side, extract the OUT parameters from the Object and return them to
the client. */
- void unbindResponseMessage(OperationMetaData opMetaData, Object resMessage,
EndpointInvocation epInv, Map<QName, UnboundHeader> unboundHeaders) throws
BindingException;
-}
Deleted:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.jaxrpc.SOAP11BindingJAXRPC;
-import org.jboss.ws.core.jaxrpc.SOAP12BindingJAXRPC;
-import org.jboss.ws.core.jaxws.core.SOAP11BindingJAXWS;
-import org.jboss.ws.core.jaxws.core.SOAP12BindingJAXWS;
-import org.jboss.ws.core.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.core.metadata.umdm.EndpointMetaData.Type;
-
-/**
- * Provides access to the protocol binding.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Jul-2006
- */
-public class CommonBindingProvider
-{
- protected EndpointMetaData epMetaData;
- protected CommonBinding binding;
-
- public CommonBindingProvider(EndpointMetaData epMetaData)
- {
- this.epMetaData = epMetaData;
- initBinding(epMetaData.getBindingId(), epMetaData.getType());
- }
-
- public CommonBindingProvider(String bindingId, Type type)
- {
- initBinding(bindingId, type);
- }
-
- protected void initBinding(String bindingId, Type type)
- {
- if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId))
- {
- binding = (type == Type.JAXWS ? new SOAP11BindingJAXWS() : new
SOAP11BindingJAXRPC());
- }
- else if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId))
- {
- binding = (type == Type.JAXWS ? new SOAP12BindingJAXWS() : new
SOAP12BindingJAXRPC());
- }
- else
- {
- throw new WSException("Unsupported binding: " + bindingId);
- }
- }
-
- public CommonBinding getCommonBinding()
- {
- return binding;
- }
-}
Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonClient.java 2006-12-07
00:48:06 UTC (rev 1588)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonClient.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -37,6 +37,8 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.binding.CommonBinding;
+import org.jboss.ws.core.binding.CommonBindingProvider;
import org.jboss.ws.core.jaxrpc.ParameterWrapping;
import org.jboss.ws.core.jaxrpc.Style;
import org.jboss.ws.core.jaxrpc.handler.HandlerChainBaseImpl;
Deleted: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.ws.Constants;
-import org.jboss.ws.core.jaxrpc.Use;
-import org.jboss.ws.core.metadata.umdm.OperationMetaData;
-import org.jboss.ws.core.soap.MessageFactoryImpl;
-
-/**
- * The SOAP11Binding
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Jul-2006
- */
-public abstract class CommonSOAP11Binding extends CommonSOAPBinding
-{
- public CommonSOAP11Binding()
- {
- }
-
- /** Create the SOAP-1.1 message */
- protected SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException
- {
- MessageFactoryImpl factory = new MessageFactoryImpl();
- factory.setEnvelopeURI(Constants.NS_SOAP11_ENV);
- SOAPMessage soapMessage = factory.createMessage();
-
- Use encStyle = opMetaData.getEndpointMetaData().getEncodingStyle();
- if (Use.ENCODED.equals(encStyle))
- {
- SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
- soapEnvelope.addNamespaceDeclaration(Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
- }
-
- return soapMessage;
- }
-}
Deleted: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.ws.Constants;
-import org.jboss.ws.core.metadata.umdm.OperationMetaData;
-import org.jboss.ws.core.soap.MessageFactoryImpl;
-
-/**
- * The SOAP11Binding
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Jul-2006
- */
-public abstract class CommonSOAP12Binding extends CommonSOAPBinding
-{
-
- public CommonSOAP12Binding()
- {
- }
-
- /** Create the SOAP-1.1 message */
- protected SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException
- {
- MessageFactoryImpl factory = new MessageFactoryImpl();
- factory.setEnvelopeURI(Constants.NS_SOAP12_ENV);
- return factory.createMessage();
- }
-}
Deleted: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,906 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.ParameterMode;
-import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPBodyElement;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-
-import org.apache.xerces.xs.XSElementDeclaration;
-import org.apache.xerces.xs.XSTypeDefinition;
-import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.jaxrpc.ParameterWrapping;
-import org.jboss.ws.core.jaxrpc.StubExt;
-import org.jboss.ws.core.jaxrpc.Style;
-import org.jboss.ws.core.metadata.umdm.OperationMetaData;
-import org.jboss.ws.core.metadata.umdm.ParameterMetaData;
-import org.jboss.ws.core.metadata.umdm.TypesMetaData;
-import org.jboss.ws.core.soap.MessageContextAssociation;
-import org.jboss.ws.core.soap.MessageFactoryImpl;
-import org.jboss.ws.core.soap.NameImpl;
-import org.jboss.ws.core.soap.SOAPBodyElementDoc;
-import org.jboss.ws.core.soap.SOAPBodyElementRpc;
-import org.jboss.ws.core.soap.SOAPContentElement;
-import org.jboss.ws.core.soap.SOAPElementImpl;
-import org.jboss.ws.core.soap.SOAPFactoryImpl;
-import org.jboss.ws.core.soap.SOAPFaultImpl;
-import org.jboss.ws.core.soap.SOAPHeaderElementImpl;
-import org.jboss.ws.core.soap.SOAPMessageImpl;
-import org.jboss.ws.core.soap.UnboundHeader;
-import org.jboss.ws.core.soap.attachment.AttachmentPartImpl;
-import org.jboss.ws.core.soap.attachment.CIDGenerator;
-import org.jboss.ws.core.utils.DOMUtils;
-import org.jboss.ws.core.utils.JavaUtils;
-import org.jboss.ws.core.utils.MimeUtils;
-import org.jboss.ws.extras.xop.XOPContext;
-import org.jboss.xb.binding.NamespaceRegistry;
-import org.w3c.dom.Element;
-
-/**
- * The SOAPBinding interface is an abstraction for the SOAP binding.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Jul-2006
- */
-public abstract class CommonSOAPBinding implements CommonBinding
-{
- // provide logging
- private static Logger log = Logger.getLogger(CommonSOAPBinding.class);
-
- private boolean mtomEnabled;
-
- /** A constant representing the identity of the SOAP 1.2 over HTTP binding. */
- public static final String SOAP12HTTP_BINDING =
"http://www.w3.org/2003/05/soap/bindings/HTTP/";
-
- /** A constant representing the identity of the SOAP 1.1 over HTTP binding. */
- public static final String SOAP11HTTP_BINDING =
"http://schemas.xmlsoap.org/wsdl/soap/http";
- private static final Name SOAP_ARRAY_NAME = new NameImpl("Array",
Constants.PREFIX_SOAP11_ENC, Constants.URI_SOAP11_ENC);
-
- public CommonSOAPBinding()
- {
- }
-
- public MessageFactory getMessageFactory()
- {
- return new MessageFactoryImpl();
- }
-
- public SOAPFactory getSOAPFactory()
- {
- return new SOAPFactoryImpl();
- }
-
- public boolean isMTOMEnabled()
- {
- return mtomEnabled;
- }
-
- public void setMTOMEnabled(boolean flag)
- {
- this.mtomEnabled = flag;
- }
-
- /** Create the SOAP-1.1 message */
- protected abstract SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException;
-
- /** On the client side, generate the payload from IN parameters. */
- public Object bindRequestMessage(OperationMetaData opMetaData, EndpointInvocation
epInv, Map<QName, UnboundHeader> unboundHeaders) throws BindingException
- {
- log.debug("bindRequestMessage: " + opMetaData.getQName());
-
- try
- {
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext == null)
- throw new WSException("MessageContext not available");
-
- // Disable MTOM for rpc/encoded
- if (opMetaData.isRPCEncoded())
- msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
-
- // Associate current message with message context
- SOAPMessageImpl reqMessage = (SOAPMessageImpl)createMessage(opMetaData);
- msgContext.setSOAPMessage(reqMessage);
-
- SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
- SOAPBody soapBody = soapEnvelope.getBody();
- SOAPHeader soapHeader = soapEnvelope.getHeader();
-
- // Get the namespace registry
- NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
-
- Style style = opMetaData.getStyle();
- if (style == Style.RPC)
- {
- QName opQName = opMetaData.getQName();
- Name opName = new NameImpl(namespaceRegistry.registerQName(opQName));
-
- log.debug("Create RPC body element: " + opName);
- SOAPBodyElement soapBodyElement = new SOAPBodyElementRpc(opName);
-
-
- soapBodyElement =
(SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
-
- for (ParameterMetaData paramMetaData : opMetaData.getInputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- Object value = epInv.getRequestParamValue(xmlName);
-
- if (paramMetaData.isSwA())
- {
- CIDGenerator cidGenerator = reqMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
- reqMessage.addAttachmentPart(part);
- }
- else
- {
- SOAPElement soapElement = paramMetaData.isInHeader() ?
(SOAPElement)soapHeader : soapBodyElement;
- addParameterToMessage(paramMetaData, value, soapElement);
- }
- }
- }
- else if (style == Style.DOCUMENT)
- {
- for (ParameterMetaData paramMetaData : opMetaData.getInputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- Object value = epInv.getRequestParamValue(xmlName);
-
- if (paramMetaData.isSwA())
- {
- CIDGenerator cidGenerator = reqMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
- reqMessage.addAttachmentPart(part);
- }
- else
- {
- SOAPElement soapElement = paramMetaData.isInHeader() ?
(SOAPElement)soapHeader : soapBody;
- addParameterToMessage(paramMetaData, value, soapElement);
- }
- }
- }
- else
- {
- throw new WSException("Unsupported message style: " + style);
- }
-
- // Add unbound headers
- if (unboundHeaders != null)
- {
- Iterator it = unboundHeaders.values().iterator();
- while (it.hasNext())
- {
- UnboundHeader unboundHeader = (UnboundHeader)it.next();
- if (unboundHeader.getMode() != ParameterMode.OUT)
- {
- QName xmlName = unboundHeader.getXmlName();
- Object value = unboundHeader.getHeaderValue();
-
- xmlName = namespaceRegistry.registerQName(xmlName);
- Name soapName = new NameImpl(xmlName.getLocalPart(),
xmlName.getPrefix(), xmlName.getNamespaceURI());
-
- log.debug("Add unboundHeader element: " + soapName);
- SOAPContentElement contentElement = new
SOAPHeaderElementImpl(soapName);
-
contentElement.setParamMetaData(unboundHeader.toParameterMetaData(opMetaData));
- soapHeader.addChildElement(contentElement);
- contentElement.setObjectValue(value);
- }
- }
- }
-
- // Set the SOAPAction
- setSOAPActionHeader(opMetaData, reqMessage);
-
- return reqMessage;
- }
- catch (Exception e)
- {
- handleException(e);
- return null;
- }
- }
-
- /** Override to set the SOAPAction header */
- public abstract void setSOAPActionHeader(OperationMetaData opMetaData, SOAPMessage
reqMessage);
-
- /** On the server side, extract the IN parameters from the payload and populate an
Invocation object */
- public EndpointInvocation unbindRequestMessage(OperationMetaData opMetaData, Object
payload) throws BindingException
- {
- log.debug("unbindRequestMessage: " + opMetaData.getQName());
-
- try
- {
- // Read the SOAPEnvelope from the reqMessage
- SOAPMessage reqMessage = (SOAPMessage)payload;
- SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
- SOAPHeader soapHeader = soapEnvelope.getHeader();
- SOAPBody soapBody = soapEnvelope.getBody();
-
- // Verify the SOAP version
- verifySOAPVersion(opMetaData, soapEnvelope);
-
- // Construct the endpoint invocation object
- EndpointInvocation epInv = new EndpointInvocation(opMetaData);
-
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext == null)
- throw new WSException("MessageContext not available");
-
- // Disable MTOM for rpc/encoded
- if (opMetaData.isRPCEncoded())
- msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
-
- // Get the namespace registry
- NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
-
- if (opMetaData.isMessageEndpoint() == false)
- {
- Style style = opMetaData.getStyle();
- if (style == Style.RPC)
- {
- SOAPBodyElement soapBodyElement =
(SOAPBodyElement)soapBody.getChildElements().next();
- Name elName = soapBodyElement.getElementName();
-
- QName elQName = new QName(elName.getURI(), elName.getLocalName(),
elName.getPrefix());
- elQName = namespaceRegistry.registerQName(elQName);
-
- for (ParameterMetaData paramMetaData : opMetaData.getParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- if (paramMetaData.getMode() == ParameterMode.OUT)
- {
- epInv.setRequestParamValue(xmlName, null);
- }
- else
- {
- if (paramMetaData.isSwA())
- {
- Object value = getAttachmentFromMessage(paramMetaData,
reqMessage);
- epInv.setRequestParamValue(xmlName, value);
- }
- else
- {
- if (paramMetaData.isInHeader() == false)
- {
- Object value = getParameterFromMessage(paramMetaData,
soapBodyElement, false);
- epInv.setRequestParamValue(xmlName, value);
- }
- else
- {
- Object value = getParameterFromMessage(paramMetaData,
soapHeader, false);
- epInv.setRequestParamValue(xmlName, value);
- }
- }
- }
- }
- }
-
- // Document style
- else
- {
- for (ParameterMetaData paramMetaData : opMetaData.getParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- if (paramMetaData.isSwA())
- {
- Object value = getAttachmentFromMessage(paramMetaData, reqMessage);
- epInv.setRequestParamValue(xmlName, value);
- }
- else
- {
- if (paramMetaData.isInHeader())
- {
- if (paramMetaData.getMode() == ParameterMode.IN)
- {
- Object value = getParameterFromMessage(paramMetaData,
soapHeader, false);
- epInv.setRequestParamValue(xmlName, value);
- }
- else
- {
- Object value = getParameterFromMessage(paramMetaData,
soapHeader, true);
- epInv.setRequestParamValue(xmlName, value);
- }
- }
- else
- {
- Object value = getParameterFromMessage(paramMetaData, soapBody,
false);
- epInv.setRequestParamValue(xmlName, value);
- }
- }
- }
- }
- }
-
- // Generic message endpoint
- else
- {
- for (ParameterMetaData paramMetaData : opMetaData.getParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- Object value = soapBody.getChildElements().next();
- epInv.setRequestParamValue(xmlName, value);
- }
- }
-
- return epInv;
- }
- catch (Exception e)
- {
- handleException(e);
- return null;
- }
- }
-
- /** On the server side, generate the payload from OUT parameters. */
- public Object bindResponseMessage(OperationMetaData opMetaData, EndpointInvocation
epInv) throws BindingException
- {
- log.debug("bindResponseMessage: " + opMetaData.getQName());
-
- try
- {
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext == null)
- throw new WSException("MessageContext not available");
-
- // Disable MTOM for rpc/encoded
- if (opMetaData.isRPCEncoded())
- msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
-
- // Associate current message with message context
- SOAPMessageImpl resMessage = (SOAPMessageImpl)createMessage(opMetaData);
- msgContext.setSOAPMessage(resMessage);
-
- // R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response
that contains a SOAP envelope.
- // Specifically, the HTTP response entity-body must be empty.
- if (opMetaData.isOneWay())
- {
- resMessage.getSOAPPart().setContent(null);
- return resMessage;
- }
-
- SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
- SOAPHeader soapHeader = soapEnvelope.getHeader();
- SOAPBody soapBody = soapEnvelope.getBody();
-
- // Get the namespace registry
- NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
-
- Style style = opMetaData.getStyle();
- if (style == Style.RPC)
- {
- QName opQName = opMetaData.getResponseName();
-
- Name opName = new NameImpl(namespaceRegistry.registerQName(opQName));
- SOAPBodyElement soapBodyElement = new SOAPBodyElementRpc(opName);
-
- soapBodyElement =
(SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
-
- // Add the return to the message
- ParameterMetaData retMetaData = opMetaData.getReturnParameter();
- if (retMetaData != null)
- {
- Object value = epInv.getReturnValue();
- if (retMetaData.isSwA())
- {
- CIDGenerator cidGenerator = resMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
- resMessage.addAttachmentPart(part);
- epInv.setReturnValue(part);
- }
- else
- {
- SOAPContentElement soapElement = addParameterToMessage(retMetaData,
value, soapBodyElement);
- epInv.setReturnValue(soapElement);
- soapElement.setObjectValue(value);
- }
- }
-
- // Add the out parameters to the message
- for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- Object value = epInv.getResponseParamValue(xmlName);
- if (paramMetaData.isSwA())
- {
- CIDGenerator cidGenerator = resMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
- resMessage.addAttachmentPart(part);
- }
- else
- {
- if (paramMetaData.isInHeader())
- {
- addParameterToMessage(paramMetaData, value, soapHeader);
- }
- else
- {
- addParameterToMessage(paramMetaData, value, soapBodyElement);
- }
- }
- }
- }
- else if (style == Style.DOCUMENT)
- {
- ParameterMetaData retMetaData = opMetaData.getReturnParameter();
- if (retMetaData != null)
- {
- Object value = epInv.getReturnValue();
- if (opMetaData.isDocumentWrapped())
- value = ParameterWrapping.wrapResponseParameters(retMetaData, value,
epInv.getOutParameters());
-
- if (retMetaData.isSwA())
- {
- CIDGenerator cidGenerator = resMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
- resMessage.addAttachmentPart(part);
- epInv.setReturnValue(part);
- }
- else
- {
- SOAPContentElement soapElement = addParameterToMessage(retMetaData,
value, soapBody);
- epInv.setReturnValue(soapElement);
- }
- }
-
- // Add the out header parameters to the message
- for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- if (paramMetaData.isInHeader())
- {
- Object value = epInv.getResponseParamValue(xmlName);
- addParameterToMessage(paramMetaData, value, soapHeader);
- }
- }
- }
- else
- {
- throw new WSException("Unsupported message style: " + style);
- }
-
- return resMessage;
- }
- catch (Exception e)
- {
- handleException(e);
- return null;
- }
- }
-
- /** On the client side, extract the OUT parameters from the payload and return them to
the client. */
- public void unbindResponseMessage(OperationMetaData opMetaData, Object payload,
EndpointInvocation epInv, Map<QName, UnboundHeader> unboundHeaders)
- throws BindingException
- {
- log.debug("unbindResponseMessage: " + opMetaData.getQName());
-
- try
- {
- // R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response
that contains a SOAP envelope.
- // Specifically, the HTTP response entity-body must be empty.
- if (opMetaData.isOneWay() == true)
- {
- return;
- }
-
- // WS-Addressing might redirect the response, which results in an empty
envelope
- SOAPMessage resMessage = (SOAPMessage)payload;
- SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
- if (soapEnvelope == null)
- {
- return;
- }
-
- // Verify the SOAP version
- verifySOAPVersion(opMetaData, soapEnvelope);
-
- // Get the SOAP message context that is associated with the current thread
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext == null)
- throw new WSException("MessageContext not available");
-
- // Disable MTOM for rpc/encoded
- if (opMetaData.isRPCEncoded())
- msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
-
- SOAPHeader soapHeader = soapEnvelope.getHeader();
- SOAPBody soapBody = soapEnvelope.getBody();
- Iterator bodyChildren = soapBody.getChildElements();
-
- SOAPBodyElement soapBodyElement = null;
- if (bodyChildren.hasNext() != false)
- soapBodyElement = (SOAPBodyElement)bodyChildren.next();
-
- // Translate the SOAPFault to an exception and throw it
- if (soapBodyElement instanceof SOAPFaultImpl)
- throwFaultException((SOAPFaultImpl)soapBodyElement);
-
- // Extract unbound OUT headers
- if (unboundHeaders != null)
- {
- Map<QName, UnboundHeader> outHeaders = new HashMap<QName,
UnboundHeader>();
- Iterator itHeaderElements = soapHeader.getChildElements();
- while (itHeaderElements.hasNext())
- {
- SOAPContentElement soapHeaderElement =
(SOAPHeaderElementImpl)itHeaderElements.next();
- Name elName = soapHeaderElement.getElementName();
- QName xmlName = new QName(elName.getURI(), elName.getLocalName());
-
- UnboundHeader unboundHeader = (UnboundHeader)unboundHeaders.get(xmlName);
- if (unboundHeader != null)
- {
-
soapHeaderElement.setParamMetaData(unboundHeader.toParameterMetaData(opMetaData));
-
- // Do the unmarshalling
- Object value = soapHeaderElement.getObjectValue();
- unboundHeader.setHeaderValue(value);
- outHeaders.put(xmlName, unboundHeader);
- }
- }
- unboundHeaders.clear();
- unboundHeaders.putAll(outHeaders);
- }
-
- Style style = opMetaData.getStyle();
- if (style == Style.RPC)
- {
- if (soapBodyElement == null)
- throw new WSException("Cannot unbind response message with empty soap
body");
-
- ParameterMetaData retMetaData = opMetaData.getReturnParameter();
- if (retMetaData != null)
- {
- if (retMetaData.isSwA())
- {
- Object value = getAttachmentFromMessage(retMetaData, resMessage);
- epInv.setReturnValue(value);
- }
- else
- {
- Object value = getParameterFromMessage(retMetaData, soapBodyElement,
false);
- epInv.setReturnValue(value);
- }
- }
-
- for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- if (paramMetaData.isSwA())
- {
- Object value = getAttachmentFromMessage(paramMetaData, resMessage);
- epInv.setResponseParamValue(xmlName, value);
- }
- else
- {
- SOAPElement soapElement = paramMetaData.isInHeader() ? soapHeader :
(SOAPElement)soapBodyElement;
- Object value = getParameterFromMessage(paramMetaData, soapElement,
false);
- epInv.setResponseParamValue(xmlName, value);
- }
- }
- }
- else if (style == Style.DOCUMENT)
- {
- ParameterMetaData retMetaData = opMetaData.getReturnParameter();
-
- // WS-Eventing has no message part for UnsubscribeResponseMsg
- if (retMetaData != null)
- {
- if (retMetaData.isSwA())
- {
- Object value = getAttachmentFromMessage(retMetaData, resMessage);
- epInv.setReturnValue(value);
- }
- else
- {
- Object value = getParameterFromMessage(retMetaData, soapBody, false);
- epInv.setReturnValue(value);
- }
-
- for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
- {
- QName xmlName = paramMetaData.getXmlName();
- if (paramMetaData.isInHeader())
- {
- Object value = getParameterFromMessage(paramMetaData, soapHeader,
false);
- epInv.setResponseParamValue(xmlName, value);
- }
- }
- }
- }
- else
- {
- throw new WSException("Unsupported message style: " + style);
- }
- }
- catch (Exception e)
- {
- handleException(e);
- }
- }
-
- public abstract SOAPMessage exceptionToFaultMessage(Exception ex);
-
- private void verifySOAPVersion(OperationMetaData opMetaData, SOAPEnvelope
soapEnvelope)
- {
- String envNS = soapEnvelope.getNamespaceURI();
- String bindingId = opMetaData.getEndpointMetaData().getBindingId();
- if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId) &&
Constants.NS_SOAP11_ENV.equals(envNS) == false)
- log.warn("Expected SOAP-1.1 envelope, but got: " + envNS);
-
- if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId) &&
Constants.NS_SOAP12_ENV.equals(envNS) == false)
- log.warn("Expected SOAP-1.2 envelope, but got: " + envNS);
- }
-
- private AttachmentPart createAttachmentPart(ParameterMetaData paramMetaData, Object
value, CIDGenerator cidGenerator) throws SOAPException, BindingException
- {
- String partName = paramMetaData.getXmlName().getLocalPart();
- Set mimeTypes = paramMetaData.getMimeTypes();
-
- AttachmentPart part = new AttachmentPartImpl();
- if (value instanceof DataHandler)
- {
- DataHandler handler = (DataHandler)value;
- String mimeType = MimeUtils.getBaseMimeType(handler.getContentType());
-
- if (mimeTypes != null && !MimeUtils.isMemberOf(mimeType, mimeTypes))
- throw new BindingException("Mime type " + mimeType + " not
allowed for parameter " + partName + " allowed types are " + mimeTypes);
-
- part.setDataHandler((DataHandler)value);
- }
- else
- {
- String mimeType = null;
- if (mimeTypes != null && mimeTypes.size() > 0)
- {
- mimeType = (String)mimeTypes.iterator().next();
- }
- else
- {
- mimeType = MimeUtils.resolveMimeType(value);
- }
-
- if (mimeType == null)
- throw new BindingException("Could not determine mime type for attachment
parameter: " + partName);
-
- part.setContent(value, mimeType);
- }
-
- if (paramMetaData.isSwA())
- {
- String swaCID = '<' + partName + "=" +
cidGenerator.generateFromCount() + '>';
- part.setContentId(swaCID);
- }
- if (paramMetaData.isXOP())
- {
- String xopCID = '<' + cidGenerator.generateFromName(partName) +
'>';
- part.setContentId(xopCID);
- }
-
- return part;
- }
-
- private Object getAttachmentFromMessage(ParameterMetaData paramMetaData, SOAPMessage
message) throws SOAPException, BindingException
- {
- QName xmlName = paramMetaData.getXmlName();
-
- AttachmentPart part =
((SOAPMessageImpl)message).getAttachmentByPartName(xmlName.getLocalPart());
- if (part == null)
- throw new BindingException("Could not locate attachment for parameter:
" + paramMetaData.getXmlName());
-
- return part;
- }
-
- /** Marshall the given parameter and add it to the SOAPMessage */
- private SOAPContentElement addParameterToMessage(ParameterMetaData paramMetaData,
Object value, SOAPElement soapElement) throws SOAPException, BindingException
- {
- QName xmlName = paramMetaData.getXmlName();
- Class javaType = paramMetaData.getJavaType();
-
- if (value != null && paramMetaData.isXOP() == false)
- {
- Class valueType = value.getClass();
- if (JavaUtils.isAssignableFrom(javaType, valueType) == false)
- throw new BindingException("javaType " + javaType.getName() +
" is not assignable from: " + valueType.getName());
- }
-
- // Make sure we have a prefix on qualified names
- if (xmlName.getNamespaceURI().length() > 0)
- {
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
- xmlName = namespaceRegistry.registerQName(xmlName);
- }
-
- Name soapName = new NameImpl(xmlName.getLocalPart(), xmlName.getPrefix(),
xmlName.getNamespaceURI());
- if (paramMetaData.isSOAPArrayParam())
- soapName = new NameImpl("Array", Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
-
- SOAPContentElement contentElement;
- if (soapElement instanceof SOAPHeader)
- {
- contentElement = new SOAPHeaderElementImpl(soapName);
- soapElement.addChildElement(contentElement);
- }
- else
- {
- Style style = paramMetaData.getOperationMetaData().getStyle();
- if (style == Style.DOCUMENT)
- {
- contentElement = new SOAPBodyElementDoc(soapName);
- soapElement.addChildElement(contentElement);
- }
- else
- {
- contentElement = new SOAPContentElement(soapName);
- soapElement.addChildElement(contentElement);
- }
- }
-
- contentElement.setParamMetaData(paramMetaData);
-
- if (paramMetaData.isSOAPArrayParam())
- {
- log.trace("Add parameter as SOAP encoded Array");
- contentElement.addNamespaceDeclaration(Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
- }
-
- // When a potential xop parameter is detected and MTOM is enabled
- // we flag the SOAP message as a XOP package
- if (paramMetaData.isXOP() && XOPContext.isMTOMEnabled())
- {
- log.trace("Add parameter as XOP");
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
- soapMessage.setXOPMessage(true);
- }
-
- contentElement.setObjectValue(value);
-
- return contentElement;
- }
-
- /** Unmarshall a message element and add it to the parameter list */
- private Object getParameterFromMessage(ParameterMetaData paramMetaData, SOAPElement
soapElement, boolean optional) throws BindingException
- {
- Name xmlName = new NameImpl(paramMetaData.getXmlName());
-
- SOAPContentElement soapContentElement = null;
- Iterator childElements = soapElement.getChildElements();
- while (childElements.hasNext())
- {
- SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
-
- // If this message was manipulated by a handler the child may not be a content
element
- if (!(childElement instanceof SOAPContentElement))
- childElement = (SOAPContentElement)soapElement.replaceChild(new
SOAPContentElement(childElement), childElement);
-
- // The parameters are expected to be lazy
- SOAPContentElement aux = (SOAPContentElement)childElement;
- Name elName = aux.getElementName();
-
- if (xmlName.equals(elName))
- {
- soapContentElement = aux;
- soapContentElement.setParamMetaData(paramMetaData);
- break;
- }
-
- if (SOAP_ARRAY_NAME.equals(elName))
- {
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- msgContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM,
Boolean.TRUE);
- try
- {
- QName compXMLName = paramMetaData.getXmlName();
- Element compElement = DOMUtils.getFirstChildElement(aux);
- if (compElement.getNodeName().equals(compXMLName.getLocalPart()))
- {
- soapContentElement = aux;
- soapContentElement.setParamMetaData(paramMetaData);
- break;
- }
- }
- finally
- {
- msgContext.removeProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
- }
- }
- }
-
- // If matching by name fails, try to match by xmlType
- // This maybe necessary when wsa:Action dispatches to the operation
- if (soapContentElement == null)
- {
- childElements = soapElement.getChildElements();
- OperationMetaData opMetaData = paramMetaData.getOperationMetaData();
- TypesMetaData typesMetaData =
opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
- if (childElements.hasNext() && opMetaData.getStyle() == Style.DOCUMENT)
- {
- SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
-
- // The parameters are expected to be lazy
- SOAPContentElement aux = (SOAPContentElement)childElement;
- Name elName = aux.getElementName();
- QName elType = null;
-
- XSElementDeclaration xsdElement =
typesMetaData.getSchemaModel().getElementDeclaration(elName.getLocalName(),
elName.getURI());
- if (xsdElement != null && xsdElement.getTypeDefinition() != null)
- {
- XSTypeDefinition xsdType = xsdElement.getTypeDefinition();
- elType = new QName(xsdType.getNamespace(), xsdType.getName());
- }
-
- if (paramMetaData.getXmlType().equals(elType))
- {
- soapContentElement = aux;
- soapContentElement.setParamMetaData(paramMetaData);
- }
- }
- }
-
- if (soapContentElement == null && optional == false)
- throw new WSException("Cannot find child element: " + xmlName);
-
- // When a potential XOP parameter is detected and
- // the incomming request is actuall XOP encoded we flag
- // the SOAP message a XOP packaged.
- if (paramMetaData.isXOP() && XOPContext.isXOPEncodedRequest())
- {
- SOAPMessageImpl soapMessage =
(SOAPMessageImpl)MessageContextAssociation.peekMessageContext().getSOAPMessage();
- soapMessage.setXOPMessage(true);
- }
- return soapContentElement;
- }
-
- abstract protected void throwFaultException(SOAPFaultImpl fault) throws Exception;
-
- private void handleException(Exception ex) throws BindingException
- {
- if (ex instanceof RuntimeException)
- throw (RuntimeException)ex;
-
- if (ex instanceof BindingException)
- throw (BindingException)ex;
-
- throw new BindingException(ex);
- }
-}
Deleted:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,92 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.ws.core;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.ws.core.soap.SOAPElementImpl;
-import org.jboss.ws.core.soap.SOAPElementWriter;
-import org.jboss.ws.core.soap.SOAPMessageImpl;
-/**
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Nov-2004
- */
-public class SOAPMessageMarshaller implements Marshaller
-{
- // Provide logging
- private static Logger log = Logger.getLogger(SOAPMessageMarshaller.class);
-
- /**
- * Marshaller will need to take the dataObject and convert
- * into primitive java data types and write to the
- * given output.
- *
- * @param dataObject Object to be writen to output
- * @param output The data output to write the object
- * data to.
- */
- public void write(Object dataObject, OutputStream output) throws IOException
- {
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
- if ((dataObject instanceof SOAPMessage) == false)
- throw new IllegalArgumentException("Not a SOAPMessage: " +
dataObject);
-
- try
- {
- SOAPMessageImpl soapMessage = (SOAPMessageImpl)dataObject;
-
- // debug the outgoing message
- if (log.isTraceEnabled())
- {
- SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
- String envStr = SOAPElementWriter.writeElement((SOAPElementImpl)soapEnv,
true);
- log.trace("Outgoing SOAPMessage\n" + envStr);
- }
-
- soapMessage.writeTo(output);
- }
- catch (SOAPException e)
- {
- log.error("Cannot marshall SOAPMessage", e);
- throw new IOException(e.toString());
- }
- }
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- return new SOAPMessageMarshaller();
- }
-}
Deleted:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.soap.MessageFactoryImpl;
-
-/**
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Nov-2004
- */
-public class SOAPMessageUnMarshaller implements UnMarshaller
-{
- // Provide logging
- private static Logger log = Logger.getLogger(SOAPMessageUnMarshaller.class);
-
- private static List validResponseCodes = new ArrayList();
- static
- {
- validResponseCodes.add(HttpServletResponse.SC_OK);
- validResponseCodes.add(HttpServletResponse.SC_ACCEPTED);
- validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
-
- public Object read(InputStream inputStream, Map metadata) throws IOException,
ClassNotFoundException
- {
- if (log.isTraceEnabled())
- {
- log.trace("Read input stream with metadata=" + metadata);
- }
-
- try
- {
- Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
- String resMessage =
(String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
- if (resCode != null && validResponseCodes.contains(resCode) == false)
- throw new WSException("Invalid HTTP server response [" + resCode +
"] - " + resMessage);
-
- MimeHeaders mimeHeaders = getMimeHeaders(metadata);
- SOAPMessage soapMsg = new
MessageFactoryImpl().createMessageInternal(mimeHeaders, inputStream, true);
- return soapMsg;
- }
- catch (SOAPException e)
- {
- log.error("Cannot unmarshall SOAPMessage", e);
- throw new IOException(e.toString());
- }
- }
-
- /**
- * Set the class loader to use for unmarhsalling. This may
- * be needed when need to have access to class definitions that
- * are not part of this unmarshaller's parent classloader (especially
- * when doing remote classloading).
- *
- * @param classloader
- */
- public void setClassLoader(ClassLoader classloader)
- {
- //NO OP
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- return new SOAPMessageUnMarshaller();
- }
-
- private MimeHeaders getMimeHeaders(Map metadata)
- {
- log.debug("getMimeHeaders from: " + metadata);
-
- MimeHeaders headers = new MimeHeaders();
- Iterator i = metadata.keySet().iterator();
- while (i.hasNext())
- {
- String key = (String)i.next();
- Object value = metadata.get(key);
- if (key != null && value instanceof List)
- {
- for (Object listValue : (List)value)
- {
- headers.addHeader(key, listValue.toString());
- }
- }
- }
- return headers;
- }
-}
Deleted:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core;
-
-// $Id$
-
-import java.util.Stack;
-
-import org.jboss.ws.extras.security.SecurityStore;
-
-/**
- * Maintain thread locals at a single point.
- *
- * @author Heiko Braun, <heiko(a)openj.net>
- * @author Thomas.Diesler(a)jboss.com
- * @since 10-Apr-2006
- */
-public class ThreadLocalAssociation
-{
-
- /**
- * Handles invocations on MDB endpoints.
- */
- private static ThreadLocal invokerMDBAssoc = new ThreadLocal();
-
- /**
- * SOAP message context
- * @see org.jboss.ws.core.soap.MessageContextAssociation
- */
- private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc =
new ThreadLocal<Stack<CommonMessageContext>>();
-
- /**
- * @see org.jboss.ws.extras.security.STRTransform
- */
- private static ThreadLocal<SecurityStore> strTransformAssoc = new
ThreadLocal<SecurityStore>();
-
- public static ThreadLocal localInvokerMDBAssoc()
- {
- return invokerMDBAssoc;
- }
-
- public static ThreadLocal<Stack<CommonMessageContext>>
localMsgContextAssoc()
- {
- return msgContextAssoc;
- }
-
- public static ThreadLocal<SecurityStore> localStrTransformAssoc()
- {
- return strTransformAssoc;
- }
-
- public static void clear()
- {
- invokerMDBAssoc.set(null);
- msgContextAssoc.set(null);
- strTransformAssoc.set(null);
- }
-}
Copied: branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBinding.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java)
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBinding.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.binding;
+
+// $Id$
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.metadata.umdm.OperationMetaData;
+import org.jboss.ws.core.soap.UnboundHeader;
+
+/**
+ * The base interface for protocol bindings.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 04-Jul-2006
+ */
+public interface CommonBinding
+{
+ /** On the client side, generate the Object from IN parameters. */
+ Object bindRequestMessage(OperationMetaData opMetaData, EndpointInvocation epInv,
Map<QName, UnboundHeader> unboundHeaders) throws BindingException;
+
+ /** On the server side, extract the IN parameters from the Object and populate an
Invocation object */
+ EndpointInvocation unbindRequestMessage(OperationMetaData opMetaData, Object
reqMessage) throws BindingException;
+
+ /** On the server side, generate the Object from OUT parameters in the Invocation
object. */
+ Object bindResponseMessage(OperationMetaData opMetaData, EndpointInvocation epInv)
throws BindingException;
+
+ /** On the client side, extract the OUT parameters from the Object and return them to
the client. */
+ void unbindResponseMessage(OperationMetaData opMetaData, Object resMessage,
EndpointInvocation epInv, Map<QName, UnboundHeader> unboundHeaders) throws
BindingException;
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBindingProvider.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonBindingProvider.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonBindingProvider.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.binding;
+
+// $Id$
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.jaxrpc.SOAP11BindingJAXRPC;
+import org.jboss.ws.core.jaxrpc.SOAP12BindingJAXRPC;
+import org.jboss.ws.core.jaxws.core.SOAP11BindingJAXWS;
+import org.jboss.ws.core.jaxws.core.SOAP12BindingJAXWS;
+import org.jboss.ws.core.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.core.metadata.umdm.EndpointMetaData.Type;
+
+/**
+ * Provides access to the protocol binding.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 04-Jul-2006
+ */
+public class CommonBindingProvider
+{
+ protected EndpointMetaData epMetaData;
+ protected CommonBinding binding;
+
+ public CommonBindingProvider(EndpointMetaData epMetaData)
+ {
+ this.epMetaData = epMetaData;
+ initBinding(epMetaData.getBindingId(), epMetaData.getType());
+ }
+
+ public CommonBindingProvider(String bindingId, Type type)
+ {
+ initBinding(bindingId, type);
+ }
+
+ protected void initBinding(String bindingId, Type type)
+ {
+ if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId))
+ {
+ binding = (type == Type.JAXWS ? new SOAP11BindingJAXWS() : new
SOAP11BindingJAXRPC());
+ }
+ else if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId))
+ {
+ binding = (type == Type.JAXWS ? new SOAP12BindingJAXWS() : new
SOAP12BindingJAXRPC());
+ }
+ else
+ {
+ throw new WSException("Unsupported binding: " + bindingId);
+ }
+ }
+
+ public CommonBinding getCommonBinding()
+ {
+ return binding;
+ }
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP11Binding.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP11Binding.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP11Binding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.binding;
+
+// $Id$
+
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ws.Constants;
+import org.jboss.ws.core.jaxrpc.Use;
+import org.jboss.ws.core.metadata.umdm.OperationMetaData;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+
+/**
+ * The SOAP11Binding
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 04-Jul-2006
+ */
+public abstract class CommonSOAP11Binding extends CommonSOAPBinding
+{
+ public CommonSOAP11Binding()
+ {
+ }
+
+ /** Create the SOAP-1.1 message */
+ protected SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException
+ {
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+ factory.setEnvelopeURI(Constants.NS_SOAP11_ENV);
+ SOAPMessage soapMessage = factory.createMessage();
+
+ Use encStyle = opMetaData.getEndpointMetaData().getEncodingStyle();
+ if (Use.ENCODED.equals(encStyle))
+ {
+ SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
+ soapEnvelope.addNamespaceDeclaration(Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
+ }
+
+ return soapMessage;
+ }
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP12Binding.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAP12Binding.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAP12Binding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.binding;
+
+// $Id$
+
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ws.Constants;
+import org.jboss.ws.core.metadata.umdm.OperationMetaData;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+
+/**
+ * The SOAP11Binding
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 04-Jul-2006
+ */
+public abstract class CommonSOAP12Binding extends CommonSOAPBinding
+{
+
+ public CommonSOAP12Binding()
+ {
+ }
+
+ /** Create the SOAP-1.1 message */
+ protected SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException
+ {
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+ factory.setEnvelopeURI(Constants.NS_SOAP12_ENV);
+ return factory.createMessage();
+ }
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAPBinding.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/binding/CommonSOAPBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,907 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.binding;
+
+// $Id$
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.ParameterMode;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.jaxrpc.ParameterWrapping;
+import org.jboss.ws.core.jaxrpc.StubExt;
+import org.jboss.ws.core.jaxrpc.Style;
+import org.jboss.ws.core.metadata.umdm.OperationMetaData;
+import org.jboss.ws.core.metadata.umdm.ParameterMetaData;
+import org.jboss.ws.core.metadata.umdm.TypesMetaData;
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.core.soap.NameImpl;
+import org.jboss.ws.core.soap.SOAPBodyElementDoc;
+import org.jboss.ws.core.soap.SOAPBodyElementRpc;
+import org.jboss.ws.core.soap.SOAPContentElement;
+import org.jboss.ws.core.soap.SOAPElementImpl;
+import org.jboss.ws.core.soap.SOAPFactoryImpl;
+import org.jboss.ws.core.soap.SOAPFaultImpl;
+import org.jboss.ws.core.soap.SOAPHeaderElementImpl;
+import org.jboss.ws.core.soap.SOAPMessageImpl;
+import org.jboss.ws.core.soap.UnboundHeader;
+import org.jboss.ws.core.soap.attachment.AttachmentPartImpl;
+import org.jboss.ws.core.soap.attachment.CIDGenerator;
+import org.jboss.ws.core.utils.DOMUtils;
+import org.jboss.ws.core.utils.JavaUtils;
+import org.jboss.ws.core.utils.MimeUtils;
+import org.jboss.ws.extras.xop.XOPContext;
+import org.jboss.xb.binding.NamespaceRegistry;
+import org.w3c.dom.Element;
+
+/**
+ * The SOAPBinding interface is an abstraction for the SOAP binding.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 04-Jul-2006
+ */
+public abstract class CommonSOAPBinding implements CommonBinding
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(CommonSOAPBinding.class);
+
+ private boolean mtomEnabled;
+
+ /** A constant representing the identity of the SOAP 1.2 over HTTP binding. */
+ public static final String SOAP12HTTP_BINDING =
"http://www.w3.org/2003/05/soap/bindings/HTTP/";
+
+ /** A constant representing the identity of the SOAP 1.1 over HTTP binding. */
+ public static final String SOAP11HTTP_BINDING =
"http://schemas.xmlsoap.org/wsdl/soap/http";
+ private static final Name SOAP_ARRAY_NAME = new NameImpl("Array",
Constants.PREFIX_SOAP11_ENC, Constants.URI_SOAP11_ENC);
+
+ public CommonSOAPBinding()
+ {
+ }
+
+ public MessageFactory getMessageFactory()
+ {
+ return new MessageFactoryImpl();
+ }
+
+ public SOAPFactory getSOAPFactory()
+ {
+ return new SOAPFactoryImpl();
+ }
+
+ public boolean isMTOMEnabled()
+ {
+ return mtomEnabled;
+ }
+
+ public void setMTOMEnabled(boolean flag)
+ {
+ this.mtomEnabled = flag;
+ }
+
+ /** Create the SOAP-1.1 message */
+ protected abstract SOAPMessage createMessage(OperationMetaData opMetaData) throws
SOAPException;
+
+ /** On the client side, generate the payload from IN parameters. */
+ public Object bindRequestMessage(OperationMetaData opMetaData, EndpointInvocation
epInv, Map<QName, UnboundHeader> unboundHeaders) throws BindingException
+ {
+ log.debug("bindRequestMessage: " + opMetaData.getQName());
+
+ try
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ if (msgContext == null)
+ throw new WSException("MessageContext not available");
+
+ // Disable MTOM for rpc/encoded
+ if (opMetaData.isRPCEncoded())
+ msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
+
+ // Associate current message with message context
+ SOAPMessageImpl reqMessage = (SOAPMessageImpl)createMessage(opMetaData);
+ msgContext.setSOAPMessage(reqMessage);
+
+ SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
+ SOAPBody soapBody = soapEnvelope.getBody();
+ SOAPHeader soapHeader = soapEnvelope.getHeader();
+
+ // Get the namespace registry
+ NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
+
+ Style style = opMetaData.getStyle();
+ if (style == Style.RPC)
+ {
+ QName opQName = opMetaData.getQName();
+ Name opName = new NameImpl(namespaceRegistry.registerQName(opQName));
+
+ log.debug("Create RPC body element: " + opName);
+ SOAPBodyElement soapBodyElement = new SOAPBodyElementRpc(opName);
+
+
+ soapBodyElement =
(SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
+
+ for (ParameterMetaData paramMetaData : opMetaData.getInputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ Object value = epInv.getRequestParamValue(xmlName);
+
+ if (paramMetaData.isSwA())
+ {
+ CIDGenerator cidGenerator = reqMessage.getCidGenerator();
+ AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
+ reqMessage.addAttachmentPart(part);
+ }
+ else
+ {
+ SOAPElement soapElement = paramMetaData.isInHeader() ?
(SOAPElement)soapHeader : soapBodyElement;
+ addParameterToMessage(paramMetaData, value, soapElement);
+ }
+ }
+ }
+ else if (style == Style.DOCUMENT)
+ {
+ for (ParameterMetaData paramMetaData : opMetaData.getInputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ Object value = epInv.getRequestParamValue(xmlName);
+
+ if (paramMetaData.isSwA())
+ {
+ CIDGenerator cidGenerator = reqMessage.getCidGenerator();
+ AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
+ reqMessage.addAttachmentPart(part);
+ }
+ else
+ {
+ SOAPElement soapElement = paramMetaData.isInHeader() ?
(SOAPElement)soapHeader : soapBody;
+ addParameterToMessage(paramMetaData, value, soapElement);
+ }
+ }
+ }
+ else
+ {
+ throw new WSException("Unsupported message style: " + style);
+ }
+
+ // Add unbound headers
+ if (unboundHeaders != null)
+ {
+ Iterator it = unboundHeaders.values().iterator();
+ while (it.hasNext())
+ {
+ UnboundHeader unboundHeader = (UnboundHeader)it.next();
+ if (unboundHeader.getMode() != ParameterMode.OUT)
+ {
+ QName xmlName = unboundHeader.getXmlName();
+ Object value = unboundHeader.getHeaderValue();
+
+ xmlName = namespaceRegistry.registerQName(xmlName);
+ Name soapName = new NameImpl(xmlName.getLocalPart(),
xmlName.getPrefix(), xmlName.getNamespaceURI());
+
+ log.debug("Add unboundHeader element: " + soapName);
+ SOAPContentElement contentElement = new
SOAPHeaderElementImpl(soapName);
+
contentElement.setParamMetaData(unboundHeader.toParameterMetaData(opMetaData));
+ soapHeader.addChildElement(contentElement);
+ contentElement.setObjectValue(value);
+ }
+ }
+ }
+
+ // Set the SOAPAction
+ setSOAPActionHeader(opMetaData, reqMessage);
+
+ return reqMessage;
+ }
+ catch (Exception e)
+ {
+ handleException(e);
+ return null;
+ }
+ }
+
+ /** Override to set the SOAPAction header */
+ public abstract void setSOAPActionHeader(OperationMetaData opMetaData, SOAPMessage
reqMessage);
+
+ /** On the server side, extract the IN parameters from the payload and populate an
Invocation object */
+ public EndpointInvocation unbindRequestMessage(OperationMetaData opMetaData, Object
payload) throws BindingException
+ {
+ log.debug("unbindRequestMessage: " + opMetaData.getQName());
+
+ try
+ {
+ // Read the SOAPEnvelope from the reqMessage
+ SOAPMessage reqMessage = (SOAPMessage)payload;
+ SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
+ SOAPHeader soapHeader = soapEnvelope.getHeader();
+ SOAPBody soapBody = soapEnvelope.getBody();
+
+ // Verify the SOAP version
+ verifySOAPVersion(opMetaData, soapEnvelope);
+
+ // Construct the endpoint invocation object
+ EndpointInvocation epInv = new EndpointInvocation(opMetaData);
+
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ if (msgContext == null)
+ throw new WSException("MessageContext not available");
+
+ // Disable MTOM for rpc/encoded
+ if (opMetaData.isRPCEncoded())
+ msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
+
+ // Get the namespace registry
+ NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
+
+ if (opMetaData.isMessageEndpoint() == false)
+ {
+ Style style = opMetaData.getStyle();
+ if (style == Style.RPC)
+ {
+ SOAPBodyElement soapBodyElement =
(SOAPBodyElement)soapBody.getChildElements().next();
+ Name elName = soapBodyElement.getElementName();
+
+ QName elQName = new QName(elName.getURI(), elName.getLocalName(),
elName.getPrefix());
+ elQName = namespaceRegistry.registerQName(elQName);
+
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ if (paramMetaData.getMode() == ParameterMode.OUT)
+ {
+ epInv.setRequestParamValue(xmlName, null);
+ }
+ else
+ {
+ if (paramMetaData.isSwA())
+ {
+ Object value = getAttachmentFromMessage(paramMetaData,
reqMessage);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ else
+ {
+ if (paramMetaData.isInHeader() == false)
+ {
+ Object value = getParameterFromMessage(paramMetaData,
soapBodyElement, false);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ else
+ {
+ Object value = getParameterFromMessage(paramMetaData,
soapHeader, false);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ }
+ }
+ }
+ }
+
+ // Document style
+ else
+ {
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ if (paramMetaData.isSwA())
+ {
+ Object value = getAttachmentFromMessage(paramMetaData, reqMessage);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ else
+ {
+ if (paramMetaData.isInHeader())
+ {
+ if (paramMetaData.getMode() == ParameterMode.IN)
+ {
+ Object value = getParameterFromMessage(paramMetaData,
soapHeader, false);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ else
+ {
+ Object value = getParameterFromMessage(paramMetaData,
soapHeader, true);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ }
+ else
+ {
+ Object value = getParameterFromMessage(paramMetaData, soapBody,
false);
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ }
+ }
+ }
+ }
+
+ // Generic message endpoint
+ else
+ {
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ Object value = soapBody.getChildElements().next();
+ epInv.setRequestParamValue(xmlName, value);
+ }
+ }
+
+ return epInv;
+ }
+ catch (Exception e)
+ {
+ handleException(e);
+ return null;
+ }
+ }
+
+ /** On the server side, generate the payload from OUT parameters. */
+ public Object bindResponseMessage(OperationMetaData opMetaData, EndpointInvocation
epInv) throws BindingException
+ {
+ log.debug("bindResponseMessage: " + opMetaData.getQName());
+
+ try
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ if (msgContext == null)
+ throw new WSException("MessageContext not available");
+
+ // Disable MTOM for rpc/encoded
+ if (opMetaData.isRPCEncoded())
+ msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
+
+ // Associate current message with message context
+ SOAPMessageImpl resMessage = (SOAPMessageImpl)createMessage(opMetaData);
+ msgContext.setSOAPMessage(resMessage);
+
+ // R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response
that contains a SOAP envelope.
+ // Specifically, the HTTP response entity-body must be empty.
+ if (opMetaData.isOneWay())
+ {
+ resMessage.getSOAPPart().setContent(null);
+ return resMessage;
+ }
+
+ SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
+ SOAPHeader soapHeader = soapEnvelope.getHeader();
+ SOAPBody soapBody = soapEnvelope.getBody();
+
+ // Get the namespace registry
+ NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
+
+ Style style = opMetaData.getStyle();
+ if (style == Style.RPC)
+ {
+ QName opQName = opMetaData.getResponseName();
+
+ Name opName = new NameImpl(namespaceRegistry.registerQName(opQName));
+ SOAPBodyElement soapBodyElement = new SOAPBodyElementRpc(opName);
+
+ soapBodyElement =
(SOAPBodyElement)soapBody.addChildElement(soapBodyElement);
+
+ // Add the return to the message
+ ParameterMetaData retMetaData = opMetaData.getReturnParameter();
+ if (retMetaData != null)
+ {
+ Object value = epInv.getReturnValue();
+ if (retMetaData.isSwA())
+ {
+ CIDGenerator cidGenerator = resMessage.getCidGenerator();
+ AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
+ resMessage.addAttachmentPart(part);
+ epInv.setReturnValue(part);
+ }
+ else
+ {
+ SOAPContentElement soapElement = addParameterToMessage(retMetaData,
value, soapBodyElement);
+ epInv.setReturnValue(soapElement);
+ soapElement.setObjectValue(value);
+ }
+ }
+
+ // Add the out parameters to the message
+ for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ Object value = epInv.getResponseParamValue(xmlName);
+ if (paramMetaData.isSwA())
+ {
+ CIDGenerator cidGenerator = resMessage.getCidGenerator();
+ AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
+ resMessage.addAttachmentPart(part);
+ }
+ else
+ {
+ if (paramMetaData.isInHeader())
+ {
+ addParameterToMessage(paramMetaData, value, soapHeader);
+ }
+ else
+ {
+ addParameterToMessage(paramMetaData, value, soapBodyElement);
+ }
+ }
+ }
+ }
+ else if (style == Style.DOCUMENT)
+ {
+ ParameterMetaData retMetaData = opMetaData.getReturnParameter();
+ if (retMetaData != null)
+ {
+ Object value = epInv.getReturnValue();
+ if (opMetaData.isDocumentWrapped())
+ value = ParameterWrapping.wrapResponseParameters(retMetaData, value,
epInv.getOutParameters());
+
+ if (retMetaData.isSwA())
+ {
+ CIDGenerator cidGenerator = resMessage.getCidGenerator();
+ AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
+ resMessage.addAttachmentPart(part);
+ epInv.setReturnValue(part);
+ }
+ else
+ {
+ SOAPContentElement soapElement = addParameterToMessage(retMetaData,
value, soapBody);
+ epInv.setReturnValue(soapElement);
+ }
+ }
+
+ // Add the out header parameters to the message
+ for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ if (paramMetaData.isInHeader())
+ {
+ Object value = epInv.getResponseParamValue(xmlName);
+ addParameterToMessage(paramMetaData, value, soapHeader);
+ }
+ }
+ }
+ else
+ {
+ throw new WSException("Unsupported message style: " + style);
+ }
+
+ return resMessage;
+ }
+ catch (Exception e)
+ {
+ handleException(e);
+ return null;
+ }
+ }
+
+ /** On the client side, extract the OUT parameters from the payload and return them to
the client. */
+ public void unbindResponseMessage(OperationMetaData opMetaData, Object payload,
EndpointInvocation epInv, Map<QName, UnboundHeader> unboundHeaders)
+ throws BindingException
+ {
+ log.debug("unbindResponseMessage: " + opMetaData.getQName());
+
+ try
+ {
+ // R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response
that contains a SOAP envelope.
+ // Specifically, the HTTP response entity-body must be empty.
+ if (opMetaData.isOneWay() == true)
+ {
+ return;
+ }
+
+ // WS-Addressing might redirect the response, which results in an empty
envelope
+ SOAPMessage resMessage = (SOAPMessage)payload;
+ SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
+ if (soapEnvelope == null)
+ {
+ return;
+ }
+
+ // Verify the SOAP version
+ verifySOAPVersion(opMetaData, soapEnvelope);
+
+ // Get the SOAP message context that is associated with the current thread
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ if (msgContext == null)
+ throw new WSException("MessageContext not available");
+
+ // Disable MTOM for rpc/encoded
+ if (opMetaData.isRPCEncoded())
+ msgContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, Boolean.FALSE);
+
+ SOAPHeader soapHeader = soapEnvelope.getHeader();
+ SOAPBody soapBody = soapEnvelope.getBody();
+ Iterator bodyChildren = soapBody.getChildElements();
+
+ SOAPBodyElement soapBodyElement = null;
+ if (bodyChildren.hasNext() != false)
+ soapBodyElement = (SOAPBodyElement)bodyChildren.next();
+
+ // Translate the SOAPFault to an exception and throw it
+ if (soapBodyElement instanceof SOAPFaultImpl)
+ throwFaultException((SOAPFaultImpl)soapBodyElement);
+
+ // Extract unbound OUT headers
+ if (unboundHeaders != null)
+ {
+ Map<QName, UnboundHeader> outHeaders = new HashMap<QName,
UnboundHeader>();
+ Iterator itHeaderElements = soapHeader.getChildElements();
+ while (itHeaderElements.hasNext())
+ {
+ SOAPContentElement soapHeaderElement =
(SOAPHeaderElementImpl)itHeaderElements.next();
+ Name elName = soapHeaderElement.getElementName();
+ QName xmlName = new QName(elName.getURI(), elName.getLocalName());
+
+ UnboundHeader unboundHeader = (UnboundHeader)unboundHeaders.get(xmlName);
+ if (unboundHeader != null)
+ {
+
soapHeaderElement.setParamMetaData(unboundHeader.toParameterMetaData(opMetaData));
+
+ // Do the unmarshalling
+ Object value = soapHeaderElement.getObjectValue();
+ unboundHeader.setHeaderValue(value);
+ outHeaders.put(xmlName, unboundHeader);
+ }
+ }
+ unboundHeaders.clear();
+ unboundHeaders.putAll(outHeaders);
+ }
+
+ Style style = opMetaData.getStyle();
+ if (style == Style.RPC)
+ {
+ if (soapBodyElement == null)
+ throw new WSException("Cannot unbind response message with empty soap
body");
+
+ ParameterMetaData retMetaData = opMetaData.getReturnParameter();
+ if (retMetaData != null)
+ {
+ if (retMetaData.isSwA())
+ {
+ Object value = getAttachmentFromMessage(retMetaData, resMessage);
+ epInv.setReturnValue(value);
+ }
+ else
+ {
+ Object value = getParameterFromMessage(retMetaData, soapBodyElement,
false);
+ epInv.setReturnValue(value);
+ }
+ }
+
+ for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ if (paramMetaData.isSwA())
+ {
+ Object value = getAttachmentFromMessage(paramMetaData, resMessage);
+ epInv.setResponseParamValue(xmlName, value);
+ }
+ else
+ {
+ SOAPElement soapElement = paramMetaData.isInHeader() ? soapHeader :
(SOAPElement)soapBodyElement;
+ Object value = getParameterFromMessage(paramMetaData, soapElement,
false);
+ epInv.setResponseParamValue(xmlName, value);
+ }
+ }
+ }
+ else if (style == Style.DOCUMENT)
+ {
+ ParameterMetaData retMetaData = opMetaData.getReturnParameter();
+
+ // WS-Eventing has no message part for UnsubscribeResponseMsg
+ if (retMetaData != null)
+ {
+ if (retMetaData.isSwA())
+ {
+ Object value = getAttachmentFromMessage(retMetaData, resMessage);
+ epInv.setReturnValue(value);
+ }
+ else
+ {
+ Object value = getParameterFromMessage(retMetaData, soapBody, false);
+ epInv.setReturnValue(value);
+ }
+
+ for (ParameterMetaData paramMetaData : opMetaData.getOutputParameters())
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ if (paramMetaData.isInHeader())
+ {
+ Object value = getParameterFromMessage(paramMetaData, soapHeader,
false);
+ epInv.setResponseParamValue(xmlName, value);
+ }
+ }
+ }
+ }
+ else
+ {
+ throw new WSException("Unsupported message style: " + style);
+ }
+ }
+ catch (Exception e)
+ {
+ handleException(e);
+ }
+ }
+
+ public abstract SOAPMessage exceptionToFaultMessage(Exception ex);
+
+ private void verifySOAPVersion(OperationMetaData opMetaData, SOAPEnvelope
soapEnvelope)
+ {
+ String envNS = soapEnvelope.getNamespaceURI();
+ String bindingId = opMetaData.getEndpointMetaData().getBindingId();
+ if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId) &&
Constants.NS_SOAP11_ENV.equals(envNS) == false)
+ log.warn("Expected SOAP-1.1 envelope, but got: " + envNS);
+
+ if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId) &&
Constants.NS_SOAP12_ENV.equals(envNS) == false)
+ log.warn("Expected SOAP-1.2 envelope, but got: " + envNS);
+ }
+
+ private AttachmentPart createAttachmentPart(ParameterMetaData paramMetaData, Object
value, CIDGenerator cidGenerator) throws SOAPException, BindingException
+ {
+ String partName = paramMetaData.getXmlName().getLocalPart();
+ Set mimeTypes = paramMetaData.getMimeTypes();
+
+ AttachmentPart part = new AttachmentPartImpl();
+ if (value instanceof DataHandler)
+ {
+ DataHandler handler = (DataHandler)value;
+ String mimeType = MimeUtils.getBaseMimeType(handler.getContentType());
+
+ if (mimeTypes != null && !MimeUtils.isMemberOf(mimeType, mimeTypes))
+ throw new BindingException("Mime type " + mimeType + " not
allowed for parameter " + partName + " allowed types are " + mimeTypes);
+
+ part.setDataHandler((DataHandler)value);
+ }
+ else
+ {
+ String mimeType = null;
+ if (mimeTypes != null && mimeTypes.size() > 0)
+ {
+ mimeType = (String)mimeTypes.iterator().next();
+ }
+ else
+ {
+ mimeType = MimeUtils.resolveMimeType(value);
+ }
+
+ if (mimeType == null)
+ throw new BindingException("Could not determine mime type for attachment
parameter: " + partName);
+
+ part.setContent(value, mimeType);
+ }
+
+ if (paramMetaData.isSwA())
+ {
+ String swaCID = '<' + partName + "=" +
cidGenerator.generateFromCount() + '>';
+ part.setContentId(swaCID);
+ }
+ if (paramMetaData.isXOP())
+ {
+ String xopCID = '<' + cidGenerator.generateFromName(partName) +
'>';
+ part.setContentId(xopCID);
+ }
+
+ return part;
+ }
+
+ private Object getAttachmentFromMessage(ParameterMetaData paramMetaData, SOAPMessage
message) throws SOAPException, BindingException
+ {
+ QName xmlName = paramMetaData.getXmlName();
+
+ AttachmentPart part =
((SOAPMessageImpl)message).getAttachmentByPartName(xmlName.getLocalPart());
+ if (part == null)
+ throw new BindingException("Could not locate attachment for parameter:
" + paramMetaData.getXmlName());
+
+ return part;
+ }
+
+ /** Marshall the given parameter and add it to the SOAPMessage */
+ private SOAPContentElement addParameterToMessage(ParameterMetaData paramMetaData,
Object value, SOAPElement soapElement) throws SOAPException, BindingException
+ {
+ QName xmlName = paramMetaData.getXmlName();
+ Class javaType = paramMetaData.getJavaType();
+
+ if (value != null && paramMetaData.isXOP() == false)
+ {
+ Class valueType = value.getClass();
+ if (JavaUtils.isAssignableFrom(javaType, valueType) == false)
+ throw new BindingException("javaType " + javaType.getName() +
" is not assignable from: " + valueType.getName());
+ }
+
+ // Make sure we have a prefix on qualified names
+ if (xmlName.getNamespaceURI().length() > 0)
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ NamespaceRegistry namespaceRegistry = msgContext.getNamespaceRegistry();
+ xmlName = namespaceRegistry.registerQName(xmlName);
+ }
+
+ Name soapName = new NameImpl(xmlName.getLocalPart(), xmlName.getPrefix(),
xmlName.getNamespaceURI());
+ if (paramMetaData.isSOAPArrayParam())
+ soapName = new NameImpl("Array", Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
+
+ SOAPContentElement contentElement;
+ if (soapElement instanceof SOAPHeader)
+ {
+ contentElement = new SOAPHeaderElementImpl(soapName);
+ soapElement.addChildElement(contentElement);
+ }
+ else
+ {
+ Style style = paramMetaData.getOperationMetaData().getStyle();
+ if (style == Style.DOCUMENT)
+ {
+ contentElement = new SOAPBodyElementDoc(soapName);
+ soapElement.addChildElement(contentElement);
+ }
+ else
+ {
+ contentElement = new SOAPContentElement(soapName);
+ soapElement.addChildElement(contentElement);
+ }
+ }
+
+ contentElement.setParamMetaData(paramMetaData);
+
+ if (paramMetaData.isSOAPArrayParam())
+ {
+ log.trace("Add parameter as SOAP encoded Array");
+ contentElement.addNamespaceDeclaration(Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
+ }
+
+ // When a potential xop parameter is detected and MTOM is enabled
+ // we flag the SOAP message as a XOP package
+ if (paramMetaData.isXOP() && XOPContext.isMTOMEnabled())
+ {
+ log.trace("Add parameter as XOP");
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+ soapMessage.setXOPMessage(true);
+ }
+
+ contentElement.setObjectValue(value);
+
+ return contentElement;
+ }
+
+ /** Unmarshall a message element and add it to the parameter list */
+ private Object getParameterFromMessage(ParameterMetaData paramMetaData, SOAPElement
soapElement, boolean optional) throws BindingException
+ {
+ Name xmlName = new NameImpl(paramMetaData.getXmlName());
+
+ SOAPContentElement soapContentElement = null;
+ Iterator childElements = soapElement.getChildElements();
+ while (childElements.hasNext())
+ {
+ SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
+
+ // If this message was manipulated by a handler the child may not be a content
element
+ if (!(childElement instanceof SOAPContentElement))
+ childElement = (SOAPContentElement)soapElement.replaceChild(new
SOAPContentElement(childElement), childElement);
+
+ // The parameters are expected to be lazy
+ SOAPContentElement aux = (SOAPContentElement)childElement;
+ Name elName = aux.getElementName();
+
+ if (xmlName.equals(elName))
+ {
+ soapContentElement = aux;
+ soapContentElement.setParamMetaData(paramMetaData);
+ break;
+ }
+
+ if (SOAP_ARRAY_NAME.equals(elName))
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ msgContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM,
Boolean.TRUE);
+ try
+ {
+ QName compXMLName = paramMetaData.getXmlName();
+ Element compElement = DOMUtils.getFirstChildElement(aux);
+ if (compElement.getNodeName().equals(compXMLName.getLocalPart()))
+ {
+ soapContentElement = aux;
+ soapContentElement.setParamMetaData(paramMetaData);
+ break;
+ }
+ }
+ finally
+ {
+ msgContext.removeProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
+ }
+ }
+ }
+
+ // If matching by name fails, try to match by xmlType
+ // This maybe necessary when wsa:Action dispatches to the operation
+ if (soapContentElement == null)
+ {
+ childElements = soapElement.getChildElements();
+ OperationMetaData opMetaData = paramMetaData.getOperationMetaData();
+ TypesMetaData typesMetaData =
opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
+ if (childElements.hasNext() && opMetaData.getStyle() == Style.DOCUMENT)
+ {
+ SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
+
+ // The parameters are expected to be lazy
+ SOAPContentElement aux = (SOAPContentElement)childElement;
+ Name elName = aux.getElementName();
+ QName elType = null;
+
+ XSElementDeclaration xsdElement =
typesMetaData.getSchemaModel().getElementDeclaration(elName.getLocalName(),
elName.getURI());
+ if (xsdElement != null && xsdElement.getTypeDefinition() != null)
+ {
+ XSTypeDefinition xsdType = xsdElement.getTypeDefinition();
+ elType = new QName(xsdType.getNamespace(), xsdType.getName());
+ }
+
+ if (paramMetaData.getXmlType().equals(elType))
+ {
+ soapContentElement = aux;
+ soapContentElement.setParamMetaData(paramMetaData);
+ }
+ }
+ }
+
+ if (soapContentElement == null && optional == false)
+ throw new WSException("Cannot find child element: " + xmlName);
+
+ // When a potential XOP parameter is detected and
+ // the incomming request is actuall XOP encoded we flag
+ // the SOAP message a XOP packaged.
+ if (paramMetaData.isXOP() && XOPContext.isXOPEncodedRequest())
+ {
+ SOAPMessageImpl soapMessage =
(SOAPMessageImpl)MessageContextAssociation.peekMessageContext().getSOAPMessage();
+ soapMessage.setXOPMessage(true);
+ }
+ return soapContentElement;
+ }
+
+ abstract protected void throwFaultException(SOAPFaultImpl fault) throws Exception;
+
+ private void handleException(Exception ex) throws BindingException
+ {
+ if (ex instanceof RuntimeException)
+ throw (RuntimeException)ex;
+
+ if (ex instanceof BindingException)
+ throw (BindingException)ex;
+
+ throw new BindingException(ex);
+ }
+}
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -25,7 +25,7 @@
import javax.xml.soap.SOAPMessage;
-import org.jboss.ws.core.CommonSOAP11Binding;
+import org.jboss.ws.core.binding.CommonSOAP11Binding;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.soap.SOAPFaultImpl;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -25,7 +25,7 @@
import javax.xml.soap.SOAPMessage;
-import org.jboss.ws.core.CommonSOAP12Binding;
+import org.jboss.ws.core.binding.CommonSOAP12Binding;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.soap.SOAPFaultImpl;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -40,9 +40,9 @@
import javax.xml.ws.soap.SOAPFaultException;
import org.jboss.logging.Logger;
-import org.jboss.ws.core.CommonBindingProvider;
import org.jboss.ws.core.CommonClient;
import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.binding.CommonBindingProvider;
import org.jboss.ws.core.jaxws.core.BindingExt;
import org.jboss.ws.core.jaxws.core.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerChainExecutor;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/BindingProviderImpl.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/BindingProviderImpl.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/BindingProviderImpl.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -33,7 +33,7 @@
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.SOAPBinding;
-import org.jboss.ws.core.CommonBindingProvider;
+import org.jboss.ws.core.binding.CommonBindingProvider;
import org.jboss.ws.core.metadata.umdm.EndpointMetaData;
import org.jboss.ws.core.metadata.umdm.EndpointMetaData.Type;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/HTTPBindingJAXWS.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/HTTPBindingJAXWS.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/HTTPBindingJAXWS.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -31,9 +31,9 @@
import javax.xml.ws.http.HTTPBinding;
import org.jboss.util.NotImplementedException;
-import org.jboss.ws.core.CommonBinding;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.binding.BindingException;
+import org.jboss.ws.core.binding.CommonBinding;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.metadata.umdm.HandlerMetaData.HandlerType;
import org.jboss.ws.core.soap.UnboundHeader;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/MessageBinding.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/MessageBinding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/MessageBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -33,9 +33,9 @@
import org.jboss.logging.Logger;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.CommonBinding;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.binding.BindingException;
+import org.jboss.ws.core.binding.CommonBinding;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.metadata.umdm.ParameterMetaData;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/PayloadBinding.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/PayloadBinding.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/PayloadBinding.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -35,9 +35,9 @@
import org.jboss.util.NotImplementedException;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.CommonBinding;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.binding.BindingException;
+import org.jboss.ws.core.binding.CommonBinding;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.metadata.umdm.ParameterMetaData;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP11BindingJAXWS.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP11BindingJAXWS.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP11BindingJAXWS.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -33,7 +33,7 @@
import javax.xml.ws.soap.SOAPBinding;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonSOAP11Binding;
+import org.jboss.ws.core.binding.CommonSOAP11Binding;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.metadata.umdm.HandlerMetaData.HandlerType;
import org.jboss.ws.core.soap.SOAPFaultImpl;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP12BindingJAXWS.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP12BindingJAXWS.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/jaxws/core/SOAP12BindingJAXWS.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -34,7 +34,7 @@
import javax.xml.ws.soap.SOAPBinding;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonSOAP12Binding;
+import org.jboss.ws.core.binding.CommonSOAP12Binding;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.metadata.umdm.HandlerMetaData.HandlerType;
import org.jboss.ws.core.soap.SOAPFaultImpl;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/metadata/builder/MetaDataBuilder.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/metadata/builder/MetaDataBuilder.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/metadata/builder/MetaDataBuilder.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -45,7 +45,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.CommonSOAPBinding;
+import org.jboss.ws.core.binding.CommonSOAPBinding;
import org.jboss.ws.core.jaxrpc.Use;
import org.jboss.ws.core.metadata.j2ee.UnifiedApplicationMetaData;
import org.jboss.ws.core.metadata.j2ee.UnifiedBeanMetaData;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -42,11 +42,11 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonBinding;
-import org.jboss.ws.core.CommonBindingProvider;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.CommonSOAPBinding;
import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.binding.CommonBinding;
+import org.jboss.ws.core.binding.CommonBindingProvider;
+import org.jboss.ws.core.binding.CommonSOAPBinding;
import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.jaxws.core.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -38,10 +38,10 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonBindingProvider;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.CommonSOAPBinding;
import org.jboss.ws.core.binding.BindingException;
+import org.jboss.ws.core.binding.CommonBindingProvider;
+import org.jboss.ws.core.binding.CommonSOAPBinding;
import org.jboss.ws.core.metadata.umdm.EndpointMetaData;
import org.jboss.ws.core.metadata.umdm.ServerEndpointMetaData;
import org.jboss.ws.core.metadata.umdm.UnifiedMetaData;
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -58,7 +58,6 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.ThreadLocalAssociation;
import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
import org.jboss.ws.core.jaxws.handler.MessageContextJAXWS;
@@ -71,6 +70,7 @@
import org.jboss.ws.core.metadata.umdm.HandlerMetaData.HandlerType;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.SOAPConnectionImpl;
+import org.jboss.ws.core.utils.ThreadLocalAssociation;
import org.jboss.ws.extras.addressing.AddressingConstantsImpl;
/**
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageContextAssociation.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageContextAssociation.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/MessageContextAssociation.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -27,7 +27,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.ThreadLocalAssociation;
+import org.jboss.ws.core.utils.ThreadLocalAssociation;
/**
* A thread local association with the current message context
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -44,8 +44,6 @@
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-import org.jboss.ws.core.SOAPMessageMarshaller;
-import org.jboss.ws.core.SOAPMessageUnMarshaller;
import org.jboss.ws.core.jaxrpc.StubExt;
import org.jboss.ws.extras.xop.XOPContext;
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java
(from rev 1586,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageMarshaller.java 2006-12-07
00:31:03 UTC (rev 1586)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,89 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.ws.core.soap;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.invocation.OnewayInvocation;
+import org.jboss.remoting.marshal.Marshaller;
+/**
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Nov-2004
+ */
+public class SOAPMessageMarshaller implements Marshaller
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SOAPMessageMarshaller.class);
+
+ /**
+ * Marshaller will need to take the dataObject and convert
+ * into primitive java data types and write to the
+ * given output.
+ *
+ * @param dataObject Object to be writen to output
+ * @param output The data output to write the object
+ * data to.
+ */
+ public void write(Object dataObject, OutputStream output) throws IOException
+ {
+ if (dataObject instanceof InvocationRequest)
+ dataObject = ((InvocationRequest)dataObject).getParameter();
+
+ if (dataObject instanceof OnewayInvocation)
+ dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
+
+ if ((dataObject instanceof SOAPMessage) == false)
+ throw new IllegalArgumentException("Not a SOAPMessage: " +
dataObject);
+
+ try
+ {
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)dataObject;
+
+ // debug the outgoing message
+ if (log.isTraceEnabled())
+ {
+ SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
+ String envStr = SOAPElementWriter.writeElement((SOAPElementImpl)soapEnv,
true);
+ log.trace("Outgoing SOAPMessage\n" + envStr);
+ }
+
+ soapMessage.writeTo(output);
+ }
+ catch (SOAPException e)
+ {
+ log.error("Cannot marshall SOAPMessage", e);
+ throw new IOException(e.toString());
+ }
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ return new SOAPMessageMarshaller();
+ }
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
(from rev 1587,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/SOAPMessageUnMarshaller.java 2006-12-07
00:41:57 UTC (rev 1587)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.soap;
+
+// $Id$
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.ws.WSException;
+
+/**
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Nov-2004
+ */
+public class SOAPMessageUnMarshaller implements UnMarshaller
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SOAPMessageUnMarshaller.class);
+
+ private static List validResponseCodes = new ArrayList();
+ static
+ {
+ validResponseCodes.add(HttpServletResponse.SC_OK);
+ validResponseCodes.add(HttpServletResponse.SC_ACCEPTED);
+ validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+
+ public Object read(InputStream inputStream, Map metadata) throws IOException,
ClassNotFoundException
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Read input stream with metadata=" + metadata);
+ }
+
+ try
+ {
+ Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
+ String resMessage =
(String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
+ if (resCode != null && validResponseCodes.contains(resCode) == false)
+ throw new WSException("Invalid HTTP server response [" + resCode +
"] - " + resMessage);
+
+ MimeHeaders mimeHeaders = getMimeHeaders(metadata);
+ SOAPMessage soapMsg = new
MessageFactoryImpl().createMessageInternal(mimeHeaders, inputStream, true);
+ return soapMsg;
+ }
+ catch (SOAPException e)
+ {
+ log.error("Cannot unmarshall SOAPMessage", e);
+ throw new IOException(e.toString());
+ }
+ }
+
+ /**
+ * Set the class loader to use for unmarhsalling. This may
+ * be needed when need to have access to class definitions that
+ * are not part of this unmarshaller's parent classloader (especially
+ * when doing remote classloading).
+ *
+ * @param classloader
+ */
+ public void setClassLoader(ClassLoader classloader)
+ {
+ //NO OP
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ return new SOAPMessageUnMarshaller();
+ }
+
+ private MimeHeaders getMimeHeaders(Map metadata)
+ {
+ log.debug("getMimeHeaders from: " + metadata);
+
+ MimeHeaders headers = new MimeHeaders();
+ Iterator i = metadata.keySet().iterator();
+ while (i.hasNext())
+ {
+ String key = (String)i.next();
+ Object value = metadata.get(key);
+ if (key != null && value instanceof List)
+ {
+ for (Object listValue : (List)value)
+ {
+ headers.addHeader(key, listValue.toString());
+ }
+ }
+ }
+ return headers;
+ }
+}
Copied:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
(from rev 1586,
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java)
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/ThreadLocalAssociation.java 2006-12-07
00:31:03 UTC (rev 1586)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.utils;
+
+// $Id$
+
+import java.util.Stack;
+
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.extras.security.SecurityStore;
+
+/**
+ * Maintain thread locals at a single point.
+ *
+ * @author Heiko Braun, <heiko(a)openj.net>
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 10-Apr-2006
+ */
+public class ThreadLocalAssociation
+{
+
+ /**
+ * Handles invocations on MDB endpoints.
+ */
+ private static ThreadLocal invokerMDBAssoc = new ThreadLocal();
+
+ /**
+ * SOAP message context
+ * @see org.jboss.ws.core.soap.MessageContextAssociation
+ */
+ private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc =
new ThreadLocal<Stack<CommonMessageContext>>();
+
+ /**
+ * @see org.jboss.ws.extras.security.STRTransform
+ */
+ private static ThreadLocal<SecurityStore> strTransformAssoc = new
ThreadLocal<SecurityStore>();
+
+ public static ThreadLocal localInvokerMDBAssoc()
+ {
+ return invokerMDBAssoc;
+ }
+
+ public static ThreadLocal<Stack<CommonMessageContext>>
localMsgContextAssoc()
+ {
+ return msgContextAssoc;
+ }
+
+ public static ThreadLocal<SecurityStore> localStrTransformAssoc()
+ {
+ return strTransformAssoc;
+ }
+
+ public static void clear()
+ {
+ invokerMDBAssoc.set(null);
+ msgContextAssoc.set(null);
+ strTransformAssoc.set(null);
+ }
+}
Modified:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/security/STRTransform.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/security/STRTransform.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/security/STRTransform.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -35,7 +35,7 @@
import org.apache.xml.security.utils.XMLUtils;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.ThreadLocalAssociation;
+import org.jboss.ws.core.utils.ThreadLocalAssociation;
import org.jboss.ws.extras.security.element.BinarySecurityToken;
import org.jboss.ws.extras.security.element.SecurityTokenReference;
import org.w3c.dom.Element;
Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/xop/XOPContext.java
===================================================================
---
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/xop/XOPContext.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/main/java/org/jboss/ws/extras/xop/XOPContext.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -201,7 +201,7 @@
* would already have been written.
*
* @see
org.jboss.ws.core.soap.SOAPConnectionImpl#callInternal(javax.xml.soap.SOAPMessage, Object,
boolean)
- * @see org.jboss.ws.core.SOAPMessageMarshaller#write(Object, java.io.OutputStream)
+ * @see org.jboss.ws.core.soap.SOAPMessageMarshaller#write(Object,
java.io.OutputStream)
*/
public static void eagerlyCreateAttachments()
{
Modified:
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/binding/SOAPBindingTestCase.java
===================================================================
---
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/binding/SOAPBindingTestCase.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/binding/SOAPBindingTestCase.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -36,11 +36,11 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonBinding;
-import org.jboss.ws.core.CommonBindingProvider;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.CommonSOAPBinding;
import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.binding.CommonBinding;
+import org.jboss.ws.core.binding.CommonBindingProvider;
+import org.jboss.ws.core.binding.CommonSOAPBinding;
import org.jboss.ws.core.jaxrpc.CallImpl;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;
Modified:
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/soap/attachment/GenericAttachmentTestCase.java
===================================================================
---
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/soap/attachment/GenericAttachmentTestCase.java 2006-12-07
00:48:06 UTC (rev 1588)
+++
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/common/soap/attachment/GenericAttachmentTestCase.java 2006-12-07
00:50:28 UTC (rev 1589)
@@ -41,10 +41,10 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.CommonBinding;
-import org.jboss.ws.core.CommonBindingProvider;
-import org.jboss.ws.core.CommonSOAPBinding;
import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.binding.CommonBinding;
+import org.jboss.ws.core.binding.CommonBindingProvider;
+import org.jboss.ws.core.binding.CommonSOAPBinding;
import org.jboss.ws.core.jaxrpc.CallImpl;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
import org.jboss.ws.core.metadata.umdm.OperationMetaData;