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>