JBossWS SVN: r2700 - in branches/jbossws-1.2.1: jbossws-core/src/java/org/jboss/ws/core/server and 3 other directories.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-28 05:17:06 -0400 (Wed, 28 Mar 2007)
New Revision: 2700
Added:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointServlet.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/EndpointContext.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
Log:
[JBWS-1515] Regression: Set-Cookie MIME headers not available anymore
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -21,6 +21,8 @@
*/
package javax.xml.soap;
+// $Id$
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -32,42 +34,47 @@
* This class is used primarily when an application wants to retrieve specific
* attachments based on certain MIME headers and values. This class will most
* likely be used by implementations of AttachmentPart and other MIME dependent
- * parts of the SAAJ API.
-
+ * parts of the SAAJ API.
+ *
* @author Scott.Stark(a)jboss.org
- * @version $Revision$
+ * @author Thomas.Diesler(a)jboss.org
*/
public class MimeHeaders
{
private LinkedList headers = new LinkedList();
- public MimeHeaders()
- {
- }
-
/**
+ * Adds a MimeHeader object with the specified name and value to this MimeHeaders object's list of headers.
*
- * @param name
- * @param value
- * @throws IllegalArgumentException - if name is null or empty.
+ * Note that RFC822 headers can contain only US-ASCII characters.
+ *
+ * @param name a String with the name of the header to be added
+ * @param value a String with the value of the header to be added
+ * @throws IllegalArgumentException - if there was a problem in the mime header name or value being added
*/
public void addHeader(String name, String value) throws IllegalArgumentException
{
if (name == null || name.length() == 0)
throw new IllegalArgumentException("Invalid null or empty header name");
+
MimeHeader header = new MimeHeader(name, value);
headers.add(header);
}
+ /**
+ * Returns all the MimeHeaders in this MimeHeaders object.
+ * @return an Iterator object over this MimeHeaders object's list of MimeHeader objects
+ */
public Iterator getAllHeaders()
{
return headers.iterator();
}
/**
+ * Returns all of the values for the specified header as an array of String objects.
*
- * @param name
- * @return All matching header values if found, null otherwise
+ * @param name the name of the header for which values will be returned
+ * @return a String array with all of the values for the specified header
*/
public String[] getHeader(String name)
{
@@ -87,23 +94,40 @@
return values;
}
+ /**
+ * Returns all the MimeHeader objects whose name matches a name in the given array of names.
+ * @param names an array of String objects with the names for which to search
+ * @return an Iterator object over the MimeHeader objects whose name matches one of the names in the given list
+ */
public Iterator getMatchingHeaders(String[] names)
{
- MatchingIter iter = new MatchingIter(headers, names, true);
+ MatchingIterator iter = new MatchingIterator(headers, names, true);
return iter;
}
+ /**
+ * Returns all of the MimeHeader objects whose name does not match a name in the given array of names.
+ * @param names an array of String objects with the names for which to search
+ * @return an Iterator object over the MimeHeader objects whose name does not match one of the names in the given list
+ */
public Iterator getNonMatchingHeaders(String[] names)
{
- MatchingIter iter = new MatchingIter(headers, names, false);
+ MatchingIterator iter = new MatchingIterator(headers, names, false);
return iter;
}
+ /**
+ * Removes all the header entries from this MimeHeaders object.
+ */
public void removeAllHeaders()
{
headers.clear();
}
+ /**
+ * Remove all MimeHeader objects whose name matches the given name.
+ * @param name a String with the name of the header for which to search
+ */
public void removeHeader(String name)
{
Iterator iter = headers.iterator();
@@ -115,11 +139,17 @@
}
}
- /** Replaces the current value of the first header entry whose name matches
+ /**
+ * Replaces the current value of the first header entry whose name matches
* the given name with the given value, adding a new header if no existing
* header name matches. This method also removes all matching headers after
* the first one.
*
+ * Note that RFC822 headers can contain only US-ASCII characters.
+ *
+ * @param name a String with the name of the header for which to search
+ * @param value a String with the value that will replace the current value of the specified header
+ * @throws IllegalArgumentException if there was a problem in the mime header name or the value being set
*/
public void setHeader(String name, String value)
{
@@ -149,7 +179,7 @@
}
}
- private static class MatchingIter implements Iterator
+ private static class MatchingIterator implements Iterator
{
private LinkedList headers;
private HashSet names;
@@ -157,7 +187,7 @@
private int index;
private MimeHeader mh;
- MatchingIter(LinkedList headers, String[] names, boolean match)
+ MatchingIterator(LinkedList headers, String[] names, boolean match)
{
this.headers = headers;
this.index = 0;
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointServlet.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointServlet.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointServlet.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -106,7 +106,7 @@
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
- if(log.isDebugEnabled()) log.debug("doPost: " + req.getRequestURI());
+ log.debug("doPost: " + req.getRequestURI());
try
{
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/EndpointContext.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/EndpointContext.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/EndpointContext.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -51,7 +51,7 @@
public HttpSession getHttpSession()
{
- return request.getSession();
+ return request.getSession(true);
}
public MessageContext getMessageContext()
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -37,9 +37,11 @@
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.activation.DataHandler;
@@ -47,8 +49,10 @@
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@@ -148,13 +152,13 @@
{
if (host == null || host.trim().length() == 0)
{
- if(log.isDebugEnabled()) log.debug("Using undefined host: " + UNDEFINED_HOSTNAME);
+ log.debug("Using undefined host: " + UNDEFINED_HOSTNAME);
host = UNDEFINED_HOSTNAME;
}
if ("0.0.0.0".equals(host))
{
InetAddress localHost = InetAddress.getLocalHost();
- if(log.isDebugEnabled()) log.debug("Using local host: " + localHost.getHostName());
+ log.debug("Using local host: " + localHost.getHostName());
host = localHost.getHostName();
}
this.webServiceHost = host;
@@ -394,6 +398,8 @@
public void processSOAPRequest(ObjectName sepID, InputStream inStream, OutputStream outStream, EndpointContext context) throws Exception
{
+ final String SESSION_COOKIES = "org.jboss.ws.cookies";
+
ServiceEndpoint wsEndpoint = getServiceEndpointByID(sepID);
if (wsEndpoint == null)
throw new WSException("Cannot obtain endpoint for: " + sepID);
@@ -402,12 +408,32 @@
ServerEndpointMetaData sepMetaData = wsEndpoint.getServiceEndpointInfo().getServerEndpointMetaData();
Type type = sepMetaData.getType();
- PropertyCallback httpSessionCallback = new HttpSessionPropertyCallback(context);
ServletContext servletContext = context.getServletContext();
HttpServletRequest httpRequest = context.getHttpServletRequest();
HttpServletResponse httpResponse = context.getHttpServletResponse();
ServletHeaderSource headerSource = new ServletHeaderSource(httpRequest, httpResponse);
-
+
+ // Default to does not create a new HTTPSession
+ Object lasySession = new HttpSessionPropertyCallback(context);
+
+ Cookie[] cookies = httpRequest.getCookies();
+ if (cookies != null)
+ {
+ HttpSession httpSession = httpRequest.getSession(true);
+ lasySession = httpSession;
+
+ Set<Cookie> sessionCoookies = (Set<Cookie>)httpSession.getAttribute(SESSION_COOKIES);
+ if (sessionCoookies == null)
+ {
+ sessionCoookies = new HashSet<Cookie>();
+ httpSession.setAttribute(SESSION_COOKIES, sessionCoookies);
+ }
+ for (Cookie cookie : cookies)
+ {
+ sessionCoookies.add(cookie);
+ }
+ }
+
// Associate a message context with the current thread
CommonMessageContext msgContext;
if (type == EndpointMetaData.Type.JAXRPC)
@@ -416,7 +442,7 @@
msgContext.put(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
msgContext.put(MessageContextJAXRPC.SERVLET_REQUEST, httpRequest);
msgContext.put(MessageContextJAXRPC.SERVLET_RESPONSE, httpResponse);
- msgContext.put(MessageContextJAXRPC.SERVLET_SESSION, httpSessionCallback);
+ msgContext.put(MessageContextJAXRPC.SERVLET_SESSION, lasySession);
}
else
{
@@ -466,6 +492,15 @@
httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
+ // Copy the cookies to the response
+ HttpSession httpSession = httpRequest.getSession();
+ Set<Cookie> sessionCoookies = httpSession != null ? (Set<Cookie>)httpSession.getAttribute(SESSION_COOKIES) : null;
+ if (sessionCoookies != null)
+ {
+ for (Cookie cookie : sessionCoookies)
+ httpResponse.addCookie(cookie);
+ }
+
sendResponse(outStream, msgContext, isFault);
}
finally
@@ -497,7 +532,7 @@
}
if (wsaTo != null)
{
- if(log.isDebugEnabled()) log.debug("Sending response to addressing destination: " + wsaTo);
+ log.debug("Sending response to addressing destination: " + wsaTo);
new SOAPConnectionImpl().callOneWay(resMessage, wsaTo);
}
else
@@ -510,7 +545,7 @@
*/
public String processSOAPRequest(ObjectName sepID, String inMessage) throws Exception
{
- if(log.isDebugEnabled()) log.debug("processSOAPRequest: " + sepID);
+ log.debug("processSOAPRequest: " + sepID);
ByteArrayInputStream inputStream = new ByteArrayInputStream(inMessage.getBytes("UTF-8"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(512);
@@ -620,7 +655,7 @@
// Register the endpoint with the MBeanServer
registry.put(sepID, wsEndpoint);
- if(log.isDebugEnabled()) log.debug("WebService created: " + sepID);
+ log.debug("WebService created: " + sepID);
}
/** Start a service endpoint
@@ -671,7 +706,7 @@
registry.remove(sepID);
ServiceEndpointInfo seInfo = wsEndpoint.getServiceEndpointInfo();
- if(log.isDebugEnabled()) log.debug("WebService destroyed: " + seInfo.getServerEndpointMetaData().getEndpointAddress());
+ log.debug("WebService destroyed: " + seInfo.getServerEndpointMetaData().getEndpointAddress());
}
public void create() throws Exception
@@ -686,7 +721,7 @@
public void destroy() throws Exception
{
- if(log.isDebugEnabled()) log.debug("Destroy service endpoint manager");
+ log.debug("Destroy service endpoint manager");
MBeanServer server = getJMXServer();
if (server != null)
{
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -102,7 +102,7 @@
private MimeHeaders getMimeHeaders(Map metadata)
{
- if(log.isDebugEnabled()) log.debug("getMimeHeaders from: " + metadata);
+ log.debug("getMimeHeaders from: " + metadata);
MimeHeaders headers = new MimeHeaders();
Iterator i = metadata.keySet().iterator();
Modified: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -1,32 +1,38 @@
/*
- * 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.
- */
+ * 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.jaxrpc.samples.handler;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPException;
@@ -71,6 +77,9 @@
SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
String rpcName = soapBodyElement.getElementName().getLocalName();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ mimeHeaders.setHeader("Cookie", "username=kermit");
+
// testInHeader
if (rpcName.equals("testInHeader"))
{
@@ -107,4 +116,22 @@
return true;
}
+
+ @Override
+ public boolean handleResponse(MessageContext msgContext)
+ {
+ log.info("handleResponse");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ String[] cookieValues = mimeHeaders.getHeader("Set-Cookie");
+ if (cookieValues == null)
+ throw new JAXRPCException("Cannot obtain cookie values");
+
+ List<String> cookieList = Arrays.asList(cookieValues);
+ if (!cookieList.contains("username=kermit"))
+ throw new JAXRPCException("Cannot obtain expected cookie value in: " + cookieList);
+
+ return true;
+ }
}
Modified: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-28 03:56:44 UTC (rev 2699)
+++ branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -63,6 +63,7 @@
handlerChain.add(new LogHandler());
handlerChain.add(new AuthorizationHandler());
handlerChain.add(new RoutingHandler());
+ handlerChain.add(new MimeHeaderHandler());
bindingProvider.getBinding().setHandlerChain(handlerChain);
String resStr = port.echo("Kermit");
Added: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java (rev 0)
+++ branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java 2007-03-28 09:17:06 UTC (rev 2700)
@@ -0,0 +1,75 @@
+/*
+ * 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.samples.handlerchain;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.rpc.JAXRPCException;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+
+/**
+ * A client side handler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 08-Oct-2005
+ */
+public class MimeHeaderHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(MimeHeaderHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ String[] cookieValues = mimeHeaders.getHeader("Set-Cookie");
+ if (cookieValues == null)
+ throw new JAXRPCException("Cannot obtain cookie values");
+
+ List<String> cookieList = Arrays.asList(cookieValues);
+ if (!cookieList.contains("username=kermit"))
+ throw new JAXRPCException("Cannot obtain expected cookie value in: " + cookieList);
+
+ return true;
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ mimeHeaders.setHeader("Cookie", "username=kermit");
+
+ return true;
+ }
+}
Property changes on: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 9 months
JBossWS SVN: r2699 - in trunk/jbossws-core/src/java/org/jboss/ws/core: jaxrpc/client and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-03-27 23:56:44 -0400 (Tue, 27 Mar 2007)
New Revision: 2699
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/CallImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/EndpointInfo.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
Log:
Initial implementation of http session affinity
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -75,7 +75,9 @@
{
// provide logging
private static Logger log = Logger.getLogger(CommonClient.class);
-
+
+ public static String SESSION_COOKIES = "org.jboss.ws.maintain.session.cookies";
+
// The endpoint together with the operationName uniquely identify the call operation
protected EndpointMetaData epMetaData;
// The current operation name
@@ -221,6 +223,8 @@
protected abstract void setInboundContextProperties();
protected abstract void setOutboundContextProperties();
+
+ protected abstract boolean shouldMaintainSession();
/** Call invokation goes as follows:
*
@@ -312,6 +316,8 @@
Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
+ if (shouldMaintainSession())
+ addSessionInfo(reqMessage, callProps);
SOAPMessage resMessage;
if (oneway)
@@ -322,12 +328,15 @@
{
resMessage = new SOAPConnectionImpl().call(reqMessage, epInfo);
}
+
+ if (shouldMaintainSession())
+ saveSessionInfo(callProps, getRequestContext());
// At pivot the message context might be replaced
msgContext = processPivotInternal(msgContext, direction);
// Copy the remoting meta data
- msgContext.putAll(callProps);
+ msgContext.put(CommonMessageContext.REMOTING_METADATA, callProps);
// Associate response message with message context
msgContext.setSOAPMessage(resMessage);
@@ -393,7 +402,57 @@
closeHandlerChain(portName, handlerType[0]);
}
}
+
+ private void saveSessionInfo(Map<String, Object> remotingMetadata, Map<String, Object> requestContext)
+ {
+ Map<String, String> cookies = (Map) remotingMetadata.get(SESSION_COOKIES);
+ if (cookies == null)
+ {
+ cookies = new HashMap<String, String>();
+ requestContext.put(SESSION_COOKIES, cookies);
+ }
+
+ List<String> setCookies = new ArrayList<String>();
+
+ List<String> setCookies1 = (List)remotingMetadata.get("Set-Cookie");
+ if (setCookies1 != null)
+ setCookies.addAll(setCookies1);
+
+ List<String> setCookies2 = (List)remotingMetadata.get("Set-Cookie2");
+ if (setCookies2 != null)
+ setCookies.addAll(setCookies2);
+
+ // TODO: The parsing here should be improved to be fully compliant with the RFC
+ for (String setCookie : setCookies)
+ {
+ int index = setCookie.indexOf(';');
+ if (index == -1)
+ continue;
+
+ String pair = setCookie.substring(0, index);
+ index = pair.indexOf('=');
+ if (index == -1)
+ continue;
+
+ String name = pair.substring(0, index);
+ String value = pair.substring(index + 1);
+
+ cookies.put(name, value);
+ }
+ }
+ protected void addSessionInfo(SOAPMessage reqMessage, Map<String, Object> callProperties)
+ {
+ Map<String, String> cookies = (Map) callProperties.get(SESSION_COOKIES);
+ if (cookies != null)
+ {
+ for (Map.Entry<String, String> cookie : cookies.entrySet())
+ {
+ reqMessage.getMimeHeaders().addHeader("Cookie" , cookie.getKey() + "=" + cookie.getValue());
+ }
+ }
+ }
+
private CommonMessageContext processPivotInternal(CommonMessageContext msgContext, DirectionHolder direction)
{
if (direction.getDirection() == Direction.OutBound)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -52,6 +52,8 @@
// expandToDOM in the SOAPContentElement should not happen during normal operation
// This property should be set the message context when it is ok to do so.
public static String ALLOW_EXPAND_TO_DOM = "org.jboss.ws.allow.expand.dom";
+
+ public static String REMOTING_METADATA = "org.jboss.ws.remoting.metadata";
// The serialization context for this message ctx
private SerializationContext serContext;
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/CallImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/CallImpl.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/CallImpl.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -671,4 +671,11 @@
return set;
}
+
+ @Override
+ protected boolean shouldMaintainSession()
+ {
+ Object bool = getRequestContext().get(Stub.SESSION_MAINTAIN_PROPERTY);
+ return Boolean.TRUE.equals(bool);
+ }
}
\ No newline at end of file
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -77,7 +77,7 @@
{
// provide logging
private static Logger log = Logger.getLogger(ClientImpl.class);
-
+
private final EndpointMetaData epMetaData;
private final HandlerResolver handlerResolver;
private Map<HandlerType, HandlerChainExecutor> executorMap = new HashMap<HandlerType, HandlerChainExecutor>();
@@ -178,17 +178,17 @@
{
// Get the HTTP_RESPONSE_CODE
MessageContext msgContext = (MessageContext)MessageContextAssociation.peekMessageContext();
- Integer resposeCode = (Integer)msgContext.get(HTTPMetadataConstants.RESPONSE_CODE);
+ Map<?, ?> remotingMetadata = (Map)msgContext.get(CommonMessageContext.REMOTING_METADATA);
+ Integer resposeCode = (Integer)remotingMetadata.get(HTTPMetadataConstants.RESPONSE_CODE);
if (resposeCode != null)
msgContext.put(MessageContextJAXWS.HTTP_RESPONSE_CODE, resposeCode);
// Map of attachments to a message for the inbound message, key is the MIME Content-ID, value is a DataHandler
msgContext.put(MessageContext.INBOUND_MESSAGE_ATTACHMENTS, new HashMap<String, DataHandler>());
- // Get the HTTP response headers
// [JBREM-728] Improve access to HTTP response headers
Map<String, List> headers = new HashMap<String, List>();
- for (Map.Entry en : msgContext.entrySet())
+ for (Map.Entry en : remotingMetadata.entrySet())
{
if (en.getKey() instanceof String && en.getValue() instanceof List)
headers.put((String)en.getKey(), (List)en.getValue());
@@ -380,4 +380,11 @@
return headers;
}
+
+ @Override
+ protected boolean shouldMaintainSession()
+ {
+ Object bool = getRequestContext().get(BindingProvider.SESSION_MAINTAIN_PROPERTY);
+ return Boolean.TRUE.equals(bool);
+ }
}
\ No newline at end of file
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/EndpointInfo.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/EndpointInfo.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/EndpointInfo.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -23,6 +23,7 @@
// $Id$
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -38,7 +39,6 @@
{
private String targetAddress;
private Map<String, Object> properties;
-
public EndpointInfo(EndpointMetaData epMetaData, String targetAddress, Map<String, Object> callProps)
{
this.targetAddress = targetAddress;
@@ -80,7 +80,7 @@
{
return targetAddress;
}
-
+
public boolean equals(Object obj)
{
if (!(obj instanceof EndpointInfo))
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2007-03-27 22:26:52 UTC (rev 2698)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2007-03-28 03:56:44 UTC (rev 2699)
@@ -159,6 +159,8 @@
timeout = callProps.get(StubExt.PROPERTY_CLIENT_TIMEOUT);
targetAddress = addURLParameter(targetAddress, "timeout", timeout.toString());
}
+
+
}
else if (endpoint instanceof EndpointReference)
{
17 years, 9 months
JBossWS SVN: r2698 - in branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws: core/jaxrpc/binding and 3 other directories.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 18:26:52 -0400 (Tue, 27 Mar 2007)
New Revision: 2698
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/TypeMappingImpl.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
Log:
Fix soap Array compXMLType detection
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/TypeMappingImpl.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/TypeMappingImpl.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/TypeMappingImpl.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -294,6 +294,18 @@
return xmlType;
}
+ /** Get the QNames that was registered last for this javaType */
+ public List<QName> getXMLTypes(Class javaType)
+ {
+ List<QName> xmlTypes = new ArrayList<QName>();
+
+ for (KeyPair kPair : getKeyPairs(null, javaType))
+ {
+ xmlTypes.add(kPair.getXmlType().toQName());
+ }
+ return xmlTypes;
+ }
+
/**
* Get the QName that was registered last for this javaType
* @param javaType class for which XML Type is needed
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -62,25 +62,22 @@
try
{
ParameterMetaData paramMetaData = (ParameterMetaData)serContext.getProperty(ParameterMetaData.class.getName());
- QName compXmlType = paramMetaData.getSOAPArrayCompType();
- int[] arrDims = getDimensionsFromAttribute(soapElement);
- Class compJavaType = getComponentTypeFromAttribute(soapElement, serContext);
- Object[] retArray = (Object[])Array.newInstance(compJavaType, arrDims);
+ QName compXmlType = getComponentTypeFromAttribute(soapElement);
+ paramMetaData.setSOAPArrayCompType(compXmlType);
- TypeMappingImpl typeMapping = serContext.getTypeMapping();
if (compXmlType == null)
- {
- compXmlType = typeMapping.getXMLType(compJavaType);
- paramMetaData.setSOAPArrayCompType(compXmlType);
- }
+ throw new WSException("Cannot obtain component xmlType: " + paramMetaData.getPartName());
- if (compXmlType == null)
- throw new WSException("Cannot obtain component xmlType for: " + compJavaType);
+ Class compJavaType = getJavaTypeForComponentType(compXmlType, serContext);
// Get the component type deserializer factory
log.debug("Get component deserializer for: [javaType=" + compJavaType.getName() + ",xmlType=" + compXmlType + "]");
+ int[] arrDims = getDimensionsFromAttribute(soapElement);
+ Object[] retArray = (Object[])Array.newInstance(compJavaType, arrDims);
+
+ TypeMappingImpl typeMapping = serContext.getTypeMapping();
DeserializerFactoryBase compDeserializerFactory = (DeserializerFactoryBase)typeMapping.getDeserializer(compJavaType, compXmlType);
if (compDeserializerFactory == null)
{
@@ -163,7 +160,7 @@
return arrDims;
}
- private Class getComponentTypeFromAttribute(Element arrayElement, SerializationContext serContext)
+ private QName getComponentTypeFromAttribute(Element arrayElement)
{
QName attrQName = new QName(Constants.URI_SOAP11_ENC, "arrayType");
QName arrayType = DOMUtils.getAttributeValueAsQName(arrayElement, attrQName);
@@ -175,6 +172,11 @@
int dimIndex = localPart.indexOf("[");
QName compXmlType = new QName(nsURI, localPart.substring(0, dimIndex));
+ return compXmlType;
+ }
+
+ private Class getJavaTypeForComponentType(QName compXmlType, SerializationContext serContext)
+ {
TypeMappingImpl typeMapping = serContext.getTypeMapping();
Class javaType = typeMapping.getJavaType(compXmlType);
if (javaType == null)
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArraySerializer.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -119,7 +119,7 @@
String nodeName = new NameImpl(compXmlName).getQualifiedName();
- buffer = new StringBuilder("<" + nodeName + " xmlns:" + Constants.PREFIX_SOAP11_ENC + "='http://schemas.xmlsoap.org/soap/encoding/' ");
+ buffer = new StringBuilder("<" + nodeName + " xmlns:" + Constants.PREFIX_SOAP11_ENC + "='" + Constants.URI_SOAP11_ENC + "' ");
if (!(value instanceof Object[]))
throw new WSException("Unsupported array type: " + javaType);
@@ -141,7 +141,8 @@
buffer.append(arrayType);
buffer.append(" xmlns:" + Constants.PREFIX_XSI + "='" + Constants.NS_SCHEMA_XSI + "'");
- buffer.append(" xmlns:" + compXmlType.getPrefix() + "='" + compXmlType.getNamespaceURI() + "'");
+ if (compXmlType.getNamespaceURI().equals(Constants.URI_SOAP11_ENC) == false)
+ buffer.append(" xmlns:" + compXmlType.getPrefix() + "='" + compXmlType.getNamespaceURI() + "'");
if (compXmlName.getNamespaceURI().length() > 0 && compXmlName.getNamespaceURI().equals(compXmlType.getNamespaceURI()) == false)
buffer.append(" xmlns:" + compXmlName.getPrefix() + "='" + compXmlName.getNamespaceURI() + "'");
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -30,8 +30,10 @@
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
+import javax.xml.soap.Text;
import org.jboss.logging.Logger;
+import org.jboss.ws.core.utils.DOMUtils;
import org.jboss.ws.core.utils.DOMWriter;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
@@ -48,6 +50,7 @@
// provide logging
private static Logger log = Logger.getLogger(HRefInlineHandler.class);
+ private SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
private SOAPBody soapBody;
public HRefInlineHandler(SOAPBody soapBody)
@@ -60,19 +63,16 @@
String bodyStr = DOMWriter.printNode(soapBody, true);
log.debug("Begin processHRefs:\n" + bodyStr);
+ SOAPBodyElement bodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
+ processElement(bodyElement);
+
Iterator it = soapBody.getChildElements();
while (it.hasNext())
{
- // Process the first body element, remove the others
+ // Remove id elements
SOAPElement soapElement = (SOAPElement)it.next();
- if (soapElement instanceof SOAPBodyElement)
- {
- processElement(soapElement);
- }
- else
- {
+ if ((soapElement instanceof SOAPBodyElement) == false)
soapBody.removeChild(soapElement);
- }
}
bodyStr = DOMWriter.printNode(soapBody, true);
@@ -100,7 +100,7 @@
private void processHRef(SOAPElement hrefElement, String href) throws SOAPException
{
- SOAPContentElement idElement = null;
+ SOAPElement idElement = null;
Iterator it = soapBody.getChildElements();
while (it.hasNext())
@@ -108,7 +108,7 @@
SOAPElement auxElement = (SOAPElement)it.next();
if (href.equals("#" + auxElement.getAttribute("id")))
{
- idElement = (SOAPContentElement)auxElement;
+ idElement = (SOAPElement)auxElement;
break;
}
}
@@ -119,20 +119,26 @@
// process nested hrefs
processElement(idElement);
- // Remove old content
- hrefElement.removeContents();
-
// Copy most attributes, except id
copyMostAttributes(hrefElement, idElement);
// Append id element children
- if (idElement.getChildElements().hasNext())
+ if (DOMUtils.hasChildElements(idElement))
{
Iterator itid = idElement.getChildElements();
while (itid.hasNext())
{
Node childNode = (Node)itid.next();
- hrefElement.appendChild(childNode);
+ if (childNode instanceof SOAPElement)
+ {
+ SOAPElement childClone = soapFactory.createElement((SOAPElement)childNode, true);
+ hrefElement.addChildElement(childClone);
+ }
+ else if (childNode instanceof Text)
+ {
+ String value = childNode.getValue();
+ hrefElement.setValue(value);
+ }
}
}
// If no children, copy the value
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -37,6 +37,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.jaxrpc.EncodedTypeMapping;
import org.jboss.ws.core.jaxrpc.LiteralTypeMapping;
import org.jboss.ws.core.jaxrpc.Style;
import org.jboss.ws.core.jaxrpc.TypeMappingImpl;
@@ -63,7 +64,6 @@
import org.jboss.ws.metadata.umdm.TypeMappingMetaData;
import org.jboss.ws.metadata.umdm.TypesMetaData;
import org.jboss.ws.metadata.umdm.WrappedParameter;
-import org.jboss.ws.metadata.wsdl.WSDLBinding;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperationInput;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperationOutput;
@@ -371,6 +371,7 @@
}
}
+ setupSOAPArrayParameter(outMetaData);
return outMetaData;
}
@@ -483,7 +484,17 @@
if (xmlTypeLocalPart.indexOf("ArrayOfArrayOf") >= 0)
compJavaType = compJavaType.getComponentType();
- QName compXMLType = new LiteralTypeMapping().getXMLType(compJavaType);
+ boolean isSoapEnc = xmlTypeLocalPart.toLowerCase().indexOf("soapenc") > 0;
+ TypeMappingImpl typeMapping = isSoapEnc ? new EncodedTypeMapping() : new LiteralTypeMapping();
+ QName compXMLType = typeMapping.getXMLType(compJavaType);
+
+ if (compXMLType != null)
+ {
+ boolean isBase64 = compXMLType.getLocalPart().startsWith("base64");
+ if (isBase64 && xmlTypeLocalPart.toLowerCase().indexOf("hex") > 0)
+ compXMLType = isSoapEnc ? Constants.TYPE_SOAP11_HEXBINARY : Constants.TYPE_LITERAL_HEXBINARY;
+ }
+
paramMetaData.setSOAPArrayCompType(compXMLType);
}
catch (ClassNotFoundException e)
@@ -839,6 +850,7 @@
}
setupXOPAttachmentParameter(wsdlOperation, outMetaData);
+ setupSOAPArrayParameter(outMetaData);
}
if (hasReturnMapping)
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-03-27 19:40:09 UTC (rev 2697)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-03-27 22:26:52 UTC (rev 2698)
@@ -367,9 +367,15 @@
return soapArrayCompType;
}
- public void setSOAPArrayCompType(QName xmlType)
+ public void setSOAPArrayCompType(QName compXmlType)
{
- this.soapArrayCompType = xmlType;
+ if (compXmlType != null && !compXmlType.equals(soapArrayCompType))
+ {
+ String logmsg = "SOAPArrayCompType: [xmlType=" + xmlType + ",compType=" + compXmlType + "]";
+ log.debug((soapArrayCompType == null ? "set" : "reset") + logmsg);
+ }
+
+ this.soapArrayCompType = compXmlType;
}
17 years, 9 months
JBossWS SVN: r2697 - trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client.
by jbossws-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-03-27 15:40:09 -0400 (Tue, 27 Mar 2007)
New Revision: 2697
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java
Log:
Fix JBCTS-460
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java 2007-03-27 19:38:24 UTC (rev 2696)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientProxy.java 2007-03-27 19:40:09 UTC (rev 2697)
@@ -37,6 +37,7 @@
import java.util.concurrent.Future;
import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Response;
@@ -204,12 +205,10 @@
Throwable th = ex;
if (ex instanceof SOAPFaultException)
{
- // The cause of a SOAPFaultException, if any, is the service specific exception
+ // Unwrap the cause if it is an Application Exception, otherwise use a protocol exception
Throwable cause = ex.getCause();
- if (cause != null)
- {
+ if (cause instanceof Exception && !(cause instanceof RuntimeException) && !(cause instanceof SOAPException))
th = cause;
- }
}
throw th;
}
17 years, 9 months
JBossWS SVN: r2696 - in trunk/jbossws-tests: ant-import and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-03-27 15:38:24 -0400 (Tue, 27 Mar 2007)
New Revision: 2696
Modified:
trunk/jbossws-tests/ant-import/build-samples-jaxrpc.xml
trunk/jbossws-tests/build.xml
Log:
disable bpel servicegen until it is compatible with wsdl4j 1.6.2
Modified: trunk/jbossws-tests/ant-import/build-samples-jaxrpc.xml
===================================================================
--- trunk/jbossws-tests/ant-import/build-samples-jaxrpc.xml 2007-03-27 17:17:38 UTC (rev 2695)
+++ trunk/jbossws-tests/ant-import/build-samples-jaxrpc.xml 2007-03-27 19:38:24 UTC (rev 2696)
@@ -526,7 +526,7 @@
</metainf>
</jar>
- <!-- jaxrpc-samples-wsbpel -->
+ <!-- jaxrpc-samples-wsbpel
<war warfile="${tests.output.dir}/libs/jaxrpc-samples-wsbpel-hello.war" webxml="${tests.output.dir}/resources/jaxrpc/samples/wsbpel/hello/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
<include name="org/jboss/test/ws/jaxrpc/samples/wsbpel/hello/HelloWorldService.class"/>
@@ -555,7 +555,7 @@
<include name="jaxrpc-mapping.xml"/>
</metainf>
</jar>
-
+ -->
<!-- jaxrpc-samples-wssecurity-sign -->
<war warfile="${tests.output.dir}/libs/jaxrpc-samples-wssecurity-sign.war" webxml="${tests.output.dir}/resources/jaxrpc/samples/wssecurity/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
Modified: trunk/jbossws-tests/build.xml
===================================================================
--- trunk/jbossws-tests/build.xml 2007-03-27 17:17:38 UTC (rev 2695)
+++ trunk/jbossws-tests/build.xml 2007-03-27 19:38:24 UTC (rev 2696)
@@ -29,7 +29,6 @@
<property name="tests.java.dir" value="${tests.dir}/src/java"/>
<property name="tests.resources.dir" value="${tests.dir}/src/resources"/>
<property name="tests.output.dir" value="${tests.dir}/output"/>
-
<!-- ================================================================== -->
<!-- Setup -->
<!-- ================================================================== -->
@@ -316,7 +315,7 @@
<wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/oneway/WEB-INF" config="${tests.resources.dir}/jaxrpc/samples/oneway/wstools-config.xml"/>
<wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/rpcstyle/WEB-INF" config="${tests.resources.dir}/jaxrpc/samples/rpcstyle/wstools-config.xml"/>
<wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/secureejb/META-INF" config="${tests.resources.dir}/jaxrpc/samples/secureejb/wstools-config.xml"/>
- <wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/wsbpel/hello/WEB-INF" config="${tests.resources.dir}/jaxrpc/samples/wsbpel/hello/wstools-config.xml"/>
+ <!-- <wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/wsbpel/hello/WEB-INF" config="${tests.resources.dir}/jaxrpc/samples/wsbpel/hello/wstools-config.xml"/> -->
<wstools dest="${tests.output.dir}/wstools/resources/jaxrpc/samples/wssecurity/WEB-INF" config="${tests.resources.dir}/jaxrpc/samples/wssecurity/wstools-config.xml"/>
<move todir="${tests.output.dir}/wstools/java">
<fileset dir="${tests.output.dir}/wstools/resources/jaxrpc/samples/docstyle/wrapped/WEB-INF" includes="org/**"/>
@@ -354,7 +353,7 @@
<wsprovide resourcedestdir="${tests.output.dir}/wsprovide/resources/jaxws/samples/wssecurity" genwsdl="true" sei="org.jboss.test.ws.jaxws.samples.wssecurity.HelloJavaBean"/>
</target>
- <target name="generate-resources" depends="servicegen,wstools,wsprovide">
+ <target name="generate-resources" depends="wstools,wsprovide">
<javac destdir="${tests.output.dir}/classes" debug="${javac.debug}" encoding="utf-8" verbose="${javac.verbose}" deprecation="${javac.deprecation}" failonerror="${javac.fail.onerror}">
<src path="${tests.output.dir}/wstools/java"/>
<exclude name="org/jboss/test/ws/interop/**"/>
17 years, 9 months
JBossWS SVN: r2695 - branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 13:17:38 -0400 (Tue, 27 Mar 2007)
New Revision: 2695
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
Log:
Copy most attributes, except id
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 17:06:43 UTC (rev 2694)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 17:17:38 UTC (rev 2695)
@@ -32,11 +32,13 @@
import javax.xml.soap.SOAPException;
import org.jboss.logging.Logger;
-import org.jboss.ws.core.utils.DOMUtils;
import org.jboss.ws.core.utils.DOMWriter;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
/**
- * Inline all rpc/encoded hrefs
+ * Inline rpc/encoded hrefs
*
* @author Thomas.Diesler(a)jboss.com
* @since 27-Mar-2007
@@ -79,6 +81,7 @@
private void processElement(SOAPElement soapElement) throws SOAPException
{
+ // Do inner first outer last
Iterator it = soapElement.getChildElements();
while (it.hasNext())
{
@@ -119,10 +122,10 @@
// Remove old content
hrefElement.removeContents();
- // Copy attributes
- DOMUtils.copyAttributes(hrefElement, idElement);
- hrefElement.removeAttribute("id");
+ // Copy most attributes, except id
+ copyMostAttributes(hrefElement, idElement);
+ // Append id element children
if (idElement.getChildElements().hasNext())
{
Iterator itid = idElement.getChildElements();
@@ -132,10 +135,28 @@
hrefElement.appendChild(childNode);
}
}
+ // If no children, copy the value
else
{
String value = idElement.getValue();
hrefElement.setValue(value);
}
}
+
+ private void copyMostAttributes(Element destElement, Element srcElement)
+ {
+ NamedNodeMap attribs = srcElement.getAttributes();
+ for (int i = 0; i < attribs.getLength(); i++)
+ {
+ Attr attr = (Attr)attribs.item(i);
+ String uri = attr.getNamespaceURI();
+ String qname = attr.getName();
+ String value = attr.getNodeValue();
+
+ // Do not copy the id attribute
+ if ("id".equals(qname) == false)
+ destElement.setAttributeNS(uri, qname, value);
+ }
+ }
+
}
17 years, 9 months
JBossWS SVN: r2694 - branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 13:06:43 -0400 (Tue, 27 Mar 2007)
New Revision: 2694
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
Log:
Remove id elements at the end of href inlining
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 16:45:04 UTC (rev 2693)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 17:06:43 UTC (rev 2694)
@@ -27,6 +27,7 @@
import javax.xml.soap.Node;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
@@ -54,15 +55,26 @@
public void processHRefs() throws SOAPException
{
- SOAPElement soapElement = (SOAPElement)soapBody.getChildElements().next();
-
String bodyStr = DOMWriter.printNode(soapBody, true);
- log.info("Begin processHRefs:\n" + bodyStr);
+ log.debug("Begin processHRefs:\n" + bodyStr);
- processElement(soapElement);
+ Iterator it = soapBody.getChildElements();
+ while (it.hasNext())
+ {
+ // Process the first body element, remove the others
+ SOAPElement soapElement = (SOAPElement)it.next();
+ if (soapElement instanceof SOAPBodyElement)
+ {
+ processElement(soapElement);
+ }
+ else
+ {
+ soapBody.removeChild(soapElement);
+ }
+ }
bodyStr = DOMWriter.printNode(soapBody, true);
- log.info("End processHRefs:\n" + bodyStr);
+ log.debug("End processHRefs:\n" + bodyStr);
}
private void processElement(SOAPElement soapElement) throws SOAPException
@@ -125,8 +137,5 @@
String value = idElement.getValue();
hrefElement.setValue(value);
}
-
- // Remove id element
- soapBody.removeChild(idElement);
}
}
17 years, 9 months
JBossWS SVN: r2693 - in branches/jbossws-1.2.1: jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding and 4 other directories.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 12:45:04 -0400 (Tue, 27 Mar 2007)
New Revision: 2693
Added:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/complex/ComplexTypeUnmarshallerTestCase.java
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws801/JBWS801TestCase.java
branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd
Log:
Implement href handling by inlining id elements
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -1,24 +1,24 @@
/*
-* 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.
-*/
+ * 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.jaxrpc;
// $Id$
@@ -55,7 +55,6 @@
import org.jboss.ws.core.jaxrpc.binding.SerializationContext;
import org.jboss.ws.core.jaxrpc.binding.SerializerFactoryBase;
import org.jboss.ws.core.jaxrpc.binding.SerializerSupport;
-import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.NameImpl;
@@ -120,7 +119,8 @@
FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
if (faultMetaData != null)
{
- if(log.isDebugEnabled()) log.debug("Deserialize fault: " + faultMetaData);
+ if (log.isDebugEnabled())
+ log.debug("Deserialize fault: " + faultMetaData);
QName xmlType = faultMetaData.getXmlType();
Class javaType = faultMetaData.getJavaType();
@@ -162,7 +162,8 @@
}
else
{
- if(log.isDebugEnabled()) log.debug("Cannot find fault meta data for: " + xmlName);
+ if (log.isDebugEnabled())
+ log.debug("Cannot find fault meta data for: " + xmlName);
}
}
}
@@ -211,7 +212,7 @@
{
assertFaultCode(faultEx.getFaultCode());
- MessageContextJAXRPC msgContext = (MessageContextJAXRPC)MessageContextAssociation.peekMessageContext();
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
SerializationContext serContext = (msgContext != null ? msgContext.getSerializationContext() : new SerializationContextJAXRPC());
NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
@@ -285,7 +286,8 @@
}
else
{
- if(log.isDebugEnabled()) log.debug("Cannot obtain fault meta data for: " + javaType);
+ if (log.isDebugEnabled())
+ log.debug("Cannot obtain fault meta data for: " + javaType);
}
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -24,13 +24,9 @@
// $Id$
import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.Deserializer;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -40,12 +36,9 @@
import org.jboss.logging.Logger;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.SOAPContentElement;
import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.core.utils.XMLPredefinedEntityReferenceResolver;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
/** The base class for all Deserializers.
@@ -63,49 +56,9 @@
QName xmlType = soapElement.getXmlType();
Source source = soapElement.getXMLFragment().getSource();
-
- SOAPContentElement refElement = getElementForHRef(soapElement);
- if (refElement != null)
- source = refElement.getXMLFragment().getSource();
-
return deserialize(xmlName, xmlType, source, serContext);
}
- protected SOAPContentElement getElementForHRef(Element soapElement)
- {
- SOAPContentElement refElement = null;
- if (soapElement.getAttribute("href").length() > 0)
- {
- String refID = soapElement.getAttribute("href");
- log.debug("Resolve soap encoded href: " + refID);
-
- try
- {
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- SOAPBody soapBody = msgContext.getSOAPMessage().getSOAPBody();
-
- Iterator it = soapBody.getChildElements();
- while (it.hasNext())
- {
- SOAPElement auxElement = (SOAPElement)it.next();
- if (refID.equals("#" + auxElement.getAttribute("id")))
- {
- refElement = (SOAPContentElement)auxElement;
- break;
- }
- }
- }
- catch (SOAPException ex)
- {
- throw new IllegalStateException("Cannot get href element: " + refID, ex);
- }
-
- if (refElement == null)
- throw new IllegalStateException("Cannot get href element: " + refID);
- }
- return refElement;
- }
-
/** Deserialize an XML fragment to an object value
*
* @param xmlName The root element name of the resulting fragment
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -36,7 +36,6 @@
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.jaxrpc.TypeMappingImpl;
-import org.jboss.ws.core.soap.SOAPContentElement;
import org.jboss.ws.core.utils.DOMUtils;
import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.metadata.umdm.ParameterMetaData;
@@ -137,15 +136,7 @@
if (it.hasNext())
{
Element childElement = (Element)it.next();
-
Source source = new DOMSource(childElement);
- SOAPContentElement refElement = getElementForHRef(childElement);
- if (refElement != null)
- {
- source = refElement.getXMLFragment().getSource();
- compXmlName = refElement.getElementQName();
- }
-
compValue = componentDeserializer.deserialize(compXmlName, compXmlType, source, serContext);
compValue = JavaUtils.getWrapperValueArray(compValue);
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -212,21 +212,21 @@
}
// Process additional soap encoded body elements
- boolean isSOAPEncoded = Constants.URI_SOAP11_ENC.equals(soapEnv.getAttributeNS(envNS, "encodingStyle"));
- isSOAPEncoded = isSOAPEncoded || Constants.URI_SOAP11_ENC.equals(soapBody.getAttributeNS(envNS, "encodingStyle"));
- while(isSOAPEncoded && itBody.hasNext())
+ boolean attachHRefElements = Constants.URI_SOAP11_ENC.equals(soapEnv.getAttributeNS(envNS, "encodingStyle"));
+ attachHRefElements = attachHRefElements || Constants.URI_SOAP11_ENC.equals(soapBody.getAttributeNS(envNS, "encodingStyle"));
+ attachHRefElements = attachHRefElements && itBody.hasNext();
+ while(attachHRefElements && itBody.hasNext())
{
Element srcElement = (Element)itBody.next();
-
- Name name = new NameImpl(srcElement.getLocalName(), srcElement.getPrefix(), srcElement.getNamespaceURI());
- SOAPContentElement destElement = new SOAPContentElement(name);
- destElement = (SOAPContentElement)soapBody.addChildElement(destElement);
-
- DOMUtils.copyAttributes(destElement, srcElement);
-
- XMLFragment xmlFragment = new XMLFragment(new DOMSource(srcElement));
- destElement.setXMLFragment(xmlFragment);
+ soapBody.addChildElement(soapFactory.createElement(srcElement, true));
}
+
+ // Inline all attached href elements
+ if (attachHRefElements)
+ {
+ HRefInlineHandler inlineHandler = new HRefInlineHandler(soapBody);
+ inlineHandler.processHRefs();
+ }
return soapEnv;
}
Added: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java (rev 0)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -0,0 +1,132 @@
+/*
+ * 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.util.Iterator;
+
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.utils.DOMUtils;
+import org.jboss.ws.core.utils.DOMWriter;
+
+/**
+ * Inline all rpc/encoded hrefs
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 27-Mar-2007
+ */
+public class HRefInlineHandler
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(HRefInlineHandler.class);
+
+ private SOAPBody soapBody;
+
+ public HRefInlineHandler(SOAPBody soapBody)
+ {
+ this.soapBody = soapBody;
+ }
+
+ public void processHRefs() throws SOAPException
+ {
+ SOAPElement soapElement = (SOAPElement)soapBody.getChildElements().next();
+
+ String bodyStr = DOMWriter.printNode(soapBody, true);
+ log.info("Begin processHRefs:\n" + bodyStr);
+
+ processElement(soapElement);
+
+ bodyStr = DOMWriter.printNode(soapBody, true);
+ log.info("End processHRefs:\n" + bodyStr);
+ }
+
+ private void processElement(SOAPElement soapElement) throws SOAPException
+ {
+ Iterator it = soapElement.getChildElements();
+ while (it.hasNext())
+ {
+ Node childElement = (Node)it.next();
+ if (childElement instanceof SOAPElement)
+ processElement((SOAPElement)childElement);
+ }
+
+ String href = soapElement.getAttribute("href");
+ if (href.length() > 0)
+ {
+ processHRef(soapElement, href);
+ soapElement.removeAttribute("href");
+ }
+ }
+
+ private void processHRef(SOAPElement hrefElement, String href) throws SOAPException
+ {
+ SOAPContentElement idElement = null;
+
+ Iterator it = soapBody.getChildElements();
+ while (it.hasNext())
+ {
+ SOAPElement auxElement = (SOAPElement)it.next();
+ if (href.equals("#" + auxElement.getAttribute("id")))
+ {
+ idElement = (SOAPContentElement)auxElement;
+ break;
+ }
+ }
+
+ if (idElement == null)
+ throw new IllegalStateException("Cannot get href element: " + href);
+
+ // process nested hrefs
+ processElement(idElement);
+
+ // Remove old content
+ hrefElement.removeContents();
+
+ // Copy attributes
+ DOMUtils.copyAttributes(hrefElement, idElement);
+ hrefElement.removeAttribute("id");
+
+ if (idElement.getChildElements().hasNext())
+ {
+ Iterator itid = idElement.getChildElements();
+ while (itid.hasNext())
+ {
+ Node childNode = (Node)itid.next();
+ hrefElement.appendChild(childNode);
+ }
+ }
+ else
+ {
+ String value = idElement.getValue();
+ hrefElement.setValue(value);
+ }
+
+ // Remove id element
+ soapBody.removeChild(idElement);
+ }
+}
Property changes on: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/HRefInlineHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/complex/ComplexTypeUnmarshallerTestCase.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/complex/ComplexTypeUnmarshallerTestCase.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/complex/ComplexTypeUnmarshallerTestCase.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -119,10 +119,10 @@
" <qname xsi:nil='1'/>" +
" <string>Hello Sub World!</string>" +
" </composite>" +
- " <string xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='xsd:string' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>Hello World!</string>" +
+ " <dateTime xsi:nil='1'/>" +
+ " <integer>100</integer>" +
" <qname xsi:nil='1'/>" +
- " <integer>100</integer>" +
- " <dateTime xsi:nil='1'/>" +
+ " <string>Hello World!</string>" +
"</ns1:CompositeType_1>";
QName xmlName = new QName(TARGET_NAMESPACE, "CompositeType_1", "ns1");
Modified: branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws801/JBWS801TestCase.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws801/JBWS801TestCase.java 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws801/JBWS801TestCase.java 2007-03-27 16:45:04 UTC (rev 2693)
@@ -1,24 +1,24 @@
/*
- * 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.
- */
+ * 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.jaxrpc.jbws801;
import java.io.IOException;
@@ -51,14 +51,14 @@
public class JBWS801TestCase extends JBossWSTest
{
private static final String NS_PREFIX = "ns1";
- private static final String NS_URI = "http://org.jboss.webservice/jbws801";
+ private static final String NS_URI = "http://org.jboss.webservice/attachment";
private static final String CID_MIMEPART = "big";
/** Deploy the test ear */
public static Test suite() throws Exception
{
return JBossWSTestSetup.newTestSetup(JBWS801TestCase.class, "jaxrpc-jbws801.war");
- }
+ }
public void testLargeFile() throws Exception
{
@@ -118,7 +118,7 @@
if (size == 0)
return -1;
- int ret = (int) Math.min(size, len);
+ int ret = (int)Math.min(size, len);
Arrays.fill(b, off, off + ret, (byte)1);
size -= ret;
@@ -137,8 +137,7 @@
}
}
- private SOAPMessage setupMimeMessage(String rpcMethodName)
- throws Exception
+ private SOAPMessage setupMimeMessage(String rpcMethodName) throws Exception
{
MessageFactory mf = MessageFactory.newInstance();
@@ -172,8 +171,7 @@
/** Send the message and validate the result
*/
- private void sendAndValidateMimeMessage(String rpcMethodName, SOAPMessage msg, long count)
- throws SOAPException, MalformedURLException
+ private void sendAndValidateMimeMessage(String rpcMethodName, SOAPMessage msg, long count) throws SOAPException, MalformedURLException
{
SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = conFactory.createConnection();
Modified: branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd 2007-03-27 15:14:21 UTC (rev 2692)
+++ branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd 2007-03-27 16:45:04 UTC (rev 2693)
@@ -23,13 +23,13 @@
</complexType>
<complexType name="Composite">
- <all>
+ <sequence>
<element name="composite" type="tns:Composite" nillable="true"/>
<element name="dateTime" type="dateTime" nillable="true"/>
<element name="integer" type="integer" nillable="true"/>
<element name="qname" type="QName" nillable="true"/>
<element name="string" type="string" nillable="true"/>
- </all>
+ </sequence>
</complexType>
</schema>
17 years, 9 months
JBossWS SVN: r2692 - in branches/jbossws-1.2.1: jbossws-core/src/java/org/jboss/ws/core/jaxrpc and 3 other directories.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 11:14:21 -0400 (Tue, 27 Mar 2007)
New Revision: 2692
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SerializationContextJAXRPC.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
branches/jbossws-1.2.1/jbossws-tests/ant-import/build-jars-jaxrpc.xml
Log:
Fix rpc/encoded tests
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -116,7 +116,7 @@
*/
public Object[] getRequestPayload() throws SOAPException
{
- if(log.isDebugEnabled()) log.debug("getRequestPayload");
+ log.debug("getRequestPayload");
List<QName> xmlNames = getRequestParamNames();
Object[] payload = new Object[opMetaData.getJavaMethod().getParameterTypes().length];
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAPFaultHelperJAXRPC.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -55,6 +55,7 @@
import org.jboss.ws.core.jaxrpc.binding.SerializationContext;
import org.jboss.ws.core.jaxrpc.binding.SerializerFactoryBase;
import org.jboss.ws.core.jaxrpc.binding.SerializerSupport;
+import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.NameImpl;
@@ -210,7 +211,7 @@
{
assertFaultCode(faultEx.getFaultCode());
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ MessageContextJAXRPC msgContext = (MessageContextJAXRPC)MessageContextAssociation.peekMessageContext();
SerializationContext serContext = (msgContext != null ? msgContext.getSerializationContext() : new SerializationContextJAXRPC());
NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SerializationContextJAXRPC.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SerializationContextJAXRPC.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SerializationContextJAXRPC.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -58,7 +58,7 @@
{
if (jaxrpcMapping == null)
{
- if(log.isDebugEnabled()) log.debug("Generate jaxrpcMapping from typeMapping");
+ log.debug("Generate jaxrpcMapping from typeMapping");
jaxrpcMapping = new JavaWsdlMapping();
for (QName xmlType : getTypeMapping().getRegisteredXmlTypes())
@@ -85,7 +85,8 @@
packageMapping.setNamespaceURI(nsURI);
packageMapping.setPackageType(packageName);
jaxrpcMapping.addPackageMapping(packageMapping);
- if(log.isDebugEnabled()) log.debug("Add package mapping: " + packageMapping);
+ if (log.isDebugEnabled())
+ log.debug("Add package mapping: " + packageMapping);
}
// Do not add mappings for array types
@@ -100,7 +101,8 @@
xmlTypeMapping.setJavaType(javaTypeName);
xmlTypeMapping.setRootTypeQName(xmlType);
jaxrpcMapping.addJavaXmlTypeMappings(xmlTypeMapping);
- if(log.isDebugEnabled()) log.debug("Add type mapping: " + xmlTypeMapping);
+ if (log.isDebugEnabled())
+ log.debug("Add type mapping: " + xmlTypeMapping);
}
}
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -30,6 +30,7 @@
import javax.xml.rpc.encoding.Deserializer;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -39,9 +40,12 @@
import org.jboss.logging.Logger;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.SOAPContentElement;
import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.core.utils.XMLPredefinedEntityReferenceResolver;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
/** The base class for all Deserializers.
@@ -58,18 +62,16 @@
QName xmlName = soapElement.getElementQName();
QName xmlType = soapElement.getXmlType();
+ Source source = soapElement.getXMLFragment().getSource();
+
SOAPContentElement refElement = getElementForHRef(soapElement);
if (refElement != null)
- {
- soapElement = refElement;
- xmlName = refElement.getElementQName();
- }
+ source = refElement.getXMLFragment().getSource();
- Source source = soapElement.getXMLFragment().getSource();
return deserialize(xmlName, xmlType, source, serContext);
}
- protected SOAPContentElement getElementForHRef(SOAPElement soapElement)
+ protected SOAPContentElement getElementForHRef(Element soapElement)
{
SOAPContentElement refElement = null;
if (soapElement.getAttribute("href").length() > 0)
@@ -77,24 +79,29 @@
String refID = soapElement.getAttribute("href");
log.debug("Resolve soap encoded href: " + refID);
- SOAPElement parentElement = soapElement.getParentElement();
- while ((parentElement instanceof SOAPBody) == false)
- parentElement = parentElement.getParentElement();
+ try
+ {
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ SOAPBody soapBody = msgContext.getSOAPMessage().getSOAPBody();
- SOAPBody soapBody = (SOAPBody)parentElement;
- Iterator it = soapBody.getChildElements();
- while (it.hasNext())
- {
- SOAPElement auxElement = (SOAPElement)it.next();
- if (refID.equals("#" + auxElement.getAttribute("id")))
+ Iterator it = soapBody.getChildElements();
+ while (it.hasNext())
{
- refElement = (SOAPContentElement)auxElement;
- break;
+ SOAPElement auxElement = (SOAPElement)it.next();
+ if (refID.equals("#" + auxElement.getAttribute("id")))
+ {
+ refElement = (SOAPContentElement)auxElement;
+ break;
+ }
}
}
+ catch (SOAPException ex)
+ {
+ throw new IllegalStateException("Cannot get href element: " + refID, ex);
+ }
if (refElement == null)
- log.warn("Cannot find referrenced element: " + refID);
+ throw new IllegalStateException("Cannot get href element: " + refID);
}
return refElement;
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -29,12 +29,10 @@
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPElement;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.jaxrpc.TypeMappingImpl;
@@ -57,27 +55,15 @@
private DeserializerSupport componentDeserializer;
- public Object deserialize(QName xmlName, QName xmlType, Source xmlFragment, SerializationContext serContext) throws BindingException
+ public Object deserialize(QName xmlName, QName xmlType, Source source, SerializationContext serContext) throws BindingException
{
- throw new NotImplementedException("Use deserialize(SOAPContenentElement, SerializationContext)");
- }
-
- public Object deserialize(SOAPContentElement soapElement, SerializationContext serContext) throws BindingException
- {
- QName xmlName = soapElement.getElementQName();
- QName xmlType = soapElement.getXmlType();
-
- SOAPContentElement refElement = getElementForHRef(soapElement);
- if (refElement != null)
- soapElement = refElement;
-
log.debug("deserialize: [xmlName=" + xmlName + ",xmlType=" + xmlType + "]");
+ Element soapElement = DOMUtils.sourceToElement(source);
try
{
ParameterMetaData paramMetaData = (ParameterMetaData)serContext.getProperty(ParameterMetaData.class.getName());
QName compXmlType = paramMetaData.getSOAPArrayCompType();
- QName compXmlName = paramMetaData.getXmlName();
int[] arrDims = getDimensionsFromAttribute(soapElement);
Class compJavaType = getComponentTypeFromAttribute(soapElement, serContext);
@@ -112,18 +98,18 @@
if (arrDims.length < 1 || 2 < arrDims.length)
throw new WSException("Unsupported array dimensions: " + Arrays.asList(arrDims));
- Iterator it = soapElement.getChildElements();
+ Iterator it = DOMUtils.getChildElements(soapElement);
if (arrDims.length == 1)
{
Object[] subArr = retArray;
- deserializeMemberValues(compXmlName, compXmlType, serContext, it, subArr);
+ deserializeMemberValues(compXmlType, serContext, it, subArr);
}
if (arrDims.length == 2)
{
for (int i = 0; i < arrDims[0]; i++)
{
Object[] subArr = (Object[])retArray[i];
- deserializeMemberValues(compXmlName, compXmlType, serContext, it, subArr);
+ deserializeMemberValues(compXmlType, serContext, it, subArr);
}
}
@@ -140,15 +126,17 @@
}
}
- private void deserializeMemberValues(QName compXmlName, QName compXmlType, SerializationContext serContext, Iterator it, Object[] subArr) throws BindingException
+ private void deserializeMemberValues(QName compXmlType, SerializationContext serContext, Iterator it, Object[] subArr) throws BindingException
{
+ QName compXmlName = new QName("item");
+
int dim = subArr.length;
for (int i = 0; i < dim; i++)
{
Object compValue = null;
if (it.hasNext())
{
- SOAPElement childElement = (SOAPElement)it.next();
+ Element childElement = (Element)it.next();
Source source = new DOMSource(childElement);
SOAPContentElement refElement = getElementForHRef(childElement);
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLFragment.java 2007-03-27 15:14:21 UTC (rev 2692)
@@ -164,29 +164,7 @@
private static String sourceToStringFragement(Source source)
{
-
throw new IllegalArgumentException("Source should never be converted to String");
-
- /*new RuntimeException("sourceToStringFragement").printStackTrace(System.out);
-
- String xmlFragment = null;
-
- try {
- TransformerFactory tf = TransformerFactory.newInstance();
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- tf.newTransformer().transform(source, new StreamResult(baos));
- xmlFragment = new String(baos.toByteArray());
- if (xmlFragment.startsWith("<?xml"))
- {
- int index = xmlFragment.indexOf(">");
- xmlFragment = xmlFragment.substring(index + 1);
- }
- } catch (TransformerException e) {
- WSException.rethrow(e);
- }
-
- return xmlFragment;
- */
}
public void writeTo(Writer writer) throws IOException
@@ -206,9 +184,6 @@
*/
private void writeSource(Writer writer) throws IOException
{
-
- //new RuntimeException("writeSource").printStackTrace(System.out);
-
if (source instanceof DOMSource)
{
DOMSource domSource = (DOMSource)source;
Modified: branches/jbossws-1.2.1/jbossws-tests/ant-import/build-jars-jaxrpc.xml
===================================================================
--- branches/jbossws-1.2.1/jbossws-tests/ant-import/build-jars-jaxrpc.xml 2007-03-27 11:06:26 UTC (rev 2691)
+++ branches/jbossws-1.2.1/jbossws-tests/ant-import/build-jars-jaxrpc.xml 2007-03-27 15:14:21 UTC (rev 2692)
@@ -147,7 +147,7 @@
<classes dir="${tests.output.dir}/classes">
<include name="org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestImpl.class"/>
<include name="org/jboss/test/ws/jaxrpc/encoded/href/MarshallTest.class"/>
- <include name="org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.class"/>
+ <include name="org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.class"/>
</classes>
<webinf dir="${tests.output.dir}/resources/jaxrpc/encoded/href/WEB-INF">
<include name="jaxrpc-mapping.xml"/>
@@ -158,7 +158,7 @@
<jar jarfile="${tests.output.dir}/libs/jaxrpc-encoded-href-client.jar">
<fileset dir="${tests.output.dir}/classes">
<include name="org/jboss/test/ws/jaxrpc/encoded/href/MarshallTest.class"/>
- <include name="org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.class"/>
+ <include name="org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.class"/>
</fileset>
<metainf dir="${tests.output.dir}/resources/jaxrpc/encoded/href/WEB-INF">
<include name="jaxrpc-mapping.xml"/>
17 years, 9 months
JBossWS SVN: r2691 - in branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core: soap and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-03-27 07:06:26 -0400 (Tue, 27 Mar 2007)
New Revision: 2691
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SerializerSupport.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPElementImpl.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java
Log:
Fix recursive expand to DOMValid->XMLValid->DOMValid transitions
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java 2007-03-27 05:05:34 UTC (rev 2690)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/QNameSerializer.java 2007-03-27 11:06:26 UTC (rev 2691)
@@ -47,25 +47,26 @@
public Result serialize(QName xmlName, QName xmlType, Object value, SerializationContext serContext, NamedNodeMap attributes) throws BindingException
{
- if(log.isDebugEnabled()) log.debug("serialize: [xmlName=" + xmlName + ",xmlType=" + xmlType + "]");
+ log.debug("serialize: [xmlName=" + xmlName + ",xmlType=" + xmlType + "]");
QName qnameValue = (QName)value;
String nsURI = qnameValue.getNamespaceURI();
NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
- Set<String> additionalNamespaces = new HashSet<String>();
+ Set<String> nsExtras = new HashSet<String>();
+
// Remove prefix and register again
if (nsURI.length() > 0)
{
qnameValue = new QName(nsURI, qnameValue.getLocalPart());
qnameValue = nsRegistry.registerQName(qnameValue);
- if (!nsURI.equals(xmlName.getNamespaceURI()))
- additionalNamespaces.add(nsURI);
+ if (nsURI.equals(xmlName.getNamespaceURI()) == false)
+ nsExtras.add(nsURI);
}
String valueStr = SimpleTypeBindings.marshalQName(qnameValue, nsRegistry);
- String xmlFragment = wrapValueStr(xmlName, valueStr, nsRegistry, additionalNamespaces, attributes, true);
+ String xmlFragment = wrapValueStr(xmlName, valueStr, nsRegistry, nsExtras, attributes, true);
return stringToResult(xmlFragment);
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SerializerSupport.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SerializerSupport.java 2007-03-27 05:05:34 UTC (rev 2690)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SerializerSupport.java 2007-03-27 11:06:26 UTC (rev 2691)
@@ -25,6 +25,8 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -88,11 +90,12 @@
/** Wrap the value string in a XML fragment with the given name
*/
- protected String wrapValueStr(QName xmlName, String valueStr, NamespaceRegistry nsRegistry, Set<String> additionalNamespaces, NamedNodeMap attributes,
- boolean normalize)
+ protected String wrapValueStr(QName xmlName, String valueStr, NamespaceRegistry nsRegistry, Set<String> nsExtras, NamedNodeMap attributes, boolean normalize)
{
- String nsURI = xmlName.getNamespaceURI();
+ String xmlNameURI = xmlName.getNamespaceURI();
String localPart = xmlName.getLocalPart();
+
+ Map<String, String> namespaces = new HashMap<String, String>();
StringBuilder nsAttr = new StringBuilder("");
if (attributes != null)
@@ -103,45 +106,62 @@
String attrName = attr.getNodeName();
String attrValue = attr.getNodeValue();
nsAttr.append(" " + attrName + "='" + attrValue + "'");
+
+ if (attrName.startsWith("xmlns:"))
+ {
+ String prefix = attrName.substring(6);
+ namespaces.put(attrValue, prefix);
+ }
}
}
String elName;
- if (nsURI.length() > 0)
+ if (xmlNameURI.length() > 0)
{
xmlName = nsRegistry.registerQName(xmlName);
String prefix = xmlName.getPrefix();
elName = prefix + ":" + localPart;
-
- nsAttr.append(" xmlns:" + prefix + "='" + nsURI + "'");
+ if (namespaces.get(xmlNameURI) == null || !prefix.equals(namespaces.get(xmlNameURI)))
+ {
+ nsAttr.append(" xmlns:" + prefix + "='" + xmlNameURI + "'");
+ namespaces.put(xmlNameURI, prefix);
+ }
}
else
{
elName = localPart;
}
- if (additionalNamespaces != null)
+ if (nsExtras != null)
{
- for (String ns : additionalNamespaces)
+ for (String nsURI : nsExtras)
{
- if (ns.equals(nsURI))
- continue;
-
- String prefix = nsRegistry.getPrefix(ns);
- nsAttr.append(" xmlns:" + prefix + "='" + ns + "'");
+ String prefix = nsRegistry.getPrefix(nsURI);
+ if (namespaces.get(nsURI) == null || !prefix.equals(namespaces.get(nsURI)))
+ {
+ nsAttr.append(" xmlns:" + prefix + "='" + nsURI + "'");
+ namespaces.put(nsURI, prefix);
+ }
}
}
String xmlFragment;
if (valueStr == null)
{
- String xmlns = " xmlns:" + Constants.PREFIX_XSI + "='" + Constants.NS_SCHEMA_XSI + "'";
- xmlFragment = "<" + elName + nsAttr + " " + Constants.PREFIX_XSI + ":nil='1'" + xmlns + "/>";
+ String xsins = "";
+ if (namespaces.get(Constants.NS_SCHEMA_XSI) == null || !Constants.PREFIX_XSI.equals(namespaces.get(xmlNameURI)))
+ {
+ xsins = " xmlns:" + Constants.PREFIX_XSI + "='" + Constants.NS_SCHEMA_XSI + "'";
+ namespaces.put(Constants.NS_SCHEMA_XSI, Constants.PREFIX_XSI);
+ }
+
+ xmlFragment = "<" + elName + nsAttr + " " + Constants.PREFIX_XSI + ":nil='1'" + xsins + "/>";
}
else
{
if (normalize)
valueStr = normalize(valueStr);
+
xmlFragment = "<" + elName + nsAttr + ">" + valueStr + "</" + elName + ">";
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2007-03-27 05:05:34 UTC (rev 2690)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2007-03-27 11:06:26 UTC (rev 2691)
@@ -638,7 +638,7 @@
Iterator it = getChildElements();
while (it.hasNext())
{
- SOAPElement el = (SOAPElement)it.next();
+ Node el = (Node)it.next();
el.detachNode();
}
}
Modified: branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java
===================================================================
--- branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java 2007-03-27 05:05:34 UTC (rev 2690)
+++ branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java 2007-03-27 11:06:26 UTC (rev 2691)
@@ -37,6 +37,7 @@
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
@@ -256,7 +257,10 @@
*/
private void expandContainerChildren()
{
+ // Do nothing if the source of the XMLFragment is the container itself
Element domElement = xmlFragment.toElement();
+ if (domElement == container)
+ return;
String rootLocalName = domElement.getLocalName();
String rootPrefix = domElement.getPrefix();
17 years, 9 months