[jboss-svn-commits] JBossWS SVN: r643 - in trunk/src: main/java/org/jboss/ws/handler main/java/org/jboss/ws/jaxws main/java/org/jboss/ws/jaxws/handler main/java/org/jboss/ws/soap test/ant test/java/org/jboss/test/ws/jaxws test/java/org/jboss/test/ws/jaxws/context test/resources/jaxws test/resources/jaxws/context test/resources/jaxws/context/WEB-INF test/resources/jaxws/context/WEB-INF/wsdl
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Jul 30 08:25:26 EDT 2006
Author: thomas.diesler at jboss.com
Date: 2006-07-30 08:25:17 -0400 (Sun, 30 Jul 2006)
New Revision: 643
Added:
trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java
trunk/src/main/java/org/jboss/ws/jaxws/handler/
trunk/src/main/java/org/jboss/ws/jaxws/handler/MessageContextImpl.java
trunk/src/main/java/org/jboss/ws/jaxws/handler/SOAPMessageContextImpl.java
trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java
trunk/src/test/java/org/jboss/test/ws/jaxws/context/
trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointBean.java
trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java
trunk/src/test/java/org/jboss/test/ws/jaxws/context/WebServiceContextTestCase.java
trunk/src/test/resources/jaxws/context/
trunk/src/test/resources/jaxws/context/WEB-INF/
trunk/src/test/resources/jaxws/context/WEB-INF/web.xml
trunk/src/test/resources/jaxws/context/WEB-INF/wsdl/
trunk/src/test/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl
Removed:
trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java
trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java
Modified:
trunk/src/test/ant/build-jars.xml
Log:
WebServiceContext initial
Deleted: trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -1,109 +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.handler;
-
-// $Id$
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.xml.rpc.handler.MessageContext;
-
-/**
- * The message context that is processed by a handler
- * in the handle method.
- * <p/>
- * Provides methods to manage a property set.
- * MessageContext properties enable handlers in a handler chain to share
- * processing related state.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 06-May-2004
- */
-public class MessageContextImpl implements MessageContext
-{
- public static final String SERVLET_CONTEXT = "javax.xml.ws.servlet.context";
- public static final String SERVLET_REQUEST = "javax.xml.ws.servlet.request";
- public static final String SERVLET_RESPONSE = "javax.xml.ws.servlet.response";
- public static final String SERVLET_SESSION = "javax.xml.ws.servlet.session";
-
- // The map of the properties
- private HashMap<String, Object> props = new HashMap<String, Object>();
-
- /**
- * Returns true if the MessageContext contains a property with the specified name.
- *
- * @param name Name of the property whose presense is to be tested
- * @return Returns true if the MessageContext contains the property; otherwise false
- */
- public boolean containsProperty(String name)
- {
- return props.containsKey(name);
- }
-
- /**
- * Gets the value of a specific property from the MessageContext
- *
- * @param name Name of the property whose value is to be retrieved
- * @return Value of the property
- * @throws IllegalArgumentException if an illegal property name is specified
- */
- public Object getProperty(String name)
- {
- return props.get(name);
- }
-
- /**
- * Returns an Iterator view of the names of the properties in this MessageContext
- *
- * @return Iterator for the property names
- */
- public Iterator getPropertyNames()
- {
- return props.keySet().iterator();
- }
-
- /**
- * Removes a property (name-value pair) from the MessageContext
- *
- * @param name Name of the property to be removed
- * @throws IllegalArgumentException if an illegal property name is specified
- */
- public void removeProperty(String name)
- {
- props.remove(name);
- }
-
- /**
- * Sets the name and value of a property associated with the MessageContext.
- * If the MessageContext contains a value of the same property, the old value is replaced.
- *
- * @param name Name of the property associated with the MessageContext
- * @param value Value of the property
- * @throws IllegalArgumentException If some aspect of the property is prevents it from being stored in the context
- * @throws UnsupportedOperationException If this method is not supported.
- */
- public void setProperty(String name, Object value)
- {
- props.put(name, value);
- }
-}
Added: trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,109 @@
+/*
+ * 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.handler;
+
+// $Id$
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.rpc.handler.MessageContext;
+
+/**
+ * The message context that is processed by a handler
+ * in the handle method.
+ * <p/>
+ * Provides methods to manage a property set.
+ * MessageContext properties enable handlers in a handler chain to share
+ * processing related state.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-May-2004
+ */
+public class MessageContextImpl implements MessageContext
+{
+ public static final String SERVLET_CONTEXT = "javax.xml.ws.servlet.context";
+ public static final String SERVLET_REQUEST = "javax.xml.ws.servlet.request";
+ public static final String SERVLET_RESPONSE = "javax.xml.ws.servlet.response";
+ public static final String SERVLET_SESSION = "javax.xml.ws.servlet.session";
+
+ // The map of the properties
+ private HashMap<String, Object> props = new HashMap<String, Object>();
+
+ /**
+ * Returns true if the MessageContext contains a property with the specified name.
+ *
+ * @param name Name of the property whose presense is to be tested
+ * @return Returns true if the MessageContext contains the property; otherwise false
+ */
+ public boolean containsProperty(String name)
+ {
+ return props.containsKey(name);
+ }
+
+ /**
+ * Gets the value of a specific property from the MessageContext
+ *
+ * @param name Name of the property whose value is to be retrieved
+ * @return Value of the property
+ * @throws IllegalArgumentException if an illegal property name is specified
+ */
+ public Object getProperty(String name)
+ {
+ return props.get(name);
+ }
+
+ /**
+ * Returns an Iterator view of the names of the properties in this MessageContext
+ *
+ * @return Iterator for the property names
+ */
+ public Iterator getPropertyNames()
+ {
+ return props.keySet().iterator();
+ }
+
+ /**
+ * Removes a property (name-value pair) from the MessageContext
+ *
+ * @param name Name of the property to be removed
+ * @throws IllegalArgumentException if an illegal property name is specified
+ */
+ public void removeProperty(String name)
+ {
+ props.remove(name);
+ }
+
+ /**
+ * Sets the name and value of a property associated with the MessageContext.
+ * If the MessageContext contains a value of the same property, the old value is replaced.
+ *
+ * @param name Name of the property associated with the MessageContext
+ * @param value Value of the property
+ * @throws IllegalArgumentException If some aspect of the property is prevents it from being stored in the context
+ * @throws UnsupportedOperationException If this method is not supported.
+ */
+ public void setProperty(String name, Object value)
+ {
+ props.put(name, value);
+ }
+}
Property changes on: trunk/src/main/java/org/jboss/ws/handler/MessageContextImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/main/java/org/jboss/ws/jaxws/handler/MessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/handler/MessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/jaxws/handler/MessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,121 @@
+/*
+ * 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.jaxws.handler;
+
+// $Id: MessageContextImpl.java 275 2006-05-04 21:36:29Z jason.greene at jboss.com $
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.handler.MessageContext;
+
+
+/**
+ * The interface MessageContext abstracts the message context that is processed by a handler in the handle method.
+ *
+ * The MessageContext interface provides methods to manage a property set.
+ * MessageContext properties enable handlers in a handler chain to share processing related state.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Jul-2006
+ */
+public class MessageContextImpl implements MessageContext
+{
+ // The map of the properties
+ private HashMap<String, Object> props = new HashMap<String, Object>();
+ // The map of property scopes
+ private HashMap<String, Scope> scopes = new HashMap<String, Scope>();
+
+ /** Sets the scope of a property. */
+ public void setScope(String key, Scope scope)
+ {
+ scopes.put(key, scope);
+ }
+
+ /** Gets the scope of a property. */
+ public Scope getScope(String key)
+ {
+ return scopes.get(key);
+ }
+
+ public int size()
+ {
+ return props.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return props.isEmpty();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return props.containsKey(key);
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return props.containsValue(value);
+ }
+
+ public Object get(Object key)
+ {
+ return props.get(key);
+ }
+
+ public Object put(String key, Object value)
+ {
+ return props.put(key, value);
+ }
+
+ public Object remove(Object key)
+ {
+ return props.remove(key);
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> srcMap)
+ {
+ props.putAll(srcMap);
+ }
+
+ public void clear()
+ {
+ props.clear();
+ }
+
+ public Set<String> keySet()
+ {
+ return props.keySet();
+ }
+
+ public Collection<Object> values()
+ {
+ return props.values();
+ }
+
+ public Set<Entry<String, Object>> entrySet()
+ {
+ return props.entrySet();
+ }
+}
Added: trunk/src/main/java/org/jboss/ws/jaxws/handler/SOAPMessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/handler/SOAPMessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/jaxws/handler/SOAPMessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,142 @@
+/*
+ * 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.jaxws.handler;
+
+// $Id: MessageContextImpl.java 275 2006-05-04 21:36:29Z jason.greene at jboss.com $
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/**
+ * The interface SOAPMessageContext provides access to the SOAP message for either RPC request or response.
+ * The javax.xml.soap.SOAPMessage specifies the standard Java API for the representation of a SOAP 1.1 message with attachments.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Jul-2006
+ */
+public class SOAPMessageContextImpl extends MessageContextImpl implements SOAPMessageContext
+{
+ // The SOAPMessage in this message context
+ private SOAPMessage soapMessage;
+ // The SOAP actor roles
+ private Set<URI> roles = new HashSet<URI>();
+
+ /** Default ctor */
+ public SOAPMessageContextImpl()
+ {
+ }
+
+ /** SOAP actor roles are invariant during the processing of SOAP message through the handler chain. */
+ public SOAPMessageContextImpl(Set<URI> roles)
+ {
+ if (roles != null)
+ this.roles = roles;
+ }
+
+ /**
+ * Gets the SOAPMessage from this message context.
+ * Modifications to the returned SOAPMessage change the message in-place, there is no need to susequently call setMessage.
+ */
+ public SOAPMessage getMessage()
+ {
+ return soapMessage;
+ }
+
+ /**
+ * Sets the SOAPMessage in this message context
+ */
+ public void setMessage(SOAPMessage soapMessage)
+ {
+ this.soapMessage = soapMessage;
+ }
+
+ /**
+ * Gets headers that have a particular qualified name from the message in the message context.
+ * Note that a SOAP message can contain multiple headers with the same qualified name.
+ */
+ public Object[] getHeaders(QName qname, JAXBContext context, boolean allRoles)
+ {
+ List<Object> headers = new ArrayList<Object>();
+
+ if (soapMessage != null)
+ {
+ try
+ {
+ SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ Iterator<SOAPHeaderElement> headerElements = soapHeader.examineAllHeaderElements();
+ while (headerElements.hasNext())
+ {
+ SOAPHeaderElement hElement = headerElements.next();
+ Name hName = hElement.getElementName();
+ if (qname.equals(new QName(hName.getURI(), hName.getLocalName())))
+ {
+ URI actor = new URI(hElement.getActor());
+ if (roles.contains(actor) || allRoles)
+ {
+ headers.add(hElement);
+
+ // FIXME
+ // SOAPMessageContext.getHeaders should return unmarshalled objects
+ // http://jira.jboss.org/jira/browse/JBWS-1105
+ }
+ }
+ }
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new WebServiceException("Cannot get headers", ex);
+ }
+ }
+
+ Object[] arr = new Object[headers.size()];
+ headers.toArray(arr);
+ return arr;
+ }
+
+ /**
+ * Gets the SOAP actor roles associated with an execution of the handler chain.
+ * Note that SOAP actor roles apply to the SOAP node and are managed using SOAPBinding.setRoles and SOAPBinding.getRoles.
+ * Handler instances in the handler chain use this information about the SOAP actor roles to process the SOAP header blocks.
+ * Note that the SOAP actor roles are invariant during the processing of SOAP message through the handler chain.
+ */
+ public Set<URI> getRoles()
+ {
+ return roles;
+ }
+}
Deleted: trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -1,166 +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.soap;
-
-// $Id$
-
-import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.ws.WSException;
-import org.jboss.ws.binding.SerializationContext;
-import org.jboss.ws.handler.MessageContextImpl;
-import org.jboss.ws.jaxrpc.JAXRPCSerializationContext;
-import org.jboss.ws.jaxws.JAXWSSerializationContext;
-import org.jboss.ws.metadata.EndpointMetaData;
-import org.jboss.ws.metadata.OperationMetaData;
-import org.jboss.ws.metadata.ServiceMetaData;
-import org.jboss.ws.metadata.EndpointMetaData.Type;
-import org.jboss.xb.binding.NamespaceRegistry;
-
-/**
- * Provides access to the SOAP message for either RPC request or response.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 14-Dec-2004
- */
-public class SOAPMessageContextImpl extends MessageContextImpl implements SOAPMessageContext
-{
- // The current SOAPMessage, maybe a request or response message
- private SOAPMessage soapMessage;
- // The operation for this message ctx
- private EndpointMetaData epMetaData;
- // The operation for this message ctx
- private OperationMetaData opMetaData;
- // The serialization context for this message ctx
- private SerializationContext serContext;
-
- /** Default constuctor
- */
- public SOAPMessageContextImpl()
- {
- }
-
- /** Gets the SOAPMessage from this message context
- *
- * @return Returns the SOAPMessage; returns null if no SOAPMessage is present in this message context
- */
- public SOAPMessage getMessage()
- {
- return soapMessage;
- }
-
- /** Sets the SOAPMessage in this message context
- *
- * @param message SOAP message
- * @throws javax.xml.rpc.JAXRPCException If any error during the setting of the SOAPMessage in this message context
- * @throws UnsupportedOperationException - If this operation is not supported
- */
- public void setMessage(SOAPMessage message)
- {
- this.soapMessage = message;
- }
-
- /**
- * Gets the SOAP actor roles associated with an execution of the HandlerChain and its contained Handler instances.
- * Note that SOAP actor roles apply to the SOAP node and are managed using HandlerChain.setRoles and HandlerChain.getRoles.
- * Handler instances in the HandlerChain use this information about the SOAP actor roles to process the SOAP header blocks.
- * Note that the SOAP actor roles are invariant during the processing of SOAP message through the HandlerChain.
- *
- * @return Array of URIs for SOAP actor roles
- */
- public String[] getRoles()
- {
- return new String[0];
- }
-
- public EndpointMetaData getEndpointMetaData()
- {
- if (epMetaData == null && opMetaData != null)
- epMetaData = opMetaData.getEndpointMetaData();
-
- return epMetaData;
- }
-
- public void setEndpointMetaData(EndpointMetaData epMetaData)
- {
- this.epMetaData = epMetaData;
- }
-
- public OperationMetaData getOperationMetaData()
- {
- return opMetaData;
- }
-
- public void setOperationMetaData(OperationMetaData opMetaData)
- {
- this.opMetaData = opMetaData;
- }
-
- /** Get or create the serialization context
- */
- public SerializationContext getSerializationContext()
- {
- if (serContext == null)
- {
- EndpointMetaData epMetaData = getEndpointMetaData();
- ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
-
- if (epMetaData.getType() == Type.JAXWS)
- {
- JAXWSSerializationContext jaxwsContext = new JAXWSSerializationContext();
- jaxwsContext.setTypeMapping(serviceMetaData.getTypeMapping());
- serContext = jaxwsContext;
- }
- else
- {
- JAXRPCSerializationContext jaxrpcContext = new JAXRPCSerializationContext();
- jaxrpcContext.setTypeMapping(serviceMetaData.getTypeMapping());
- jaxrpcContext.setJavaWsdlMapping(serviceMetaData.getJavaWsdlMapping());
- serContext = jaxrpcContext;
- }
- }
-
- serContext.setNamespaceRegistry(getNamespaceRegistry());
- return serContext;
- }
-
- /** Get the namespace registry from the current SOAPEnvelope
- */
- public NamespaceRegistry getNamespaceRegistry()
- {
- if (soapMessage == null)
- throw new WSException("Cannot obtain NamespaceRegistry, because there is no SOAPMessage associated with this context");
-
- try
- {
- SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapMessage.getSOAPPart().getEnvelope();
- NamespaceRegistry nsRegistry = soapEnv.getNamespaceRegistry();
- return nsRegistry;
- }
- catch (SOAPException e)
- {
- throw new WSException("Cannot get SOAPEnvelope: " + e);
- }
- }
-}
Added: trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,166 @@
+/*
+ * 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.soap;
+
+// $Id$
+
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.binding.SerializationContext;
+import org.jboss.ws.handler.MessageContextImpl;
+import org.jboss.ws.jaxrpc.JAXRPCSerializationContext;
+import org.jboss.ws.jaxws.JAXWSSerializationContext;
+import org.jboss.ws.metadata.EndpointMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ServiceMetaData;
+import org.jboss.ws.metadata.EndpointMetaData.Type;
+import org.jboss.xb.binding.NamespaceRegistry;
+
+/**
+ * Provides access to the SOAP message for either RPC request or response.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Dec-2004
+ */
+public class SOAPMessageContextImpl extends MessageContextImpl implements SOAPMessageContext
+{
+ // The current SOAPMessage, maybe a request or response message
+ private SOAPMessage soapMessage;
+ // The operation for this message ctx
+ private EndpointMetaData epMetaData;
+ // The operation for this message ctx
+ private OperationMetaData opMetaData;
+ // The serialization context for this message ctx
+ private SerializationContext serContext;
+
+ /** Default constuctor
+ */
+ public SOAPMessageContextImpl()
+ {
+ }
+
+ /** Gets the SOAPMessage from this message context
+ *
+ * @return Returns the SOAPMessage; returns null if no SOAPMessage is present in this message context
+ */
+ public SOAPMessage getMessage()
+ {
+ return soapMessage;
+ }
+
+ /** Sets the SOAPMessage in this message context
+ *
+ * @param message SOAP message
+ * @throws javax.xml.rpc.JAXRPCException If any error during the setting of the SOAPMessage in this message context
+ * @throws UnsupportedOperationException - If this operation is not supported
+ */
+ public void setMessage(SOAPMessage message)
+ {
+ this.soapMessage = message;
+ }
+
+ /**
+ * Gets the SOAP actor roles associated with an execution of the HandlerChain and its contained Handler instances.
+ * Note that SOAP actor roles apply to the SOAP node and are managed using HandlerChain.setRoles and HandlerChain.getRoles.
+ * Handler instances in the HandlerChain use this information about the SOAP actor roles to process the SOAP header blocks.
+ * Note that the SOAP actor roles are invariant during the processing of SOAP message through the HandlerChain.
+ *
+ * @return Array of URIs for SOAP actor roles
+ */
+ public String[] getRoles()
+ {
+ return new String[0];
+ }
+
+ public EndpointMetaData getEndpointMetaData()
+ {
+ if (epMetaData == null && opMetaData != null)
+ epMetaData = opMetaData.getEndpointMetaData();
+
+ return epMetaData;
+ }
+
+ public void setEndpointMetaData(EndpointMetaData epMetaData)
+ {
+ this.epMetaData = epMetaData;
+ }
+
+ public OperationMetaData getOperationMetaData()
+ {
+ return opMetaData;
+ }
+
+ public void setOperationMetaData(OperationMetaData opMetaData)
+ {
+ this.opMetaData = opMetaData;
+ }
+
+ /** Get or create the serialization context
+ */
+ public SerializationContext getSerializationContext()
+ {
+ if (serContext == null)
+ {
+ EndpointMetaData epMetaData = getEndpointMetaData();
+ ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
+
+ if (epMetaData.getType() == Type.JAXWS)
+ {
+ JAXWSSerializationContext jaxwsContext = new JAXWSSerializationContext();
+ jaxwsContext.setTypeMapping(serviceMetaData.getTypeMapping());
+ serContext = jaxwsContext;
+ }
+ else
+ {
+ JAXRPCSerializationContext jaxrpcContext = new JAXRPCSerializationContext();
+ jaxrpcContext.setTypeMapping(serviceMetaData.getTypeMapping());
+ jaxrpcContext.setJavaWsdlMapping(serviceMetaData.getJavaWsdlMapping());
+ serContext = jaxrpcContext;
+ }
+ }
+
+ serContext.setNamespaceRegistry(getNamespaceRegistry());
+ return serContext;
+ }
+
+ /** Get the namespace registry from the current SOAPEnvelope
+ */
+ public NamespaceRegistry getNamespaceRegistry()
+ {
+ if (soapMessage == null)
+ throw new WSException("Cannot obtain NamespaceRegistry, because there is no SOAPMessage associated with this context");
+
+ try
+ {
+ SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapMessage.getSOAPPart().getEnvelope();
+ NamespaceRegistry nsRegistry = soapEnv.getNamespaceRegistry();
+ return nsRegistry;
+ }
+ catch (SOAPException e)
+ {
+ throw new WSException("Cannot get SOAPEnvelope: " + e);
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/jboss/ws/soap/SOAPMessageContextImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/test/ant/build-jars.xml
===================================================================
--- trunk/src/test/ant/build-jars.xml 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/ant/build-jars.xml 2006-07-30 12:25:17 UTC (rev 643)
@@ -309,6 +309,17 @@
</metainf>
</jar>
+ <!-- jbossws-jaxws-context -->
+ <war warfile="${build.test.dir}/libs/jbossws-jaxws-context.war" webxml="${build.test.dir}/resources/jaxws/context/WEB-INF/web.xml">
+ <classes dir="${build.test.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/context/EndpointBean.class"/>
+ <include name="org/jboss/test/ws/jaxws/context/EndpointInterface.class"/>
+ </classes>
+ <webinf dir="${build.test.dir}/resources/jaxws/context/WEB-INF">
+ <include name="wsdl/**"/>
+ </webinf>
+ </war>
+
<!-- jbossws-jaxws-endpoint -->
<war warfile="${build.test.dir}/libs/jbossws-jaxws-endpoint.war" webxml="${build.test.dir}/resources/jaxws/endpoint/WEB-INF/web.xml">
<classes dir="${build.test.dir}/classes">
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointBean.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointBean.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointBean.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,47 @@
+/*
+ * 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.test.ws.jaxws.context;
+
+import javax.annotation.Resource;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+ at WebService(name = "EndpointInterface", targetNamespace = "http://org.jboss.ws/jaxws/context", serviceName = "TestService")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public class EndpointBean
+{
+ @Resource
+ private WebServiceContext context;
+
+ @WebMethod
+ public String echo(String input)
+ {
+ SOAPMessageContext msgContext = (SOAPMessageContext)context.getMessageContext();
+ SOAPMessage soapMessage = msgContext.getMessage();
+
+ return input;
+ }
+}
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,30 @@
+/*
+ * 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.test.ws.jaxws.context;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface EndpointInterface extends Remote
+{
+ String echo(String input) throws RemoteException;
+}
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/context/WebServiceContextTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/context/WebServiceContextTestCase.java 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/context/WebServiceContextTestCase.java 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,72 @@
+/*
+ * 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.test.ws.jaxws.context;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.test.ws.JBossWSTest;
+import org.jboss.test.ws.JBossWSTestSetup;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory;
+
+/**
+ * Test JAXWS WebServiceContext
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Apr-2005
+ */
+public class WebServiceContextTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return JBossWSTestSetup.newTestSetup(WebServiceContextTestCase.class, "jbossws-jaxws-context.war");
+ }
+
+ public void testWSDLAccess() throws MalformedURLException
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jbossws-jaxws-context?wsdl");
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
+ assertNotNull(wsdlDefinitions);
+ }
+
+ public void testClientAccess() throws Exception
+ {
+ // Create the port
+ URL wsdlURL = new File("resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl").toURL();
+ QName qname = new QName("http://org.jboss.ws/jaxws/context", "TestService");
+ Service service = Service.create(wsdlURL, qname);
+ EndpointInterface port = (EndpointInterface)service.getPort(EndpointInterface.class);
+
+ String helloWorld = "Hello world!";
+ Object retObj = port.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+
+}
Added: trunk/src/test/resources/jaxws/context/WEB-INF/web.xml
===================================================================
--- trunk/src/test/resources/jaxws/context/WEB-INF/web.xml 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/resources/jaxws/context/WEB-INF/web.xml 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.context.EndpointBean</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
Added: trunk/src/test/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl
===================================================================
--- trunk/src/test/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl 2006-07-26 17:32:24 UTC (rev 642)
+++ trunk/src/test/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl 2006-07-30 12:25:17 UTC (rev 643)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<definitions name="TestService" targetNamespace="http://org.jboss.ws/jaxws/context" xmlns:tns="http://org.jboss.ws/jaxws/context"
+ xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types/>
+ <message name="EndpointInterface_echo">
+ <part name="String_1" type="xsd:string"/>
+ </message>
+ <message name="EndpointInterface_echoResponse">
+ <part name="result" type="xsd:string"/>
+ </message>
+ <portType name="EndpointInterface">
+ <operation name="echo" parameterOrder="String_1">
+ <input message="tns:EndpointInterface_echo"/>
+ <output message="tns:EndpointInterface_echoResponse"/>
+ </operation>
+ </portType>
+ <binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="echo">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://org.jboss.ws/jaxws/context"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://org.jboss.ws/jaxws/context"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="TestService">
+ <port name="EndpointInterfacePort" binding="tns:EndpointInterfaceBinding">
+ <soap:address location="http://@jbosstest.host.name@:8080/jbossws-jaxws-context"/>
+ </port>
+ </service>
+</definitions>
More information about the jboss-svn-commits
mailing list