axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Srinath Perera" <>
Subject RE: serialize / desirialize SOAPHeader
Date Wed, 09 Jul 2003 03:38:08 GMT
Hi All

Thanks for Cris and Daniels am in move.

I have another prob. When I serialize SOAPHeaderElement ect... I want to
serialize custom Object set as objectValue with in the SOAPBodyElement. Ok to
do so I have to register
Serializer to custom object to the system. I do not want to use wsdd file
(this is my custom app). 

So I add the code in DefaultTypeMappingImpl  to registor type with basic
types. It works happly!!. I want to o the same without change the src code i
try following.

SerializationContext sc = new SerializationContextImpl(w);
TypeMappingRegistry reg = new TypeMappingRegistryImpl();
javax.xml.rpc.encoding.TypeMapping t = reg.createTypeMapping();
t.register(Parameter.class , Constants.SOAP_RESULT,
                           new ResultSerializerFactory(),null);
reg.register("" ,t);

env.output(sc); //this is envelop

The exception says it can't find serializer (it seems it only look at noly in
default type mapping).

And it also does not let you change the DefaultTypeMapping dynamically.
Thanks for your time.



Lanka Software Foundation  (
Promoting Open-Source Development in Sri Lanka.

---------- Original Message -----------
From: Glen Daniels <>
To: "''" <>
Sent: Mon, 7 Jul 2003 10:59:53 -0400 
Subject: RE: serialize / desirialize SOAPHeader

> Hi Srinath!
> > I look at message, encoding packages in src. But the SOAP 
> > Header ect depend on 
> > serializingContext,DesializingContext which in turn depend on 
> > MessageContext which is not avalible to me. (This is my 
> > custom application).
> Depending on how you do this, it might be a bit of a problem.  The 
> Axis message classes are pretty dependent on Axis constructs like 
> the *Contexts, and it's appropriate that they are written this way.  
> You can always move up the stack to the SAAJ interfaces and rewrite 
> the implementations yourself if you want.  But manipulating the Axis 
> classes is easier than you might think.
> > public static void main(String[] args)throws Exception {
> > // create SOAPHeader from the response rq.xml(SOAP message)
> >   SOAPHeader h = new SOAPHeader("", 
> > "Transaction", "t", 
> >    null, new DeserializationContextImpl(
> >             new InputSource(
> >                         new FileInputStream(".//samples//rq.xml")),
> >             null,
> >             Constants.URI_SOAP12_RPC),
> >             SOAPConstants.SOAP11_CONSTANTS);
> >          System.out.println("h = " + h.getName());
> >          System.out.println("h = " + h.getValue());
> >          Writer w = new FileWriter(".//samples//rs.xml"); 
> > //write the header back to the res.xml
> >          h.output(new SerializationContextImpl(w ));
> >          w.flush();
> >          w.close();
> OK, first off - the SOAPHeader class represents the <SOAP:Header> 
> element, not an individual header inside it (personally I've never 
> really seen the need to have a class for this - we used to have a 
> "SOAPHeader" class which represented individual headers, and you'd 
> have a list of those in the SOAPEnvelope, but then JAX-RPC/SAAJ 
> changed that, making it more complicated without, IMHO, buying you 
> much of anything).  So you probably want to be using 
> SOAPHeaderElement instead.
> Second, if you want to take an existing SOAP message in your rq.xml 
> file, parse it, and then operate on it, you'll need to construct the 
> DeserializationContextImpl first, then call parse() on it to set up 
> the envelope object tree.  After that you can create 
> SOAPHeaderElements and add/remove them to your heart's content.
> All the constructors for the axis.message.* classes which take 
> DeserializationContext arguments are meant to be used ONLY by the 
> deserialization system.  So when you're creating these things 
> yourself, use the other constructors instead.  So you can do 
> something like:
>   SOAPHeaderElement myHeader = new SOAPHeaderElement("http://my-
> namespace/", "CustomHeader");  myHeader.setMustUnderstand(true);  // 
> etc...  myEnvelope.addHeader(myHeader);
> There are examples of dynamically creating SOAP envelopes scattered 
> throughout our tests - for instance, test.encoding.TestDOM,
>  test.soap.TestFaultHandler, test.message.TestSOAPEnvelope, etc....
> Hope this helps,
> --Glen
------- End of Original Message -------

View raw message