Author: thomas.diesler(a)jboss.com
Date: 2007-03-26 13:47:39 -0400 (Mon, 26 Mar 2007)
New Revision: 2686
Added:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.java
Removed:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.java
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/SOAPArrayDeserializer.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBUnmarshaller.java
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/SOAPContentElement.java
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.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/encoded/href/MarshallTestCase.java
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestImpl.java
branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/META-INF/application-client.xml
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/WEB-INF/webservices.xml
Log:
Fix missing ns declarations when transforming DOMSource. Add support for SOAP Arrays using
href
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/DeserializerSupport.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -24,17 +24,25 @@
// $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.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.jboss.logging.Logger;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
+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.Node;
/** The base class for all Deserializers.
*
@@ -43,7 +51,54 @@
*/
public abstract class DeserializerSupport implements Deserializer
{
+ private static final Logger log = Logger.getLogger(DeserializerSupport.class);
+ 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;
+ xmlName = refElement.getElementQName();
+ }
+
+ Source source = soapElement.getXMLFragment().getSource();
+ return deserialize(xmlName, xmlType, source, serContext);
+ }
+
+ protected SOAPContentElement getElementForHRef(SOAPElement soapElement)
+ {
+ SOAPContentElement refElement = null;
+ if (soapElement.getAttribute("href").length() > 0)
+ {
+ String refID = soapElement.getAttribute("href");
+ log.debug("Resolve soap encoded href: " + refID);
+
+ SOAPElement parentElement = soapElement.getParentElement();
+ while ((parentElement instanceof SOAPBody) == false)
+ parentElement = parentElement.getParentElement();
+
+ SOAPBody soapBody = (SOAPBody)parentElement;
+ Iterator it = soapBody.getChildElements();
+ while (it.hasNext())
+ {
+ SOAPElement auxElement = (SOAPElement)it.next();
+ if (refID.equals("#" + auxElement.getAttribute("id")))
+ {
+ refElement = (SOAPContentElement)auxElement;
+ break;
+ }
+ }
+
+ if (refElement == null)
+ log.warn("Cannot find referrenced element: " + refID);
+ }
+ return refElement;
+ }
+
/** Deserialize an XML fragment to an object value
*
* @param xmlName The root element name of the resulting fragment
@@ -53,22 +108,45 @@
*/
public abstract Object deserialize(QName xmlName, QName xmlType, Source xmlFragment,
SerializationContext serContext) throws BindingException;
+ // TODO: remove when JBossXB supports unmarshall(Source)
+ //
http://jira.jboss.org/jira/browse/JBXB-100
protected static String sourceToString(Source source)
{
String xmlFragment = null;
-
- try {
- TransformerFactory tf = TransformerFactory.newInstance();
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- StreamResult streamResult = new StreamResult(baos);
- tf.newTransformer().transform(source, streamResult);
- xmlFragment = new String(baos.toByteArray());
- if (xmlFragment.startsWith("<?xml"))
+ try
+ {
+ if (source instanceof DOMSource)
{
- int index = xmlFragment.indexOf(">");
- xmlFragment = xmlFragment.substring(index + 1);
+ Node node = ((DOMSource)source).getNode();
+ xmlFragment = DOMWriter.printNode(node, false);
}
- } catch (TransformerException e) {
+ else
+ {
+ // Note, this code will not handler namespaces correctly that
+ // are defined on a parent of the DOMSource
+ //
+ // <env:Envelope
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ // <env:Body>
+ // <myMethod>
+ // <param xsi:type='xsd:string'>Hello
World!</param>
+ // </myMethod>
+ // </env:Body>
+ // </env:Envelope>
+ //
+ TransformerFactory tf = TransformerFactory.newInstance();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ StreamResult streamResult = new StreamResult(baos);
+ tf.newTransformer().transform(source, streamResult);
+ xmlFragment = new String(baos.toByteArray());
+ if (xmlFragment.startsWith("<?xml"))
+ {
+ int index = xmlFragment.indexOf(">");
+ xmlFragment = xmlFragment.substring(index + 1);
+ }
+ }
+ }
+ catch (TransformerException e)
+ {
WSException.rethrow(e);
}
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/SOAPArrayDeserializer.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -29,13 +29,16 @@
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;
+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;
@@ -52,30 +55,32 @@
// provide logging
private static final Logger log = Logger.getLogger(SOAPArrayDeserializer.class);
- private DeserializerSupport compDeserializer;
+ private DeserializerSupport componentDeserializer;
- public SOAPArrayDeserializer() throws BindingException
+ public Object deserialize(QName xmlName, QName xmlType, Source xmlFragment,
SerializationContext serContext) throws BindingException
{
+ throw new NotImplementedException("Use deserialize(SOAPContenentElement,
SerializationContext)");
}
- public Object deserialize(QName xmlName, QName xmlType, Source xmlFragment,
SerializationContext serContext) throws BindingException {
- return deserialize(xmlName, xmlType, sourceToString(xmlFragment), serContext);
- }
+ public Object deserialize(SOAPContentElement soapElement, SerializationContext
serContext) throws BindingException
+ {
+ QName xmlName = soapElement.getElementQName();
+ QName xmlType = soapElement.getXmlType();
- /**
- */
- private Object deserialize(QName xmlName, QName xmlType, String xmlFragment,
SerializationContext serContext) throws BindingException
- {
- if(log.isDebugEnabled()) log.debug("deserialize: [xmlName=" + xmlName +
",xmlType=" + xmlType + "]");
+ SOAPContentElement refElement = getElementForHRef(soapElement);
+ if (refElement != null)
+ soapElement = refElement;
+
+ log.debug("deserialize: [xmlName=" + xmlName + ",xmlType=" +
xmlType + "]");
+
try
{
ParameterMetaData paramMetaData =
(ParameterMetaData)serContext.getProperty(ParameterMetaData.class.getName());
QName compXmlType = paramMetaData.getSOAPArrayCompType();
QName compXmlName = paramMetaData.getXmlName();
- Element arrayElement = DOMUtils.parse(xmlFragment);
- int[] arrDims = getDimensionsFromAttribute(arrayElement);
- Class compJavaType = getComponentTypeFromAttribute(arrayElement, serContext);
+ int[] arrDims = getDimensionsFromAttribute(soapElement);
+ Class compJavaType = getComponentTypeFromAttribute(soapElement, serContext);
Object[] retArray = (Object[])Array.newInstance(compJavaType, arrDims);
TypeMappingImpl typeMapping = serContext.getTypeMapping();
@@ -89,23 +94,25 @@
throw new WSException("Cannot obtain component xmlType for: " +
compJavaType);
// Get the component type deserializer factory
- if(log.isDebugEnabled()) log.debug("Get component deserializer for:
[javaType=" + compJavaType.getName() + ",xmlType=" + compXmlType +
"]");
+ log.debug("Get component deserializer for: [javaType=" +
compJavaType.getName() + ",xmlType=" + compXmlType + "]");
+
DeserializerFactoryBase compDeserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(compJavaType, compXmlType);
if (compDeserializerFactory == null)
{
log.warn("Cannot obtain component deserializer for: [javaType=" +
compJavaType.getName() + ",xmlType=" + compXmlType + "]");
compDeserializerFactory =
(DeserializerFactoryBase)typeMapping.getDeserializer(null, compXmlType);
}
+
if (compDeserializerFactory == null)
throw new WSException("Cannot obtain component deserializer for: "
+ compXmlType);
// Get the component type deserializer
- compDeserializer =
(DeserializerSupport)compDeserializerFactory.getDeserializer();
+ componentDeserializer =
(DeserializerSupport)compDeserializerFactory.getDeserializer();
if (arrDims.length < 1 || 2 < arrDims.length)
throw new WSException("Unsupported array dimensions: " +
Arrays.asList(arrDims));
- Iterator it = DOMUtils.getChildElements(arrayElement);
+ Iterator it = soapElement.getChildElements();
if (arrDims.length == 1)
{
Object[] subArr = retArray;
@@ -120,7 +127,7 @@
}
}
- if(log.isDebugEnabled()) log.debug("deserialized: " +
retArray.getClass().getName());
+ log.debug("deserialized: " + retArray.getClass().getName());
return retArray;
}
catch (RuntimeException e)
@@ -141,9 +148,17 @@
Object compValue = null;
if (it.hasNext())
{
- Element childElement = (Element)it.next();
- Source compXMLFragment = new DOMSource(childElement);
- compValue = compDeserializer.deserialize(compXmlName, compXmlType,
compXMLFragment, serContext);
+ SOAPElement childElement = (SOAPElement)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);
}
subArr[i] = compValue;
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBUnmarshaller.java
===================================================================
---
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBUnmarshaller.java 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/binding/jbossxb/JBossXBUnmarshaller.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -1,34 +1,36 @@
/*
-* 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.binding.jbossxb;
+// $Id$
+
import java.io.InputStream;
/**
* @author Heiko Braun <heiko.braun(a)jboss.com>
- * @version $Id$
* @since Jul 5, 2006
*/
-public interface JBossXBUnmarshaller {
+public interface JBossXBUnmarshaller
+{
Object unmarshal(InputStream is) throws UnmarshalException;
Object getProperty(String name);
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -217,7 +217,6 @@
while(isSOAPEncoded && itBody.hasNext())
{
Element srcElement = (Element)itBody.next();
- registerNamespacesLocally(srcElement);
Name name = new NameImpl(srcElement.getLocalName(), srcElement.getPrefix(),
srcElement.getNamespaceURI());
SOAPContentElement destElement = new SOAPContentElement(name);
@@ -237,7 +236,6 @@
soapBody.removeContents();
Element srcElement = (Element)domBodyElement;
- registerNamespacesLocally(srcElement);
QName beName = DOMUtils.getElementQName(domBodyElement);
SOAPContentElement destElement = new SOAPBodyElementDoc(beName);
@@ -263,7 +261,6 @@
while (itBodyElement.hasNext())
{
Element srcElement = (Element)itBodyElement.next();
- registerNamespacesLocally(srcElement);
Name name = new NameImpl(srcElement.getLocalName(), srcElement.getPrefix(),
srcElement.getNamespaceURI());
SOAPContentElement destElement = new SOAPContentElement(name);
@@ -340,25 +337,4 @@
}
return child;
}
-
- /**
- * Register globally available namespaces on element level.
- * This is necessary to ensure that each xml fragment is valid.
- */
- private void registerNamespacesLocally(Element srcElement)
- {
- String nsURI = srcElement.getNamespaceURI();
- if (nsURI != null && nsURI.length() > 0)
- {
- String prefix = srcElement.getPrefix();
- if (prefix == null)
- {
- srcElement.setAttribute("xmlns", nsURI);
- }
- else
- {
- srcElement.setAttribute("xmlns:" + prefix, nsURI);
- }
- }
- }
}
Modified:
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java
===================================================================
---
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPContentElement.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -103,7 +103,7 @@
this.soapContent = new DOMContent(this);
}
- ParameterMetaData getParamMetaData()
+ public ParameterMetaData getParamMetaData()
{
if (paramMetaData == null)
throw new IllegalStateException("Parameter meta data not available");
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-core/src/java/org/jboss/ws/core/soap/XMLContent.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -28,15 +28,12 @@
import java.io.InputStream;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
-import java.util.Iterator;
import java.util.List;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
@@ -142,37 +139,7 @@
DeserializerFactoryBase deserializerFactory =
getDeserializerFactory(typeMapping, javaType, xmlType);
DeserializerSupport des =
(DeserializerSupport)deserializerFactory.getDeserializer();
- Source source = xmlFragment.getSource();
-
- // Get the rpc/encoded referenced content
- if (opMetaData.isRPCEncoded() &&
container.getAttribute("href").length() > 0)
- {
- String refID = container.getAttribute("href");
- log.debug("Resolve soap encoded href: " + refID);
- SOAPElement parentElement = container.getParentElement();
- if (parentElement instanceof SOAPBodyElement)
- {
- SOAPContentElement refElement = null;
-
- SOAPBody soapBody = (SOAPBody)parentElement.getParentElement();
- Iterator it = soapBody.getChildElements();
- while (it.hasNext())
- {
- SOAPElement soapElement = (SOAPElement)it.next();
- if (refID.equals("#" +
soapElement.getAttribute("id")))
- {
- refElement = (SOAPContentElement)soapElement;
- source = refElement.getXMLFragment().getSource();
- break;
- }
- }
-
- if (refElement == null)
- log.warn("Cannot find referrenced element: " + refID);
- }
- }
-
- obj = des.deserialize(container.getElementQName(), xmlType, source,
serContext);
+ obj = des.deserialize(container, serContext);
if (obj != null)
{
Class objType = obj.getClass();
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/common/jbossxb/complex/ComplexTypeUnmarshallerTestCase.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -50,7 +50,7 @@
/** Get the URL to the defining schema */
protected XSModel getSchemaModel(QName xmlType, Class javaType) throws Exception
{
- File xsdFile = new
File("resources/common/jbossxb/ComplexTypesService_RPC.xsd");
+ File xsdFile = new
File("../src/resources/common/jbossxb/ComplexTypesService_RPC.xsd");
assertTrue(xsdFile.exists());
return new JavaToXSD().parseSchema(xsdFile.toURL());
@@ -110,8 +110,8 @@
public void testCompositeType() throws Exception
{
- String xmlStr = "<ns1:CompositeType_1 xmlns:ns1='" +
TARGET_NAMESPACE
- + "'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+ String xmlStr =
+ "<ns1:CompositeType_1 xmlns:ns1='" + TARGET_NAMESPACE +
"'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
" <composite>" +
" <composite xsi:nil='1'/>" +
" <dateTime xsi:nil='1'/>" +
@@ -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>"
+
+ " <qname xsi:nil='1'/>" +
+ " <integer>100</integer>" +
" <dateTime xsi:nil='1'/>" +
- " <integer>100</integer>" +
- " <qname xsi:nil='1'/>" +
- " <string>Hello World!</string>" +
"</ns1:CompositeType_1>";
QName xmlName = new QName(TARGET_NAMESPACE, "CompositeType_1",
"ns1");
Copied:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.java
(from rev 2682,
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.java)
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.java
(rev 0)
+++
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HRefHandler.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -0,0 +1,124 @@
+/*
+ * 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.encoded.href;
+
+import java.io.ByteArrayInputStream;
+
+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.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.logging.Logger;
+
+public class HRefHandler extends GenericHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(HRefHandler.class);
+
+ private static boolean hrefEncoding;
+
+ protected QName[] headers;
+
+ public QName[] getHeaders()
+ {
+ return headers;
+ }
+
+ public void init(HandlerInfo info)
+ {
+ log.info("init: " + info);
+ headers = info.getHeaders();
+ }
+
+ public static void setHrefEncoding(boolean flag)
+ {
+ hrefEncoding = flag;
+ }
+
+ public boolean handleRequest(MessageContext msgContext)
+ {
+ log.info("handleRequest");
+
+ if (hrefEncoding)
+ {
+ try
+ {
+ String envStr =
+ "<env:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ "<env:Body
env:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'>" +
+ "<ns1:base64BinaryTest
xmlns:ns1='http://marshalltestservice.org/wsdl'>" +
+ "<arrayOfbyte_1 href='#ID1'/>" +
+ "</ns1:base64BinaryTest>" +
+ "<enc:base64 id='ID1'
xsi:type='enc:base64'>SHJlZkVuY29kZWRSZXF1ZXN0</enc:base64>" +
+ "</env:Body>" +
+ "</env:Envelope>";
+
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage reqMessage = factory.createMessage(null, new
ByteArrayInputStream(envStr.getBytes()));
+ ((SOAPMessageContext)msgContext).setMessage(reqMessage);
+ }
+ catch (Exception e)
+ {
+ throw new JAXRPCException(e);
+ }
+ }
+
+ return true;
+ }
+
+
+ public boolean handleResponse(MessageContext msgContext)
+ {
+ log.info("handleResponse");
+
+ if (hrefEncoding)
+ {
+ try
+ {
+ String envStr =
+ "<env:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+ "<env:Body
env:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'>" +
+ "<ns1:base64BinaryTestResponse
xmlns:ns1='http://marshalltestservice.org/wsdl'>" +
+ "<result href='#ID1'/>" +
+ "</ns1:base64BinaryTestResponse>" +
+ "<enc:base64 id='ID1'
xsi:type='enc:base64'>SHJlZkVuY29kZWRSZXNwb25zZQ==</enc:base64>" +
+ "</env:Body>" +
+ "</env:Envelope>";
+
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage resMessage = factory.createMessage(null, new
ByteArrayInputStream(envStr.getBytes()));
+ ((SOAPMessageContext)msgContext).setMessage(resMessage);
+ }
+ catch (Exception e)
+ {
+ throw new JAXRPCException(e);
+ }
+ }
+
+ return true;
+ }
+}
Deleted:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.java
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.java 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/HrefHandler.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxrpc.encoded.href;
-
-import java.io.ByteArrayInputStream;
-
-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.MessageFactory;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.logging.Logger;
-
-public class HrefHandler extends GenericHandler
-{
- // Provide logging
- private static Logger log = Logger.getLogger(HrefHandler.class);
-
- private static boolean hrefEncoding;
-
- protected QName[] headers;
-
- public QName[] getHeaders()
- {
- return headers;
- }
-
- public void init(HandlerInfo info)
- {
- log.info("init: " + info);
- headers = info.getHeaders();
- }
-
- public static void setHrefEncoding(boolean flag)
- {
- hrefEncoding = flag;
- }
-
- public boolean handleRequest(MessageContext msgContext)
- {
- log.info("handleRequest");
-
- if (hrefEncoding)
- {
- try
- {
- String envStr =
- "<env:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
- "<env:Body
env:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'>" +
- "<ns1:base64BinaryTest
xmlns:ns1='http://marshalltestservice.org/wsdl'>" +
- "<arrayOfbyte_1 href='#ID1'/>" +
- "</ns1:base64BinaryTest>" +
- "<enc:base64 id='ID1'
xsi:type='enc:base64'>SHJlZkVuY29kZWRSZXF1ZXN0</enc:base64>" +
- "</env:Body>" +
- "</env:Envelope>";
-
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage reqMessage = factory.createMessage(null, new
ByteArrayInputStream(envStr.getBytes()));
- ((SOAPMessageContext)msgContext).setMessage(reqMessage);
- }
- catch (Exception e)
- {
- throw new JAXRPCException(e);
- }
- }
-
- return true;
- }
-
-
- public boolean handleResponse(MessageContext msgContext)
- {
- log.info("handleResponse");
-
- if (hrefEncoding)
- {
- try
- {
- String envStr =
- "<env:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
- "<env:Body
env:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'>" +
- "<ns1:base64BinaryTestResponse
xmlns:ns1='http://marshalltestservice.org/wsdl'>" +
- "<result href='#ID1'/>" +
- "</ns1:base64BinaryTestResponse>" +
- "<enc:base64 id='ID1'
xsi:type='enc:base64'>SHJlZkVuY29kZWRSZXNwb25zZQ==</enc:base64>" +
- "</env:Body>" +
- "</env:Envelope>";
-
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage resMessage = factory.createMessage(null, new
ByteArrayInputStream(envStr.getBytes()));
- ((SOAPMessageContext)msgContext).setMessage(resMessage);
- }
- catch (Exception e)
- {
- throw new JAXRPCException(e);
- }
- }
-
- return true;
- }
-}
Modified:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestCase.java
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestCase.java 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestCase.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -65,7 +65,7 @@
public void testHrefMessage() throws Exception
{
- HrefHandler.setHrefEncoding(true);
+ HRefHandler.setHrefEncoding(true);
byte[] retObj = port.base64BinaryTest("HandlerReplacesThis".getBytes());
assertEquals("HrefEncodedResponse", new String(retObj));
}
Modified:
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestImpl.java
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestImpl.java 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/encoded/href/MarshallTestImpl.java 2007-03-26
17:47:39 UTC (rev 2686)
@@ -20,7 +20,7 @@
if (message == null && message.length() == 0)
throw new IllegalStateException("Incommig message is null");
- HrefHandler.setHrefEncoding("HrefEncodedRequest".equals(message));
+ HRefHandler.setHrefEncoding("HrefEncodedRequest".equals(message));
return byteArray;
}
}
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-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/resources/common/jbossxb/ComplexTypesService_RPC.xsd 2007-03-26
17:47:39 UTC (rev 2686)
@@ -23,13 +23,13 @@
</complexType>
<complexType name="Composite">
- <sequence>
+ <all>
<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"/>
- </sequence>
+ </all>
</complexType>
</schema>
Modified:
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/META-INF/application-client.xml
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/META-INF/application-client.xml 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/META-INF/application-client.xml 2007-03-26
17:47:39 UTC (rev 2686)
@@ -17,7 +17,7 @@
</port-component-ref>
<handler>
<handler-name>HrefHandler</handler-name>
-
<handler-class>org.jboss.test.ws.jaxrpc.encoded.href.HrefHandler</handler-class>
+
<handler-class>org.jboss.test.ws.jaxrpc.encoded.href.HRefHandler</handler-class>
</handler>
</service-ref>
Modified:
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/WEB-INF/webservices.xml
===================================================================
---
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/WEB-INF/webservices.xml 2007-03-26
13:09:51 UTC (rev 2685)
+++
branches/jbossws-1.2.1/jbossws-tests/src/resources/jaxrpc/encoded/href/WEB-INF/webservices.xml 2007-03-26
17:47:39 UTC (rev 2686)
@@ -19,7 +19,7 @@
</service-impl-bean>
<handler>
<handler-name>HrefHandler</handler-name>
-
<handler-class>org.jboss.test.ws.jaxrpc.encoded.href.HrefHandler</handler-class>
+
<handler-class>org.jboss.test.ws.jaxrpc.encoded.href.HRefHandler</handler-class>
</handler>
</port-component>
</webservice-description>