Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 37885 invoked from network); 25 Oct 2007 17:14:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Oct 2007 17:14:02 -0000 Received: (qmail 28079 invoked by uid 500); 25 Oct 2007 17:13:50 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 28031 invoked by uid 500); 25 Oct 2007 17:13:50 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 28022 invoked by uid 99); 25 Oct 2007 17:13:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 10:13:49 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 19:14:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4B6851A9858; Thu, 25 Oct 2007 10:13:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r588283 [9/18] - in /incubator/cxf/branches/jliu: ./ api/ api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/io/ api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/phase/ api/src/main/java... Date: Thu, 25 Oct 2007 17:10:56 -0000 To: cxf-commits@incubator.apache.org From: jliu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071025171306.4B6851A9858@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java Thu Oct 25 10:09:20 2007 @@ -19,16 +19,23 @@ package org.apache.cxf.jaxb; +import java.lang.annotation.Annotation; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Collection; import java.util.HashSet; import java.util.Set; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlTransient; + import org.apache.cxf.common.util.PackageUtils; import org.apache.cxf.service.ServiceModelVisitor; import org.apache.cxf.service.model.MessagePartInfo; @@ -56,12 +63,12 @@ } boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped(); - if (isFromWrapper - && clazz.isArray() + if (isFromWrapper + && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) { clazz = clazz.getComponentType(); } - + Type genericType = (Type) part.getProperty("generic.type"); if (genericType != null) { boolean isList = Collection.class.isAssignableFrom(clazz); @@ -73,38 +80,38 @@ && !Byte.TYPE.equals(cl2.getComponentType())) { genericType = cl2.getComponentType(); } - addType(genericType); + addType(genericType); } else if (!isList) { - addType(genericType); + addType(genericType); } } else { - addType(genericType); + addType(genericType); } - - if (isList + + if (isList && genericType instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) genericType; - if (pt.getActualTypeArguments().length > 0 + if (pt.getActualTypeArguments().length > 0 && pt.getActualTypeArguments()[0] instanceof Class) { - - Class arrayCls = + + Class arrayCls = Array.newInstance((Class) pt.getActualTypeArguments()[0], 0).getClass(); clazz = arrayCls; part.setTypeClass(clazz); if (isFromWrapper) { addType(clazz.getComponentType()); } - } else if (pt.getActualTypeArguments().length > 0 + } else if (pt.getActualTypeArguments().length > 0 && pt.getActualTypeArguments()[0] instanceof GenericArrayType) { GenericArrayType gat = (GenericArrayType)pt.getActualTypeArguments()[0]; gat.getGenericComponentType(); - Class arrayCls = + Class arrayCls = Array.newInstance((Class) gat.getGenericComponentType(), 0).getClass(); clazz = Array.newInstance(arrayCls, 0).getClass(); part.setTypeClass(clazz); if (isFromWrapper) { addType(clazz.getComponentType()); - } + } } } if (isFromWrapper && isList) { @@ -115,7 +122,7 @@ addClass(clazz); } } - + private void addType(Type cls) { if (cls instanceof Class) { addClass((Class)cls); @@ -127,11 +134,11 @@ GenericArrayType gt = (GenericArrayType)cls; Class ct = (Class) gt.getGenericComponentType(); ct = Array.newInstance(ct, 0).getClass(); - + addClass(ct); } } - + private void addClass(Class cls) { if (cls.isArray() && cls.getComponentType().isPrimitive()) { @@ -172,28 +179,101 @@ } } - private void walkReferences(Class cls) { if (cls.getName().startsWith("java.") || cls.getName().startsWith("javax.")) { return; } - //walk the public fields/methods to try and find all the classes. JAXB will only load the - //EXACT classes in the fields/methods if they are in a different package. Thus, + //walk the public fields/methods to try and find all the classes. JAXB will only load the + //EXACT classes in the fields/methods if they are in a different package. Thus, //subclasses won't be found and the xsi:type stuff won't work at all. - //We'll grab the public field/method types and then add the ObjectFactory stuff + //We'll grab the public field/method types and then add the ObjectFactory stuff //as well as look for jaxb.index files in those packages. - - Field fields[] = cls.getFields(); - for (Field f : fields) { - addType(f.getGenericType()); + + XmlAccessorType accessorType = cls.getAnnotation(XmlAccessorType.class); + if (accessorType == null && cls.getPackage() != null) { + accessorType = cls.getPackage().getAnnotation(XmlAccessorType.class); } - Method methods[] = cls.getMethods(); - for (Method m : methods) { - addType(m.getGenericReturnType()); - for (Type t : m.getGenericParameterTypes()) { - addType(t); + XmlAccessType accessType = accessorType != null ? accessorType.value() : XmlAccessType.PUBLIC_MEMBER; + + if (accessType != XmlAccessType.PROPERTY) { // only look for fields if we are instructed to + Field fields[] = cls.getFields(); + for (Field f : fields) { + if (isFieldAccepted(f, accessType)) { + addType(f.getGenericType()); + } + } + } + + if (accessType != XmlAccessType.FIELD) { // only look for methods if we are instructed to + Method methods[] = cls.getMethods(); + for (Method m : methods) { + if (isMethodAccepted(m, accessType)) { + addType(m.getGenericReturnType()); + for (Type t : m.getGenericParameterTypes()) { + addType(t); + } + } + } + } + } + + /** + * Checks is the field is accepted as a JAXB property. + */ + private boolean isFieldAccepted(Field field, XmlAccessType accessType) { + // We only accept non static fields which are not marked @XmlTransient + if (Modifier.isStatic(field.getModifiers()) || field.isAnnotationPresent(XmlTransient.class)) { + return false; + } + + if (accessType == XmlAccessType.NONE) { + return checkJaxbAnnotation(field.getAnnotations()); + } else { + return true; + } + } + + /** + * Checks is the method is accepted as a JAXB property getter. + */ + private boolean isMethodAccepted(Method method, XmlAccessType accessType) { + // We only accept non static property getters which are not marked @XmlTransient + if (Modifier.isStatic(method.getModifiers()) || method.isAnnotationPresent(XmlTransient.class)) { + return false; + } + + // must not have parameters and return type must not be void + if (method.getReturnType() == Void.class || method.getParameterTypes().length != 0) { + return false; + } + + boolean isPropGetter = method.getName().startsWith("get") || method.getName().startsWith("is"); + + if (!isPropGetter) { + return false; + } + + if (accessType == XmlAccessType.NONE) { + return checkJaxbAnnotation(method.getAnnotations()); + } else { + return true; + } + } + + /** + * Checks if there are JAXB annotations among the annotations of the class member. + * @param annotations the array of annotations from the class member + * @return true if JAXB annotations are present, false otherwise + */ + private boolean checkJaxbAnnotation(Annotation[] annotations) { + // must check if there are any jaxb annotations + Package jaxbAnnotationsPackage = XmlElement.class.getPackage(); + for (Annotation annotation : annotations) { + if (annotation.annotationType().getPackage() == jaxbAnnotationsPackage) { + return true; } } + return false; } -} +} \ No newline at end of file Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java Thu Oct 25 10:09:20 2007 @@ -72,7 +72,7 @@ return new JAXBAttachmentUnmarshaller(attachments); } - protected AttachmentMarshaller getAttachmentMarrshaller() { + protected AttachmentMarshaller getAttachmentMarshaller() { return new JAXBAttachmentMarshaller(attachments); } Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Thu Oct 25 10:09:20 2007 @@ -32,8 +32,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.ResourceBundle; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Pattern; import javax.xml.bind.JAXBContext; @@ -53,8 +54,8 @@ import com.sun.xml.bind.v2.ContextFactory; import com.sun.xml.bind.v2.runtime.JAXBContextImpl; -import org.apache.cxf.common.i18n.BundleUtils; import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.CacheMap; import org.apache.cxf.common.util.PackageUtils; import org.apache.cxf.common.util.StringUtils; @@ -72,13 +73,13 @@ import org.apache.ws.commons.schema.XmlSchemaCollection; public final class JAXBDataBinding extends AbstractDataBinding implements DataBinding { - public static final String SCHEMA_RESOURCE = "SCHEMRESOURCE"; public static final String UNWRAP_JAXB_ELEMENT = "unwrap.jaxb.element"; - private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXBDataBinding.class); - + private static final Logger LOG = LogUtils.getLogger(JAXBDataBinding.class); + + private static final Class SUPPORTED_READER_FORMATS[] = new Class[] {Node.class, XMLEventReader.class, XMLStreamReader.class}; @@ -198,6 +199,9 @@ } } + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "CREATED_JAXB_CONTEXT", new Object[] {ctx, contextClasses}); + } setContext(ctx); @@ -225,7 +229,7 @@ (Document)r.getNode(), r.getSystemId()); } } catch (IOException e) { - throw new ServiceConstructionException(new Message("SCHEMA_GEN_EXC", BUNDLE), e); + throw new ServiceConstructionException(new Message("SCHEMA_GEN_EXC", LOG), e); } } @@ -392,8 +396,8 @@ //Now we can not add all the classes that Jaxb needed into JaxbContext, especially when - //an ObjectFactroy is pointed by an jaxb @XmlElementDecl annotation - //added this workaround method to load the jaxb needed OjbectFactory class + //an ObjectFactory is pointed to by an jaxb @XmlElementDecl annotation + //added this workaround method to load the jaxb needed ObjectFactory class public boolean addJaxbObjectFactory(JAXBException e1) { boolean added = false; java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream(); @@ -418,6 +422,14 @@ } return added; + } + + /** + * Jaxb has no declared namespace prefixes. + * {@inheritDoc} + */ + public Map getDeclaredNamespaceMappings() { + return null; } Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java Thu Oct 25 10:09:20 2007 @@ -200,6 +200,27 @@ public static void marshall(JAXBContext context, Schema schema, Object elValue, Object source) { marshall(context, schema, elValue, null, source, null); } + + @SuppressWarnings("unchecked") + public static void marshallNullElement(JAXBContext context, Schema schema, + Object source, MessagePartInfo part) { + Class clazz = part != null ? (Class) part.getTypeClass() : null; + try { + Marshaller u = createMarshaller(context, clazz); + u.setSchema(schema); + try { + // The Marshaller.JAXB_FRAGMENT will tell the Marshaller not to + // generate the xml declaration. + u.setProperty(Marshaller.JAXB_FRAGMENT, true); + u.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + } catch (javax.xml.bind.PropertyException e) { + // intentionally empty. + } + writeObject(u, source, new JAXBElement(part.getElementQName(), clazz, null)); + } catch (JAXBException e) { + throw new Fault(new Message("MARSHAL_ERROR", BUNDLE, e.getMessage()), e); + } + } public static void marshall(JAXBContext context, Schema schema, Object elValue, Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java Thu Oct 25 10:09:20 2007 @@ -20,13 +20,18 @@ package org.apache.cxf.jaxb; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.Iterator; +import java.util.logging.Logger; import javax.xml.namespace.QName; import com.sun.xml.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.bind.v2.runtime.JaxBeanInfo; +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.interceptor.Fault; import org.apache.cxf.service.ServiceModelVisitor; import org.apache.cxf.service.model.FaultInfo; import org.apache.cxf.service.model.MessagePartInfo; @@ -46,6 +51,7 @@ * Walks the service model and sets up the element/type names. */ class JAXBSchemaInitializer extends ServiceModelVisitor { + private static final Logger LOG = LogUtils.getLogger(JAXBSchemaInitializer.class); private XmlSchemaCollection schemas; private JAXBContextImpl context; @@ -148,20 +154,20 @@ private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) { XmlSchemaElement el = null; - SchemaInfo schemaInfo = null; - for (SchemaInfo s : serviceInfo.getSchemas()) { - if (s.getNamespaceURI().equals(qn.getNamespaceURI())) { - schemaInfo = s; - + SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI()); + if (schemaInfo != null) { + el = schemaInfo.getElementByQName(qn); + if (el == null) { el = createXsElement(part, typeName, schemaInfo); schemaInfo.getSchema().getElements().add(el.getQName(), el); schemaInfo.getSchema().getItems().add(el); - - return; + } else if (!typeName.equals(el.getSchemaTypeName())) { + throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG, + qn, typeName, el.getSchemaTypeName())); } + return; } - schemaInfo = new SchemaInfo(serviceInfo, qn.getNamespaceURI()); el = createXsElement(part, typeName, schemaInfo); @@ -171,6 +177,7 @@ schema.getItems().add(el); NamespaceMap nsMap = new NamespaceMap(); + nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace()); nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD); schema.setNamespaceContext(nsMap); @@ -195,29 +202,27 @@ QName name = (QName)fault.getProperty("elementName"); part.setElementQName(name); JaxBeanInfo beanInfo = context.getBeanInfo(cls); - SchemaInfo schemaInfo = null; - for (SchemaInfo s : serviceInfo.getSchemas()) { - if (s.getNamespaceURI().equals(part.getElementQName().getNamespaceURI()) - && !isExistSchemaElement(s.getSchema(), part.getElementQName())) { - schemaInfo = s; - - XmlSchemaElement el = new XmlSchemaElement(); - el.setQName(part.getElementQName()); - el.setName(part.getElementQName().getLocalPart()); - el.setNillable(true); + if (beanInfo == null) { + throw new Fault(new Message("NO_BEAN_INFO", LOG, cls.getName())); + } + SchemaInfo schemaInfo = serviceInfo.getSchema(part.getElementQName().getNamespaceURI()); + if (schemaInfo != null + && !isExistSchemaElement(schemaInfo.getSchema(), part.getElementQName())) { - schemaInfo.getSchema().getItems().add(el); - schemaInfo.getSchema().getElements().add(el.getQName(), el); - - Iterator itr = beanInfo.getTypeNames().iterator(); - if (!itr.hasNext()) { - continue; - } - QName typeName = itr.next(); - el.setSchemaTypeName(typeName); + XmlSchemaElement el = new XmlSchemaElement(); + el.setQName(part.getElementQName()); + el.setName(part.getElementQName().getLocalPart()); + el.setNillable(true); + + schemaInfo.getSchema().getItems().add(el); + schemaInfo.getSchema().getElements().add(el.getQName(), el); + Iterator itr = beanInfo.getTypeNames().iterator(); + if (!itr.hasNext()) { return; } + QName typeName = itr.next(); + el.setSchemaTypeName(typeName); } } } @@ -237,6 +242,7 @@ schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED)); NamespaceMap nsMap = new NamespaceMap(); + nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace()); nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD); schema.setNamespaceContext(nsMap); @@ -271,6 +277,14 @@ ct.setParticle(seq); String namespace = part.getElementQName().getNamespaceURI(); for (Field f : cls.getDeclaredFields()) { + // This code takes all the fields that are public and not static. + // It is arguable that it should be looking at get/is properties and all those + // bean-like things. + int modifiers = f.getModifiers(); + if (!Modifier.isPublic(modifiers) || Modifier.isStatic(modifiers)) { + continue; + } + JaxBeanInfo beanInfo = context.getBeanInfo(f.getType()); if (beanInfo != null) { el = new XmlSchemaElement(); Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Messages.properties?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Messages.properties (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Messages.properties Thu Oct 25 10:09:20 2007 @@ -22,7 +22,11 @@ SCHEMA_NOT_RESOLVED = Could not resolve URI: {0} UNKNOWN_SOURCE = Marshalling Error, unrecognized source {0}. MARSHAL_ERROR = Marshalling Error: {0} -UNMARSHAL_ERROR = Unmarshalling Error : {0} +UNMARSHAL_ERROR = Unmarshalling Error: {0} UNKNOWN_ELEMENT_NAME = Could not determine the element name for {0}. UNKNOWN_PACKAGE_NS = No package info found for class {0}. Cannot lookup default schema namespace. SCHEMA_GEN_EXC = Could not generate schemas. +CREATED_JAXB_CONTEXT = Created JAXBContext "{0}" with classes {1}. +NO_BEAN_INFO = Could not find JAXB information for bean class {0} in context. Make sure it follows JAXB conventions. +CANNOT_CREATE_ELEMENT = Cannot create element {0} with type of {1} due to element already exists with type {2}. + \ No newline at end of file Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java Thu Oct 25 10:09:20 2007 @@ -40,7 +40,17 @@ if (obj != null || !(part.getXmlSchema() instanceof XmlSchemaElement)) { JAXBEncoderDecoder.marshall(getJAXBContext(), getSchema(), obj, part, output, - getAttachmentMarrshaller()); + getAttachmentMarshaller()); + } else if (obj == null && needToRender(obj, part)) { + JAXBEncoderDecoder.marshallNullElement(getJAXBContext(), getSchema(), output, part); } + } + + private boolean needToRender(Object obj, MessagePartInfo part) { + if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) { + XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema(); + return element.isNillable() && element.getMinOccurs() > 0; + } + return false; } } Modified: incubator/cxf/branches/jliu/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java (original) +++ incubator/cxf/branches/jliu/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java Thu Oct 25 10:09:20 2007 @@ -43,6 +43,7 @@ import org.apache.cxf.Bus; import org.apache.cxf.binding.BindingFactoryManager; +import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.databinding.DataReader; import org.apache.cxf.databinding.DataWriter; import org.apache.cxf.helpers.CastUtils; @@ -63,7 +64,7 @@ public class JAXBDataBindingTest extends Assert { - private static final Logger LOG = Logger.getLogger(JAXBDataBindingTest.class.getName()); + private static final Logger LOG = LogUtils.getLogger(JAXBDataBindingTest.class); private static final String WSDL_PATH = "/wsdl/hello_world.wsdl"; private Definition def; private Service service; Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/pom.xml URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/pom.xml?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/pom.xml (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/pom.xml Thu Oct 25 10:09:20 2007 @@ -104,7 +104,7 @@ org.apache.geronimo.specs geronimo-servlet_2.5_spec provided - + org.springframework spring-web Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java Thu Oct 25 10:09:20 2007 @@ -26,7 +26,7 @@ import javax.xml.ws.Binding; import javax.xml.ws.BindingProvider; //TODO JAX-WS 2.1 -//import javax.xml.ws.EndpointReference; +import javax.xml.ws.EndpointReference; import javax.xml.ws.handler.MessageContext; public class BindingProviderImpl implements BindingProvider { @@ -79,17 +79,12 @@ } } - /* //TODO JAX-WS 2.1 public EndpointReference getEndpointReference() { - // TODO throw new UnsupportedOperationException(); } public T getEndpointReference(Class clazz) { - // TODO throw new UnsupportedOperationException(); } - */ - } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java Thu Oct 25 10:09:20 2007 @@ -81,6 +81,7 @@ public class DispatchImpl extends BindingProviderImpl implements Dispatch, MessageObserver { private static final Logger LOG = LogUtils.getL7dLogger(DispatchImpl.class); + private static final String FINISHED = "exchange.finished"; private Bus bus; private InterceptorProvider iProvider; @@ -171,9 +172,9 @@ // execute chain chain.doIntercept(message); - getConduitSelector().complete(exchange); if (message.getContent(Exception.class) != null) { + getConduitSelector().complete(exchange); if (getBinding() instanceof SOAPBinding) { try { SOAPFault soapFault = SOAPFactory.newInstance().createFault(); @@ -206,6 +207,7 @@ synchronized (exchange) { Message inMsg = waitResponse(exchange); respContext.putAll(inMsg); + getConduitSelector().complete(exchange); //need to do context mapping from cxf message to jax-ws ContextPropertiesMapping.mapResponsefromCxf2Jaxws(respContext); return cl.cast(inMsg.getContent(Object.class)); @@ -216,6 +218,13 @@ } private Message waitResponse(Exchange exchange) { + while (!Boolean.TRUE.equals(exchange.get(FINISHED))) { + try { + exchange.wait(); + } catch (InterruptedException e) { + //TODO - timeout + } + } Message inMsg = exchange.getInMessage(); if (inMsg == null) { try { @@ -303,6 +312,7 @@ chain.doIntercept(message); } finally { synchronized (message.getExchange()) { + message.getExchange().put(FINISHED, Boolean.TRUE); message.getExchange().setInMessage(message); message.getExchange().notifyAll(); } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Thu Oct 25 10:09:20 2007 @@ -24,11 +24,16 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; - import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.ws.Binding; +import javax.xml.ws.EndpointReference; +import javax.xml.ws.WebServiceFeature; import javax.xml.ws.WebServicePermission; +import javax.xml.ws.soap.MTOM; +import javax.xml.ws.soap.MTOMFeature; + +import org.w3c.dom.Element; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; @@ -47,6 +52,7 @@ import org.apache.cxf.service.Service; import org.apache.cxf.service.invoker.Invoker; + public class EndpointImpl extends javax.xml.ws.Endpoint implements InterceptorProvider, Configurable { /** @@ -109,9 +115,9 @@ this.bindingUri = bindingUri; wsdlLocation = wsdl == null ? null : new String(wsdl); serverFactory = new JaxWsServerFactoryBean(); + loadWSFeatureAnnotation(); } - - + public EndpointImpl(Bus b, Object i, String bindingUri) { this(b, i, bindingUri, (String)null); } @@ -119,6 +125,15 @@ public EndpointImpl(Bus bus, Object implementor) { this(bus, implementor, (String) null); } + + private void loadWSFeatureAnnotation() { + List wsFeatures = new ArrayList(); + MTOM mtom = implementor.getClass().getAnnotation(MTOM.class); + if (mtom != null) { + wsFeatures.add(new MTOMFeature(mtom.enabled(), mtom.threshold())); + } + ((JaxWsServiceFactoryBean) serverFactory.getServiceFactory()).setWsFeatures(wsFeatures); + } public Binding getBinding() { return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding(); @@ -200,6 +215,7 @@ public void stop() { if (null != server) { server.stop(); + server = null; } } @@ -450,17 +466,13 @@ this.schemaLocations = schemaLocations; } - /* //TODO JAX-WS 2.1 public EndpointReference getEndpointReference(Element... referenceParameters) { - // TODO throw new UnsupportedOperationException(); } public T getEndpointReference(Class clazz, Element... referenceParameters) { - // TODO throw new UnsupportedOperationException(); } - */ } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java Thu Oct 25 10:09:20 2007 @@ -61,7 +61,7 @@ super(factory, scope); } - protected Fault createFault(Throwable ex) { + protected Fault createFault(Throwable ex, Method m, List params, boolean checked) { //map the JAX-WS faults if (ex instanceof SOAPFaultException) { SOAPFaultException sfe = (SOAPFaultException)ex; @@ -73,7 +73,7 @@ return fault; } - return super.createFault(ex); + return super.createFault(ex, m, params, checked); } protected Object invoke(Exchange exchange, final Object serviceObject, Method m, List params) { Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Thu Oct 25 10:09:20 2007 @@ -33,8 +33,7 @@ import javax.xml.ws.AsyncHandler; import javax.xml.ws.Binding; import javax.xml.ws.BindingProvider; -//TODO JAX-WS 2.1 -//import javax.xml.ws.EndpointReference; +import javax.xml.ws.EndpointReference; import javax.xml.ws.Response; import javax.xml.ws.WebServiceException; import javax.xml.ws.handler.MessageContext.Scope; @@ -250,16 +249,12 @@ return binding; } - /* // TODO JAX-WS 2.1 public EndpointReference getEndpointReference() { - // TODO throw new UnsupportedOperationException(); } public T getEndpointReference(Class clazz) { - // TODO throw new UnsupportedOperationException(); } - */ } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Thu Oct 25 10:09:20 2007 @@ -20,6 +20,7 @@ +import java.lang.reflect.Proxy; import java.util.List; import javax.xml.ws.WebServiceException; @@ -172,7 +173,7 @@ private void buildHandlerChain() { AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); - List chain = builder.buildHandlerChainFromClass(getServiceBean().getClass(), + List chain = builder.buildHandlerChainFromClass(getServiceBeanClass(), getEndpointName()); for (Handler h : chain) { injectResources(h); @@ -196,7 +197,13 @@ resourceManager = new DefaultResourceManager(resolvers); resourceManager.addResourceResolver(new WebServiceContextResourceResolver()); ResourceInjector injector = new ResourceInjector(resourceManager); - injector.inject(instance); + if (Proxy.isProxyClass(instance.getClass()) && getServiceClass() != null) { + injector.inject(instance, getServiceClass()); + injector.construct(instance, getServiceClass()); + } else { + injector.inject(instance); + injector.construct(instance); + } } } } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Thu Oct 25 10:09:20 2007 @@ -21,6 +21,7 @@ import java.net.MalformedURLException; import java.net.URL; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -31,13 +32,14 @@ import java.util.concurrent.Executor; import java.util.logging.Level; import java.util.logging.Logger; - import javax.jws.WebService; import javax.xml.bind.JAXBContext; import javax.xml.namespace.QName; import javax.xml.ws.Dispatch; +import javax.xml.ws.EndpointReference; import javax.xml.ws.Service.Mode; import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; import javax.xml.ws.handler.Handler; import javax.xml.ws.handler.HandlerResolver; import javax.xml.ws.spi.ServiceDelegate; @@ -240,15 +242,23 @@ return handlerResolver; } - public T getPort(Class type) { + public T getPort(Class serviceEndpointInterface) { + return getPort(serviceEndpointInterface, new WebServiceFeature[]{}); + } + + public T getPort(Class serviceEndpointInterface, WebServiceFeature... features) { try { - return createPort(null, null, type); + return createPort(null, null, serviceEndpointInterface, features); } catch (ServiceConstructionException e) { throw new WebServiceException(e); - } + } + } + + public T getPort(QName portName, Class serviceEndpointInterface) { + return getPort(portName, serviceEndpointInterface, new WebServiceFeature[]{}); } - public T getPort(QName portName, Class type) { + public T getPort(QName portName, Class serviceEndpointInterface, WebServiceFeature... features) { if (portName == null) { throw new WebServiceException(BUNDLE.getString("PORT_NAME_NULL_EXC")); } @@ -258,12 +268,12 @@ } try { - return createPort(portName, null, type); + return createPort(portName, null, serviceEndpointInterface, features); } catch (ServiceConstructionException e) { throw new WebServiceException(e); - } + } } - + public T getPort(EndpointReferenceType endpointReference, Class type) { endpointReference = EndpointReferenceUtils.resolve(endpointReference, bus); @@ -307,13 +317,19 @@ } protected T createPort(QName portName, EndpointReferenceType epr, Class serviceEndpointInterface) { + return createPort(portName, epr, serviceEndpointInterface, new WebServiceFeature[]{}); + } + + protected T createPort(QName portName, EndpointReferenceType epr, Class serviceEndpointInterface, + WebServiceFeature... features) { LOG.log(Level.FINE, "creating port for portName", portName); LOG.log(Level.FINE, "endpoint reference:", epr); LOG.log(Level.FINE, "endpoint interface:", serviceEndpointInterface); JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); JaxWsClientFactoryBean clientFac = (JaxWsClientFactoryBean) proxyFac.getClientFactoryBean(); - ReflectionServiceFactoryBean serviceFactory = proxyFac.getServiceFactory(); + JaxWsServiceFactoryBean serviceFactory = (JaxWsServiceFactoryBean) proxyFac.getServiceFactory(); + serviceFactory.setWsFeatures(Arrays.asList(features)); proxyFac.setBus(bus); proxyFac.setServiceClass(serviceEndpointInterface); @@ -329,7 +345,7 @@ Service service = serviceFactory.getService(); if (service == null) { serviceFactory.setServiceClass(serviceEndpointInterface); - serviceFactory.setBus(getBus()); + serviceFactory.setBus(getBus()); service = serviceFactory.create(); } @@ -485,12 +501,10 @@ // TODO JAX-WS 2.1 - /* public Dispatch createDispatch(QName portName, Class type, Mode mode, WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } @@ -498,7 +512,6 @@ Class type, Mode mode, WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } @@ -506,7 +519,6 @@ JAXBContext context, Mode mode, WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } @@ -514,28 +526,12 @@ JAXBContext context, Mode mode, WebServiceFeature... features) { - // TODO - throw new UnsupportedOperationException(); - } - - public T getPort(Class serviceEndpointInterface, - WebServiceFeature... features) { - // TODO - throw new UnsupportedOperationException(); - } - - public T getPort(QName portName, - Class serviceEndpointInterface, - WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } public T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } - */ } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java Thu Oct 25 10:09:20 2007 @@ -20,12 +20,13 @@ package org.apache.cxf.jaxws.context; import java.security.Principal; - +import javax.xml.ws.EndpointReference; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext; -import org.apache.cxf.security.SecurityContext; +import org.w3c.dom.Element; +import org.apache.cxf.security.SecurityContext; public class WebServiceContextImpl implements WebServiceContext { @@ -61,20 +62,14 @@ } // TODO JAX-WS 2.1 - /* public EndpointReference getEndpointReference(Element... referenceParameters) { - // TODO throw new UnsupportedOperationException(); } public T getEndpointReference(Class clazz, Element... referenceParameters) { - // TODO throw new UnsupportedOperationException(); } - */ - - public static void setMessageContext(MessageContext ctx) { //ContextPropertiesMapping.mapCxf2Jaxws(ctx); Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java Thu Oct 25 10:09:20 2007 @@ -179,6 +179,7 @@ resolvers.add(new InitParamResourceResolver(params)); ResourceInjector resInj = new ResourceInjector(resMgr, resolvers); resInj.inject(handler); + resInj.construct(handler); } } @@ -198,7 +199,7 @@ try { m = handler.getClass().getMethod("init", Map.class); } catch (NoSuchMethodException ex) { - // emtpy + // empty } return m; } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java Thu Oct 25 10:09:20 2007 @@ -108,6 +108,7 @@ // resourceManager.addResourceResolver(new WebContextEntriesResourceResolver()); ResourceInjector injector = new ResourceInjector(resourceManager); injector.inject(handler); + injector.construct(handler); } } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java Thu Oct 25 10:09:20 2007 @@ -85,6 +85,7 @@ obj = new StreamSource(cos.getInputStream()); message.setContent(Source.class, new StreamSource(cos.getInputStream())); + cos.close(); } catch (Exception e) { throw new Fault(e); } @@ -98,8 +99,11 @@ Transformer transformer = XMLUtils.newTransformer(); transformer.transform(obj, new StreamResult(cos)); - SOAPMessage msg = initSOAPMessage(cos.getInputStream()); + InputStream in = cos.getInputStream(); + SOAPMessage msg = initSOAPMessage(in); source = new DOMSource(((SOAPMessage)msg).getSOAPBody().getFirstChild()); + in.close(); + cos.close(); } catch (Exception e) { throw new Fault(e); } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java Thu Oct 25 10:09:20 2007 @@ -21,12 +21,17 @@ import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.logging.Logger; import javax.activation.DataSource; import javax.mail.util.ByteArrayDataSource; +import javax.xml.soap.AttachmentPart; import javax.xml.soap.MessageFactory; +import javax.xml.soap.MimeHeader; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPException; @@ -40,6 +45,7 @@ import org.w3c.dom.Node; +import org.apache.cxf.attachment.AttachmentImpl; import org.apache.cxf.binding.soap.Soap11; import org.apache.cxf.binding.soap.Soap12; import org.apache.cxf.binding.soap.SoapMessage; @@ -49,6 +55,7 @@ import org.apache.cxf.databinding.source.NodeDataReader; import org.apache.cxf.databinding.source.XMLStreamDataReader; import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.helpers.XMLUtils; import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor; @@ -58,6 +65,7 @@ import org.apache.cxf.jaxb.JAXBDataBinding; import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor; import org.apache.cxf.jaxws.handler.soap.DispatchSOAPHandlerInterceptor; +import org.apache.cxf.message.Attachment; import org.apache.cxf.message.Exchange; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageContentsList; @@ -111,11 +119,10 @@ ex.put(Service.Mode.class, mode); if (message instanceof SoapMessage) { - SOAPMessage soapMessage = newSOAPMessage(is, ((SoapMessage)message).getVersion()); + SOAPMessage soapMessage = newSOAPMessage(is, (SoapMessage)message); PostDispatchSOAPHandlerInterceptor postSoap = new PostDispatchSOAPHandlerInterceptor(); message.getInterceptorChain().add(postSoap); - //soapMessage.writeTo(System.out); message.setContent(SOAPMessage.class, soapMessage); } else if (message instanceof XMLMessage) { if (type.equals(DataSource.class)) { @@ -144,16 +151,25 @@ message.getInterceptorChain().add(postLogical); is.close(); + message.removeContent(InputStream.class); } catch (Exception e) { throw new Fault(e); } } - private SOAPMessage newSOAPMessage(InputStream is, SoapVersion version) throws Exception { - // TODO: Get header from message, this interceptor should after - // readHeadersInterceptor + private SOAPMessage newSOAPMessage(InputStream is, SoapMessage msg) throws Exception { + SoapVersion version = msg.getVersion(); MimeHeaders headers = new MimeHeaders(); + if (msg.containsKey(Message.PROTOCOL_HEADERS)) { + Map> heads = CastUtils.cast((Map)msg.get(Message.PROTOCOL_HEADERS)); + for (Map.Entry> entry : heads.entrySet()) { + for (String val : entry.getValue()) { + headers.addHeader(entry.getKey(), val); + } + } + } + MessageFactory msgFactory = null; if (version == null || version instanceof Soap11) { msgFactory = MessageFactory.newInstance(); @@ -187,6 +203,24 @@ //This seems to be a problem in SAAJ. Envelope might not be initialized properly //without calling getEnvelope() soapMessage.getSOAPPart().getEnvelope(); + if (soapMessage.countAttachments() > 0) { + if (message.getAttachments() == null) { + message.setAttachments(new ArrayList(soapMessage + .countAttachments())); + } + Iterator it = CastUtils.cast(soapMessage.getAttachments()); + while (it.hasNext()) { + AttachmentPart part = it.next(); + AttachmentImpl att = new AttachmentImpl(part.getContentId()); + att.setDataHandler(part.getDataHandler()); + Iterator it2 = CastUtils.cast(part.getAllMimeHeaders()); + while (it2.hasNext()) { + MimeHeader header = it2.next(); + att.setHeader(header.getName(), header.getValue()); + } + message.getAttachments().add(att); + } + } } catch (SOAPException e) { throw new Fault(e); } @@ -227,10 +261,30 @@ if (SOAPMessage.class.isAssignableFrom(type)) { try { - CachedOutputStream cos = new CachedOutputStream(); - Transformer transformer = XMLUtils.newTransformer(); - transformer.transform(source, new StreamResult(cos)); - obj = newSOAPMessage(cos.getInputStream(), ((SoapMessage)message).getVersion()); + SoapVersion version = ((SoapMessage)message).getVersion(); + MessageFactory msgFactory = null; + if (version == null || version instanceof Soap11) { + msgFactory = MessageFactory.newInstance(); + } else if (version instanceof Soap12) { + msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); + } + SOAPMessage msg = msgFactory.createMessage(); + msg.getSOAPPart().setContent(source); + + if (message.getAttachments() != null) { + for (Attachment att : message.getAttachments()) { + AttachmentPart part = msg.createAttachmentPart(att.getDataHandler()); + if (att.getId() != null) { + part.setContentId(att.getId()); + } + for (Iterator it = att.getHeaderNames(); it.hasNext();) { + String s = it.next(); + part.setMimeHeader(s, att.getHeader(s)); + } + msg.addAttachmentPart(part); + } + } + obj = msg; } catch (Exception e) { throw new Fault(e); } @@ -286,6 +340,8 @@ dataReader.setProperty(JAXBDataBinding.UNWRAP_JAXB_ELEMENT, Boolean.FALSE); Object obj = dataReader.read(null, reader, null); + reader.close(); + cos.close(); return obj; Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java Thu Oct 25 10:09:20 2007 @@ -22,15 +22,23 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.logging.Logger; import javax.activation.DataSource; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.soap.AttachmentPart; import javax.xml.soap.MessageFactory; +import javax.xml.soap.MimeHeader; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPConstants; +import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; +import javax.xml.soap.SOAPPart; import javax.xml.stream.XMLStreamWriter; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -42,6 +50,7 @@ import org.w3c.dom.Node; +import org.apache.cxf.attachment.AttachmentImpl; import org.apache.cxf.binding.soap.Soap11; import org.apache.cxf.binding.soap.Soap12; import org.apache.cxf.binding.soap.SoapMessage; @@ -49,14 +58,15 @@ import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.databinding.DataWriter; import org.apache.cxf.databinding.source.NodeDataWriter; +import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.helpers.XMLUtils; import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor; import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor; import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.io.CachedOutputStream; import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor; +import org.apache.cxf.message.Attachment; import org.apache.cxf.message.Message; import org.apache.cxf.message.XMLMessage; import org.apache.cxf.phase.Phase; @@ -77,9 +87,6 @@ } public void handleMessage(Message message) throws Fault { - org.apache.cxf.service.Service service = - message.getExchange().get(org.apache.cxf.service.Service.class); - Object obj = null; Object result = message.getContent(List.class); if (result != null) { @@ -97,26 +104,7 @@ if (message instanceof SoapMessage) { Source source = null; if (mode == Service.Mode.PAYLOAD) { - if (obj instanceof SOAPMessage || obj instanceof DataSource) { - throw new Fault( - new org.apache.cxf.common.i18n.Message( - "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING", - LOG, obj.getClass(), "PAYLOAD")); - } else if (obj instanceof Source) { - source = (Source)obj; - } else { - //JAXB - try { - SOAPMessage msg = newSOAPMessage(null, ((SoapMessage)message).getVersion()); - DataWriter dataWriter = getDataWriter(message, service, Node.class); - dataWriter.write(obj, msg.getSOAPBody()); - //msg.writeTo(System.out); - source = new DOMSource(DOMUtils.getChild(msg.getSOAPBody(), Node.ELEMENT_NODE)); - } catch (Exception e) { - throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT", - LOG), e); - } - } + source = handlePayloadMode(obj, message); } else { if (obj instanceof DataSource) { throw new Fault( @@ -124,7 +112,8 @@ "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING", LOG, "DataSource", "MESSAGE")); } else if (obj instanceof SOAPMessage) { - source = new DOMSource(((SOAPMessage)obj).getSOAPPart()); + source = handleSOAPMessage(obj, message); + } else if (obj instanceof Source) { source = (Source)obj; } @@ -157,6 +146,8 @@ } else { // JAXB element try { + org.apache.cxf.service.Service service = + message.getExchange().get(org.apache.cxf.service.Service.class); DataWriter dataWriter = getDataWriter(message, service, XMLStreamWriter.class); W3CDOMStreamWriter xmlWriter = new W3CDOMStreamWriter(); @@ -173,6 +164,68 @@ message.getInterceptorChain().add(ending); } + private Source handleSOAPMessage(Object obj, Message message) { + SOAPMessage soapMessage = (SOAPMessage)obj; + try { + //workaround bug in Sun SAAJ impl + soapMessage.getSOAPPart().getEnvelope(); + } catch (SOAPException e1) { + //ignore + } + Source source = new DOMSource(soapMessage.getSOAPPart()); + + if (soapMessage.countAttachments() > 0) { + if (message.getAttachments() == null) { + message.setAttachments(new ArrayList(soapMessage + .countAttachments())); + } + Iterator it = CastUtils.cast(soapMessage.getAttachments()); + while (it.hasNext()) { + AttachmentPart part = it.next(); + AttachmentImpl att = new AttachmentImpl(part.getContentId()); + try { + att.setDataHandler(part.getDataHandler()); + } catch (SOAPException e) { + throw new Fault(e); + } + Iterator it2 = CastUtils.cast(part.getAllMimeHeaders()); + while (it2.hasNext()) { + MimeHeader header = it2.next(); + att.setHeader(header.getName(), header.getValue()); + } + message.getAttachments().add(att); + } + } + return source; + } + + private Source handlePayloadMode(Object obj, Message message) { + Source source = null; + if (obj instanceof SOAPMessage || obj instanceof DataSource) { + throw new Fault( + new org.apache.cxf.common.i18n.Message( + "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING", + LOG, obj.getClass(), "PAYLOAD")); + } else if (obj instanceof Source) { + source = (Source)obj; + } else { + //JAXB + try { + org.apache.cxf.service.Service service = + message.getExchange().get(org.apache.cxf.service.Service.class); + SOAPMessage msg = newSOAPMessage(null, ((SoapMessage)message).getVersion()); + DataWriter dataWriter = getDataWriter(message, service, Node.class); + dataWriter.write(obj, msg.getSOAPBody()); + //msg.writeTo(System.out); + source = new DOMSource(DOMUtils.getChild(msg.getSOAPBody(), Node.ELEMENT_NODE)); + } catch (Exception e) { + throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT", + LOG), e); + } + } + return source; + } + private class DispatchOutDatabindingEndingInterceptor extends AbstractOutDatabindingInterceptor { public DispatchOutDatabindingEndingInterceptor() { super(Phase.WRITE_ENDING); @@ -190,6 +243,27 @@ if (xmlWriter != null) { xmlWriter.flush(); } else if (soapMessage != null) { + Map> heads + = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); + if (heads == null) { + heads = new HashMap>(); + message.put(Message.PROTOCOL_HEADERS, heads); + } + + soapMessage.saveChanges(); + Iterator smh = CastUtils.cast(soapMessage.getMimeHeaders().getAllHeaders()); + while (smh.hasNext()) { + MimeHeader head = smh.next(); + if ("Content-Type".equals(head.getName())) { + message.put(Message.CONTENT_TYPE, head.getValue()); + } else if (!"Content-Length".equals(head.getName())) { + if (!heads.containsKey(head.getName())) { + heads.put(head.getName(), new ArrayList()); + } + Listl = heads.get(head.getName()); + l.add(head.getValue()); + } + } soapMessage.writeTo(os); } else if (source != null) { doTransform(source, os); @@ -200,6 +274,7 @@ // Finish the message processing, do flush os.flush(); } catch (Exception ex) { + ex.printStackTrace(); throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT", LOG, ex)); } } @@ -221,6 +296,20 @@ Source source = message.getContent(Source.class); message.removeContent(Source.class); + //workaround bug in Sun SAAJ impl where + //source doesn't work if the SOAPPart was already + //created from a source + if (source instanceof DOMSource) { + DOMSource ds = (DOMSource)source; + if (ds.getNode() instanceof SOAPPart) { + try { + ((SOAPPart)ds.getNode()).getEnvelope(); + } catch (SOAPException e) { + //ignore + } + } + } + if (mode == Service.Mode.PAYLOAD) { // Input is Source in payload mode, need to wrap it // with a SOAPMessage @@ -234,11 +323,32 @@ } } else { try { - CachedOutputStream cos = new CachedOutputStream(); - Transformer transformer = XMLUtils.newTransformer(); - transformer.transform(source, new StreamResult(cos)); - obj = newSOAPMessage(cos.getInputStream(), ((SoapMessage)message).getVersion()); + SoapVersion version = ((SoapMessage)message).getVersion(); + MessageFactory msgFactory = null; + if (version == null || version instanceof Soap11) { + msgFactory = MessageFactory.newInstance(); + } else if (version instanceof Soap12) { + msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); + } + SOAPMessage msg = msgFactory.createMessage(); + msg.getSOAPPart().setContent(source); + msg.saveChanges(); + if (message.getAttachments() != null) { + for (Attachment att : message.getAttachments()) { + AttachmentPart part = msg.createAttachmentPart(att.getDataHandler()); + if (att.getId() != null) { + part.setContentId(att.getId()); + } + for (Iterator it = att.getHeaderNames(); it.hasNext();) { + String s = it.next(); + part.setMimeHeader(s, att.getHeader(s)); + } + msg.addAttachmentPart(part); + } + } + obj = msg; } catch (Exception e) { + e.printStackTrace(); throw new Fault(e); } } @@ -278,7 +388,7 @@ } if (obj instanceof DataSource) { InputStream is = ((DataSource)obj).getInputStream(); - IOUtils.copy(((DataSource)obj).getInputStream(), os); + IOUtils.copy(is, os); is.close(); } } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties Thu Oct 25 10:09:20 2007 @@ -26,3 +26,4 @@ ATTACHMENT_NOT_SUPPORTED = Attachments of type {0} are not supported. DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING = {0} is not valid in {1} mode with SOAP/HTTP binding. DISPATCH_OBJECT_NOT_SUPPORTED_XMLBINDING = {0} is not valid in {1} mode with XML/HTTP binding. +EXCEPTION_WHILE_WRITING_FAULT = Exception occurred while writing fault. Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java Thu Oct 25 10:09:20 2007 @@ -22,6 +22,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ResourceBundle; +import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.namespace.QName; @@ -34,23 +35,23 @@ import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.databinding.DataWriter; import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.interceptor.FaultOutInterceptor; import org.apache.cxf.jaxws.support.JaxWsServiceConfiguration; +import org.apache.cxf.message.FaultMode; import org.apache.cxf.message.Message; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; import org.apache.cxf.service.Service; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.FaultInfo; import org.apache.cxf.service.model.MessagePartInfo; import org.apache.cxf.service.model.OperationInfo; -public class WebFaultOutInterceptor extends AbstractPhaseInterceptor { +public class WebFaultOutInterceptor extends FaultOutInterceptor { private static final Logger LOG = LogUtils.getL7dLogger(WebFaultOutInterceptor.class); private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JaxWsServiceConfiguration.class); public WebFaultOutInterceptor() { - super(Phase.PRE_PROTOCOL); + super(); } private QName getFaultName(WebFault wf, Class cls, OperationInfo op) { @@ -104,14 +105,27 @@ } Service service = message.getExchange().get(Service.class); - DataWriter writer = service.getDataBinding().createWriter(Node.class); - - OperationInfo op = message.getExchange().get(BindingOperationInfo.class).getOperationInfo(); - QName faultName = getFaultName(fault, cause.getClass(), op); - MessagePartInfo part = getFaultMessagePart(faultName, op); - writer.write(faultInfo, part, f.getOrCreateDetail()); - - f.setMessage(ex.getMessage()); + try { + DataWriter writer = service.getDataBinding().createWriter(Node.class); + + OperationInfo op = message.getExchange().get(BindingOperationInfo.class).getOperationInfo(); + QName faultName = getFaultName(fault, cause.getClass(), op); + MessagePartInfo part = getFaultMessagePart(faultName, op); + writer.write(faultInfo, part, f.getOrCreateDetail()); + + f.setMessage(ex.getMessage()); + } catch (Exception nex) { + //if exception occurs while writing a fault, we'll just let things continue + //and let the rest of the chain try handling it as is. + LOG.log(Level.WARNING, "EXCEPTION_WHILE_WRITING_FAULT", nex); + } + } else { + FaultMode mode = message.get(FaultMode.class); + if (mode == FaultMode.CHECKED_APPLICATION_FAULT) { + //only convert checked exceptions with this + //otherwise delegate down to the normal protocol specific stuff + super.handleMessage(message); + } } } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java Thu Oct 25 10:09:20 2007 @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.logging.Logger; @@ -120,10 +121,25 @@ try { newParams = new MessageContentsList(helper.getWrapperParts(wrappedObject)); + List removes = null; for (MessagePartInfo part : messageInfo.getMessageParts()) { if (Boolean.TRUE.equals(part.getProperty(ReflectionServiceFactoryBean.HEADER))) { MessagePartInfo mpi = wrappedMessageInfo.getMessagePart(part.getName()); - newParams.put(part, lst.get(mpi)); + if (lst.hasValue(mpi)) { + newParams.put(part, lst.get(mpi)); + } else if (mpi.getTypeClass() == null) { + //header, but not mapped to a param on the method + if (removes == null) { + removes = new ArrayList(); + } + removes.add(mpi.getIndex()); + } + } + } + if (removes != null) { + Collections.sort(removes, Collections.reverseOrder()); + for (Integer i : removes) { + newParams.remove(i.intValue()); } } } catch (Exception e) { Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java Thu Oct 25 10:09:20 2007 @@ -109,7 +109,9 @@ for (MessagePartInfo p : messageInfo.getMessageParts()) { if (Boolean.TRUE.equals(p.getProperty(ReflectionServiceFactoryBean.HEADER))) { MessagePartInfo mpi = wrappedMsgInfo.getMessagePart(p.getName()); - newObjs.put(mpi, objs.get(p)); + if (objs.hasValue(p)) { + newObjs.put(mpi, objs.get(p)); + } } } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java Thu Oct 25 10:09:20 2007 @@ -268,6 +268,9 @@ Object ret = wrapperType.newInstance(); for (int x = 0; x < setMethods.length; x++) { + if (setMethods[x] == null && fields[x] == null) { + continue; + } Object o = lst.get(x); if (jaxbObjectMethods[x] != null) { o = jaxbObjectMethods[x].invoke(objectFactory, o); Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java Thu Oct 25 10:09:20 2007 @@ -20,19 +20,18 @@ package org.apache.cxf.jaxws.spi; import java.net.URL; +import java.util.List; import java.util.logging.Logger; - import javax.xml.namespace.QName; +import javax.xml.transform.Source; import javax.xml.ws.Endpoint; -//TODO JAX-WS 2.1 -//import javax.xml.ws.EndpointReference; +import javax.xml.ws.EndpointReference; import javax.xml.ws.WebServiceException; -//TODO JAX-WS 2.1 -//import javax.xml.ws.WebServiceFeature; +import javax.xml.ws.WebServiceFeature; import javax.xml.ws.spi.ServiceDelegate; -//TODO JAX-WS 2.1 -//import javax.xml.ws.wsaddressing.W3CEndpointReference; +import javax.xml.ws.wsaddressing.W3CEndpointReference; +import org.w3c.dom.Element; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; @@ -42,6 +41,7 @@ import org.apache.cxf.jaxws.EndpointUtils; import org.apache.cxf.jaxws.ServiceImpl; + public class ProviderImpl extends javax.xml.ws.spi.Provider { public static final String JAXWS_PROVIDER = ProviderImpl.class.getName(); @@ -76,28 +76,24 @@ } // TODO JAX-WS 2.1 - /* + public W3CEndpointReference createW3CEndpointReference(String address, QName serviceName, QName portName, List metadata, String wsdlDocumentLocation, List referenceParameters) { - // TODO throw new UnsupportedOperationException(); } public T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, WebServiceFeature... features) { - // TODO throw new UnsupportedOperationException(); } public EndpointReference readEndpointReference(Source eprInfoset) { - // TODO throw new UnsupportedOperationException(); } - */ } Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java Thu Oct 25 10:09:20 2007 @@ -144,7 +144,7 @@ throws BeanDefinitionStoreException { String id = super.resolveId(elem, definition, ctx); if (StringUtils.isEmpty(id)) { - id = getBeanClass().getName() + "--" + hashCode(); + id = getBeanClass().getName() + "--" + definition.hashCode(); } return id; Modified: incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=588283&r1=588282&r2=588283&view=diff ============================================================================== --- incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java (original) +++ incubator/cxf/branches/jliu/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java Thu Oct 25 10:09:20 2007 @@ -22,6 +22,9 @@ import java.util.List; import javax.xml.ws.Binding; +import javax.xml.ws.WebServiceFeature; +import javax.xml.ws.soap.MTOMFeature; +import javax.xml.ws.soap.SOAPBinding; import org.apache.cxf.Bus; import org.apache.cxf.binding.soap.SoapBinding; @@ -63,15 +66,18 @@ private Binding jaxwsBinding; private JaxWsImplementorInfo implInfo; + private List wsFeatures; public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei) throws EndpointException { - this(bus, s, ei, null); + this(bus, s, ei, null, null); } - public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei, JaxWsImplementorInfo implementorInfo) + public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei, JaxWsImplementorInfo implementorInfo, + List features) throws EndpointException { super(bus, s, ei); this.implInfo = implementorInfo; + this.wsFeatures = features; createJaxwsBinding(); @@ -130,9 +136,25 @@ return jaxwsBinding; } + private MTOMFeature getMTOMFeature() { + if (wsFeatures == null) { + return null; + } + for (WebServiceFeature feature : wsFeatures) { + if (feature instanceof MTOMFeature) { + return (MTOMFeature)feature; + } + } + return null; + } + final void createJaxwsBinding() { if (getBinding() instanceof SoapBinding) { jaxwsBinding = new SOAPBindingImpl(getEndpointInfo().getBinding()); + MTOMFeature mtomFeature = getMTOMFeature(); + if (mtomFeature != null && mtomFeature.isEnabled()) { + ((SOAPBinding)jaxwsBinding).setMTOMEnabled(true); + } } else if (getBinding() instanceof XMLBinding) { jaxwsBinding = new HTTPBindingImpl(getEndpointInfo().getBinding()); } else {