users@jaxb.java.net

marshalling using custom SOAP bindings

From: jesse crossley <jesse.crossley_at_gmail.com>
Date: Wed, 18 Jul 2007 10:49:52 -0700 (PDT)

first off, i know there are SOAP APIs that i could use, but since i already
have good code for delivering SOAP messages, all i want to do is marshal my
messages using JAXB bindings.

so i produced bindings using the SOAP envelope.xsd and my required wsdls and
xsds, and i can unmarshal with these just fine:
my SOAP reader uses just the envelope.xsd for its context, and when i
extract the anies from env->body->any i get Nodes, which i can then pass on
to my more specific readers for unmarshalling into actual generated, binding
objects.

however, i cannot find the proper way to add objects to the SOAP envelope's
body's list of anies, since the list is a List<Element>, and my other
generated binding objects don't extend Element. i tried to use the
Marshaller.getNode() method to get a (hopefully castable) Node representing
the object i wanted to add to the List of anyies, but that failed:

Exception in thread "main" java.lang.UnsupportedOperationException
        at
javax.xml.bind.helpers.AbstractMarshallerImpl.getNode(AbstractMarshallerImpl.java:124)
        at
mil.cfn.uswdss.mdi.binding.subscription.SubscriptionWriter.createEnvelope(SubscriptionWriter.java:63)
        at
mil.cfn.uswdss.mdi.binding.subscription.SubscriptionWriter.main(SubscriptionWriter.java:353)


can anyone shed some light on my situation? code snippets are below, and i
can certainly try to explain things more fully if need be.

thanks,
jdc


public static final Envelope createEnvelope(
            final AddEventListener addEventListener) {
        final Envelope returnable = soapOF.createEnvelope();
        try {
            final Node addEventListenerNode = getMarshaller().getNode(
                    addEventListener);
            // PENDING(jdc): gotta make sure this is a safe cast..
           
returnable.getBody().getAnies().add((Element)addEventListenerNode);
            
        } catch (final JAXBException jaxbe) {
            getClassLog().error("Failed...", jaxbe);
        }
        return returnable;
    }

    private static final String CONTEXT =
        "org.xmlsoap.schemas.soap.envelope:" +
        "peoiws5.mdiapps.soap.ws.shws.types";
    
    private static JAXBContext context;
    
    static {
        // initialize the JAXBContext
        try {
            context = JAXBContext.newInstance(CONTEXT);
            
            if (getClassLog().isTraceEnabled()) {
                getClassLog().trace("our context is " + context.toString());
            }
        } catch (final JAXBException jaxbe) {
            getClassLog().error("Failed to initialize the JAXBContext.",
jaxbe);
        }
    }
-- 
View this message in context: http://www.nabble.com/marshalling-using-custom-SOAP-bindings-tf4104769.html#a11673568
Sent from the java.net - jaxb users mailing list archive at Nabble.com.