Search in sources :

Example 6 with XmlMimeType

use of javax.xml.bind.annotation.XmlMimeType in project jbossws-cxf by jbossws.

the class WrappedEndpointImpl method parameterAnnotation.

@WebMethod
@XmlMimeType("text/plain")
public DataHandler parameterAnnotation(@XmlMimeType("text/plain") DataHandler data) {
    try {
        System.out.println("Recv " + data.getContentType());
        Object dataContent = data.getContent();
        System.out.println("Got " + dataContent);
        if (dataContent instanceof InputStream) {
            ((InputStream) dataContent).close();
        }
        return new DataHandler("Server data", "text/plain");
    } catch (IOException e) {
        throw new WebServiceException(e);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) InputStream(java.io.InputStream) DataHandler(javax.activation.DataHandler) IOException(java.io.IOException) WebMethod(javax.jws.WebMethod) XmlMimeType(javax.xml.bind.annotation.XmlMimeType)

Example 7 with XmlMimeType

use of javax.xml.bind.annotation.XmlMimeType in project cxf by apache.

the class WrapperClassGenerator method addJAXBAnnotations.

private boolean addJAXBAnnotations(FieldVisitor fv, List<Annotation> jaxbAnnos, String name) {
    AnnotationVisitor av0;
    boolean addedEl = false;
    for (Annotation ann : jaxbAnnos) {
        if (ann instanceof XmlMimeType) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
            av0.visit("value", ((XmlMimeType) ann).value());
            av0.visitEnd();
        } else if (ann instanceof XmlJavaTypeAdapter) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
            generateXmlJavaTypeAdapter(av0, (XmlJavaTypeAdapter) ann);
            av0.visitEnd();
        } else if (ann instanceof XmlAttachmentRef) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
            av0.visitEnd();
        } else if (ann instanceof XmlList) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
            av0.visitEnd();
        } else if (ann instanceof XmlElement) {
            addedEl = true;
            XmlElement el = (XmlElement) ann;
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
            if ("##default".equals(el.name())) {
                av0.visit("name", name);
            } else {
                av0.visit("name", el.name());
            }
            av0.visit("nillable", el.nillable());
            av0.visit("required", el.required());
            av0.visit("namespace", el.namespace());
            av0.visit("defaultValue", el.defaultValue());
            if (el.type() != XmlElement.DEFAULT.class) {
                av0.visit("type", el.type());
            }
            av0.visitEnd();
        } else if (ann instanceof XmlElementWrapper) {
            XmlElementWrapper el = (XmlElementWrapper) ann;
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElementWrapper;", true);
            av0.visit("name", el.name());
            av0.visit("nillable", el.nillable());
            av0.visit("required", el.required());
            av0.visit("namespace", el.namespace());
            av0.visitEnd();
        }
    }
    return addedEl;
}
Also used : XmlMimeType(javax.xml.bind.annotation.XmlMimeType) XmlAttachmentRef(javax.xml.bind.annotation.XmlAttachmentRef) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlElement(javax.xml.bind.annotation.XmlElement) Annotation(java.lang.annotation.Annotation) XmlElementWrapper(javax.xml.bind.annotation.XmlElementWrapper) XmlList(javax.xml.bind.annotation.XmlList)

Aggregations

XmlMimeType (javax.xml.bind.annotation.XmlMimeType)7 IOException (java.io.IOException)4 DataHandler (javax.activation.DataHandler)4 WebServiceException (javax.xml.ws.WebServiceException)4 Annotation (java.lang.annotation.Annotation)3 XmlAttachmentRef (javax.xml.bind.annotation.XmlAttachmentRef)2 XmlElement (javax.xml.bind.annotation.XmlElement)2 XmlList (javax.xml.bind.annotation.XmlList)2 XmlJavaTypeAdapter (javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter)2 InputStream (java.io.InputStream)1 WebMethod (javax.jws.WebMethod)1 XmlElementWrapper (javax.xml.bind.annotation.XmlElementWrapper)1 MimeAttribute (org.apache.cxf.databinding.source.mime.MimeAttribute)1 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)1 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)1 JavaField (org.apache.cxf.tools.common.model.JavaField)1