Author: heiko.braun(a)jboss.com
Date: 2007-05-24 06:21:49 -0400 (Thu, 24 May 2007)
New Revision: 3220
Added:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/DocumentPayloadWithoutRef.java
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxws/DynamicWrapperGenerator.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/OperationMetaData.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/WrappedParameter.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpoint.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpoint.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/SWARefTestCase.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpoint.java
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java
Log:
Copy attachment annotations to wrapper beans
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxws/DynamicWrapperGenerator.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxws/DynamicWrapperGenerator.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/core/jaxws/DynamicWrapperGenerator.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -35,11 +35,7 @@
import javassist.NotFoundException;
import javassist.bytecode.ConstPool;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.*;
import javax.xml.namespace.QName;
import org.jboss.logging.Logger;
@@ -112,7 +108,12 @@
for (WrappedParameter parameter : wrappedParameters)
{
- addProperty(clazz, parameter.getType(), parameter.getName(),
parameter.getVariable(), parameter.getTypeArguments());
+ addProperty(
+ clazz, parameter.getType(),
+ parameter.getName(), parameter.getVariable(),
+ parameter.getTypeArguments(),
+ new boolean[] {parameter.isSwaRef(), parameter.isXop()}
+ );
}
clazz.stopPruning(!prune);
pool.toClass(clazz, loader);
@@ -146,7 +147,11 @@
addClassAnnotations(clazz, fmd.getXmlName(), fmd.getXmlType(), propertyOrder);
for (String property : propertyOrder)
- addProperty(clazz, properties.get(property).getName(), new QName(property),
property, null);
+ addProperty(
+ clazz, properties.get(property).getName(),
+ new QName(property), property, null,
+ new boolean[] {false, false}
+ );
clazz.stopPruning(!prune);
pool.toClass(clazz, loader);
@@ -188,7 +193,9 @@
return "(" + type + ")V";
}
- private void addProperty(CtClass clazz, String typeName, QName name, String variable,
String[] typeArguments)
+ private void addProperty(CtClass clazz, String typeName,
+ QName name, String variable, String[] typeArguments,
+ boolean[] attachments)
throws CannotCompileException, NotFoundException
{
ConstPool constPool = clazz.getClassFile().getConstPool();
@@ -210,6 +217,19 @@
annotation.addParameter("namespace", name.getNamespaceURI());
annotation.addParameter("name", name.getLocalPart());
annotation.markField(field);
+
+ // @XmlAttachmentRef
+ if(attachments[0])
+ {
+ annotation = JavassistUtils.createAnnotation(XmlAttachmentRef.class, constPool);
+ annotation.markField(field);
+ }
+ // @XmlMimeType
+ if(attachments[1])
+ {
+ annotation = JavassistUtils.createAnnotation(XmlMimeType.class, constPool);
+ annotation.markField(field);
+ }
clazz.addField(field);
// Add accessor methods
@@ -248,5 +268,6 @@
annotation = JavassistUtils.createAnnotation(XmlAccessorType.class, constPool);
annotation.addParameter("value", XmlAccessType.FIELD);
annotation.markClass(clazz);
+
}
}
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -33,6 +33,9 @@
private String mimeType;
private Type type;
+ // distinguish return value and method parameters
+ private int index = -1;
+
public AttachmentScanResult(String mimeType, Type type)
{
this.mimeType = mimeType;
@@ -48,4 +51,25 @@
{
return type;
}
+
+ /**
+ * <code>
+ * <pre>
+ * -1 - return value
+ * 0 - 1st method parameter
+ * n - n'th method parameter
+ * </pre>
+ * </code>
+ *
+ * @return
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
}
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -30,6 +30,7 @@
import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
@@ -71,7 +72,7 @@
* @param xmlRoot
* @return the first matching XmlMimeType#value() or <code>null</code> if
none found
*/
- public AttachmentScanResult scan(Class xmlRoot)
+ public AttachmentScanResult scanBean(Class xmlRoot)
{
if( isJDKType(xmlRoot) ) return null;
@@ -103,7 +104,7 @@
if(null == result) // try getter methods
{
- result = scanGetterAnnotation(xmlRoot, field);
+ result = scanGetterAnnotation(xmlRoot, field);
}
// avoid recursive loops
@@ -112,7 +113,7 @@
// drill down if none found so far
if(null == result)
- result = scan(type);
+ result = scanBean(type);
}
@@ -121,6 +122,85 @@
return result;
}
+ public static List<AttachmentScanResult> scanMethod(Method method)
+ {
+ List<AttachmentScanResult> results = new
ArrayList<AttachmentScanResult>();
+
+ // return type
+ if(method.getReturnType() != void.class)
+ {
+
+ AttachmentScanResult result = null;
+
+ if(method.isAnnotationPresent(XmlAttachmentRef.class))
+ {
+ result = new AttachmentScanResult("application/octet-stream",
AttachmentScanResult.Type.SWA_REF);
+ }
+ else if (method.isAnnotationPresent(XmlMimeType.class))
+ {
+ XmlMimeType mimeTypeDecl = method.getAnnotation(XmlMimeType.class);
+ new AttachmentScanResult(mimeTypeDecl.value(),
AttachmentScanResult.Type.XOP);
+ }
+
+ if(result!=null)
+ {
+ result.setIndex(-1); // default for return values
+ results.add(result);
+ }
+
+ }
+
+ // method parameter
+ int ordinate = 0;
+ for (Annotation[] parameterAnnotations : method.getParameterAnnotations())
+ {
+ if (parameterAnnotations!=null)
+ {
+ for (Annotation annotation : parameterAnnotations)
+ {
+ AttachmentScanResult paramResult = null;
+
+ if(XmlAttachmentRef.class == annotation.annotationType())
+ {
+ paramResult = new
AttachmentScanResult("application/octet-stream",
AttachmentScanResult.Type.SWA_REF);
+ }
+ else if(XmlMimeType.class == annotation.annotationType())
+ {
+ XmlMimeType mimeTypeDecl = method.getAnnotation(XmlMimeType.class);
+ paramResult = new AttachmentScanResult(mimeTypeDecl.value(),
AttachmentScanResult.Type.XOP);
+ }
+
+ if(paramResult!=null)
+ {
+ paramResult.setIndex(ordinate);
+ ordinate++;
+ results.add(paramResult);
+
+ }
+ }
+ }
+ }
+
+
+ return results;
+ }
+
+ public static AttachmentScanResult getResultByIndex(List<AttachmentScanResult>
results, int index)
+ {
+ AttachmentScanResult result = null;
+
+ for(AttachmentScanResult asr : results)
+ {
+ if(asr.getIndex() == index)
+ {
+ result = asr;
+ break;
+ }
+ }
+
+ return result;
+ }
+
private boolean alreadyScanned(Field field)
{
@@ -167,7 +247,7 @@
}
else if(method.isAnnotationPresent(XmlAttachmentRef.class))
{
- return new AttachmentScanResult("application/octet-stream",
AttachmentScanResult.Type.SWA_REF);
+ return new AttachmentScanResult("application/octet-stream",
AttachmentScanResult.Type.SWA_REF);
}
}
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -67,6 +67,8 @@
import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.extensions.addressing.AddressingPropertiesImpl;
import org.jboss.ws.extensions.addressing.metadata.AddressingOpMetaExt;
+import org.jboss.ws.extensions.xop.jaxws.AttachmentScanResult;
+import org.jboss.ws.extensions.xop.jaxws.ReflectiveAttachmentRefScanner;
import org.jboss.ws.metadata.acessor.JAXBAccessor;
import org.jboss.ws.metadata.builder.MetaDataBuilder;
import org.jboss.ws.metadata.j2ee.serviceref.HandlerChainsObjectFactory;
@@ -583,6 +585,10 @@
epMetaData.addOperation(opMetaData);
// Build parameter meta data
+
+ // Attachment annotations on SEI parameters
+ List<AttachmentScanResult> scanResult =
ReflectiveAttachmentRefScanner.scanMethod(method);
+
Class[] parameterTypes = method.getParameterTypes();
Type[] genericTypes = method.getGenericParameterTypes();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
@@ -650,6 +656,15 @@
wrappedParameter = new WrappedParameter(wrappedParameter);
wrappedOutputParameters.add(wrappedParameter);
}
+
+ AttachmentScanResult asr =
ReflectiveAttachmentRefScanner.getResultByIndex(scanResult, i);
+ if(asr!=null)
+ {
+ if(AttachmentScanResult.Type.SWA_REF == asr.getType())
+ wrappedParameter.setSwaRef(true);
+ else
+ wrappedParameter.setXop(true);
+ }
}
else
{
@@ -704,6 +719,15 @@
// insert at the beginning just for prettiness
wrappedOutputParameters.add(0, wrapped);
+
+ AttachmentScanResult asr =
ReflectiveAttachmentRefScanner.getResultByIndex(scanResult, -1);
+ if(asr!=null)
+ {
+ if(AttachmentScanResult.Type.SWA_REF == asr.getType())
+ wrapped.setSwaRef(true);
+ else
+ wrapped.setXop(true);
+ }
}
else
{
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/OperationMetaData.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/OperationMetaData.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/OperationMetaData.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -23,16 +23,6 @@
// $Id$
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.jws.soap.SOAPBinding.ParameterStyle;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.ParameterMode;
-
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.jaxrpc.Style;
@@ -42,6 +32,15 @@
import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
import org.w3c.dom.Element;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.ParameterMode;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* An Operation component describes an operation that a given interface supports.
*
@@ -244,7 +243,7 @@
ParameterMetaData returnMetaData = getReturnParameter();
if (returnMetaData != null && !returnMetaData.matchParameter(method,
matches, exact))
-return false;
+ return false;
// We should have an entry for every parameter index if we match
return matches.size() == paramTypes.length;
@@ -462,12 +461,15 @@
// reset java method
javaMethod = null;
+ // parameter
for (ParameterMetaData parameter : parameters)
parameter.eagerInitialize();
+ // return value
if (returnParam != null)
returnParam.eagerInitialize();
+ // faults
for (FaultMetaData fault : faults)
fault.eagerInitialize();
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -489,7 +489,7 @@
if (epType == Type.JAXWS)
{
ReflectiveAttachmentRefScanner scanner = new ReflectiveAttachmentRefScanner();
- AttachmentScanResult scanResult = scanner.scan(javaType);
+ AttachmentScanResult scanResult = scanner.scanBean(javaType);
if (scanResult != null)
{
if(log.isDebugEnabled()) log.debug("Identified attachment reference:
" + xmlName + ", type="+scanResult.getType());
Modified:
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/WrappedParameter.java
===================================================================
---
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/WrappedParameter.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-core/src/java/org/jboss/ws/metadata/umdm/WrappedParameter.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -41,6 +41,8 @@
private boolean holder = false;
private int index = -2;
private Accessor accessor;
+ private boolean swaRef;
+ private boolean xop;
public WrappedParameter(WrappedParameter wrapped)
{
@@ -131,6 +133,27 @@
this.accessor = accessor;
}
+
+ public boolean isSwaRef()
+ {
+ return swaRef;
+ }
+
+ public void setSwaRef(boolean swaRef)
+ {
+ this.swaRef = swaRef;
+ }
+
+ public boolean isXop()
+ {
+ return xop;
+ }
+
+ public void setXop(boolean xop)
+ {
+ this.xop = xop;
+ }
+
public String toString()
{
return "[name = " + getName() + ", type = " + getType() +
", typeArgs = " + JavaUtils.printArray(getTypeArguments()) + ", variable =
" + getVariable()
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpoint.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpoint.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpoint.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -4,6 +4,8 @@
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.ejb.Remote;
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import java.rmi.RemoteException;
@WebService(name="BareEndpoint")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle =
SOAPBinding.ParameterStyle.BARE)
@@ -11,8 +13,9 @@
public interface BareEndpoint
{
@WebMethod
- void submitAttachment(DocumentPayload payload);
+ DocumentPayload beanAnnotation(DocumentPayload payload) throws RemoteException;
@WebMethod
- DocumentPayload retrieveAttachment();
+ @XmlAttachmentRef
+ DocumentPayloadWithoutRef parameterAnnotation(@XmlAttachmentRef
DocumentPayloadWithoutRef payload) throws RemoteException;
}
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/BareEndpointImpl.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -1,11 +1,15 @@
package org.jboss.test.ws.jaxws.samples.swaref;
import org.jboss.ws.annotation.WebContext;
+import org.jboss.ws.WSException;
import javax.jws.WebService;
+import javax.jws.WebMethod;
import javax.ejb.Stateless;
import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAttachmentRef;
import java.io.IOException;
+import java.rmi.RemoteException;
@Stateless
@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.samples.swaref.BareEndpoint")
@@ -13,21 +17,33 @@
public class BareEndpointImpl implements BareEndpoint
{
- public void submitAttachment(DocumentPayload payload)
+ public DocumentPayload beanAnnotation(DocumentPayload payload) throws RemoteException
{
try
{
System.out.println("Got '" + payload.getData().getContent()
+"'");
+ return new DocumentPayload( new DataHandler("Server data",
"text/plain"));
}
catch (IOException e)
{
- e.printStackTrace();
+ throw new WSException(e);
}
}
- public DocumentPayload retrieveAttachment()
+ @WebMethod
+ @XmlAttachmentRef
+ public DocumentPayloadWithoutRef parameterAnnotation(@XmlAttachmentRef
DocumentPayloadWithoutRef payload) throws RemoteException
{
- DataHandler data = new DataHandler("Server data",
"text/plain");
- return new DocumentPayload(data);
+ try
+ {
+ if(null == payload) throw new WSException("Payload was null");
+ System.out.println("Got " + payload.getData().getContent());
+ DataHandler dataHandler = new DataHandler("Server data",
"text/plain");
+ return new DocumentPayloadWithoutRef(dataHandler);
+ }
+ catch (IOException e)
+ {
+ throw new WSException(e);
+ }
}
}
Added:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/DocumentPayloadWithoutRef.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/DocumentPayloadWithoutRef.java
(rev 0)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/DocumentPayloadWithoutRef.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -0,0 +1,35 @@
+package org.jboss.test.ws.jaxws.samples.swaref;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Document that's not annotated with @XmlAttachmentRef
+ */
+@XmlRootElement
+public class DocumentPayloadWithoutRef
+{
+ private DataHandler data;
+
+ public DocumentPayloadWithoutRef()
+ {
+ }
+
+ public DocumentPayloadWithoutRef(DataHandler data)
+ {
+ this.data = data;
+ }
+
+ @XmlElement
+ public DataHandler getData()
+ {
+ return data;
+ }
+
+ public void setData(DataHandler data)
+ {
+ this.data = data;
+ }
+}
Property changes on:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/DocumentPayloadWithoutRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpoint.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpoint.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpoint.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -15,5 +15,8 @@
{
@WebMethod
@XmlAttachmentRef
- DataHandler echo(@XmlAttachmentRef DataHandler data) throws RemoteException;
+ DataHandler parameterAnnotation(@XmlAttachmentRef DataHandler data) throws
RemoteException;
+
+ @WebMethod
+ DocumentPayload beanAnnotation(DocumentPayload payload) throws RemoteException;
}
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/RpcLitEndpointImpl.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -17,7 +17,7 @@
{
@WebMethod
- public DataHandler echo(DataHandler data) throws RemoteException
+ public DataHandler parameterAnnotation(DataHandler data) throws RemoteException
{
try
{
@@ -30,4 +30,19 @@
}
}
+
+ @WebMethod
+ public DocumentPayload beanAnnotation(DocumentPayload payload) throws RemoteException
+ {
+ try
+ {
+ System.out.println("Got " + payload.getData().getContent() );
+ DataHandler data = new DataHandler("Server data",
"text/plain");
+ return new DocumentPayload(data);
+ }
+ catch (IOException e)
+ {
+ throw new WSException(e);
+ }
+ }
}
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/SWARefTestCase.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/SWARefTestCase.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/SWARefTestCase.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -5,13 +5,14 @@
import org.jboss.test.ws.JBossWSTestSetup;
import javax.xml.ws.Service;
-import javax.xml.ws.BindingProvider;
import javax.xml.namespace.QName;
import javax.activation.DataHandler;
import java.net.URL;
/**
- * TODO: same test with doclit wrapped, currently the scanner fails on generated wrapper
+ * Test SwARef with different binding styles and @XmlAttachmentRef locations.
+ *
+ * @author Heiko.Braun(a)jboss.com
*/
public class SWARefTestCase extends JBossWSTest
{
@@ -30,41 +31,64 @@
return JBossWSTestSetup.newTestSetup(SWARefTestCase.class,
"jaxws-samples-swaref.jar");
}
- public void testSubmitAttachment() throws Exception
+ public void testBeanAnnotationWithBare() throws Exception
{
Service service = Service.create(new URL(bareEndpointURL +"?wsdl"),
bareServiceQName);
BareEndpoint port = service.getPort(BareEndpoint.class);
- port.submitAttachment(new DocumentPayload(data));
+ DocumentPayload response = port.beanAnnotation(new DocumentPayload(data));
+ assertTrue(response.getData().getContent().equals("Server data"));
}
- public void testRetrieveAttachment() throws Exception {
+ /*public void testParameterAnnotationWithBare() throws Exception
+ {
Service service = Service.create(new URL(bareEndpointURL +"?wsdl"),
bareServiceQName);
BareEndpoint port = service.getPort(BareEndpoint.class);
- DocumentPayload response = port.retrieveAttachment();
+
+ DocumentPayloadWithoutRef response = port.parameterAnnotation(new
DocumentPayloadWithoutRef(data));
assertTrue(response.getData().getContent().equals("Server data"));
+ }*/
+
+ public void testBeanAnnotationWithWrapped() throws Exception
+ {
+ Service service = Service.create(new URL(wrappedEndpointURL+"?wsdl"),
wrappedServiceQName);
+ WrappedEndpoint port = service.getPort(WrappedEndpoint.class);
+
+ DocumentPayload response = port.beanAnnotation(new DocumentPayload(data),
"Wrapped test");
+ assertTrue(response.getData().getContent().equals("Server data"));
+
}
- public void testWrappedEndpoint() throws Exception
+ public void testParameterAnnotationWithWrapped() throws Exception
{
Service service = Service.create(new URL(wrappedEndpointURL+"?wsdl"),
wrappedServiceQName);
WrappedEndpoint port = service.getPort(WrappedEndpoint.class);
- DocumentPayload response = port.echo(new DocumentPayload(data), "Wrapped
test");
+ DataHandler response = port.parameterAnnotation(data, "Wrapped test");
+ assertNotNull("Response as null", response);
+ assertTrue("Contents are not equal",
response.getContent().equals("Server data"));
+ }
+
+ public void testBeanAnnotationWithRPC() throws Exception
+ {
+ Service service = Service.create(new URL(rpclitEndpointURL+"?wsdl"),
rpcLitServiceQName);
+ RpcLitEndpoint port = service.getPort(RpcLitEndpoint.class);
+
+ DocumentPayload response = port.beanAnnotation( new DocumentPayload(data));
+ assertNotNull("Response was null", response);
assertTrue(response.getData().getContent().equals("Server data"));
}
- public void testRpcLitEndpoint() throws Exception
+ /*public void testParameterAnnotationWithRPC() throws Exception
{
- System.out.println("FIXME [JBWS-1460]: @XmlMimeType and @XmlAttachmentRef on
SEI parameter declarations");
- /*Service service = Service.create(new URL(rpclitEndpointURL+"?wsdl"),
rpcLitServiceQName);
+ //System.out.println("FIXME [JBWS-1460]: @XmlMimeType and @XmlAttachmentRef on
SEI parameter declarations");
+ Service service = Service.create(new URL(rpclitEndpointURL+"?wsdl"),
rpcLitServiceQName);
RpcLitEndpoint port = service.getPort(RpcLitEndpoint.class);
- DataHandler response = port.echo(data);
+ DataHandler response = port.parameterAnnotation(data);
assertNotNull("Response was null", response);
assertTrue(response.getContent().equals("Server data"));
- */
- }
+ }*/
}
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpoint.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpoint.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpoint.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -3,15 +3,19 @@
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ejb.Remote;
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAttachmentRef;
import java.rmi.RemoteException;
@Remote
@WebService
public interface WrappedEndpoint
{
- /* (non-Javadoc)
- * @see org.jboss.ws.test.TestService#echo(javax.activation.DataHandler)
- */
@WebMethod
- DocumentPayload echo(DocumentPayload dhw, String test) throws RemoteException;
+ DocumentPayload beanAnnotation(DocumentPayload dhw, String test) throws
RemoteException;
+
+ @WebMethod
+ @XmlAttachmentRef
+ DataHandler parameterAnnotation(@XmlAttachmentRef DataHandler data, String test)
throws RemoteException;
+
}
Modified:
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java
===================================================================
---
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java 2007-05-23
15:14:01 UTC (rev 3219)
+++
branches/jbossws-2.0/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/swaref/WrappedEndpointImpl.java 2007-05-24
10:21:49 UTC (rev 3220)
@@ -1,14 +1,17 @@
package org.jboss.test.ws.jaxws.samples.swaref;
import org.jboss.ws.annotation.WebContext;
+import org.jboss.ws.WSException;
import javax.activation.DataHandler;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ejb.Stateless;
+import javax.xml.bind.annotation.XmlAttachmentRef;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.IOException;
import java.rmi.RemoteException;
@Stateless
@@ -17,10 +20,10 @@
public class WrappedEndpointImpl implements WrappedEndpoint
{
/* (non-Javadoc)
- * @see org.jboss.ws.test.TestService#echo(javax.activation.DataHandler)
+ * @see
org.jboss.ws.test.TestService#parameterAnnotation(javax.activation.DataHandler)
*/
@WebMethod
- public DocumentPayload echo(DocumentPayload dhw, String test) throws RemoteException
+ public DocumentPayload beanAnnotation(DocumentPayload dhw, String test) throws
RemoteException
{
DataHandler dh;
@@ -55,8 +58,21 @@
}
+ @WebMethod
+ @XmlAttachmentRef
+ public DataHandler parameterAnnotation(@XmlAttachmentRef DataHandler data, String
test) throws RemoteException
+ {
+ try
+ {
+ System.out.println("Got " + data.getContent());
+ return new DataHandler("Server data", "text/plain");
+ }
+ catch (IOException e)
+ {
+ throw new WSException(e);
+ }
+ }
-
private static void dumpDH(DataHandler in_dh) throws Exception
{
InputStream is = in_dh.getInputStream();