Hi Hozefa:
I wouldn't rely on the MessageContext being set in the constructor for your
object, although it is interesting that we apparently make two service
objects - I'll look into that to see what's up there.
The MessageContext represents information about a PARTICULAR
request/invocation, and thus should be examined only in the context of an
actual service method (doSomething()). Don't cache it, either, btw!
If you have a need to know more about the local Axis configuration around your
service object at construction time, we can see about perhaps giving you a
pointer to the AxisEngine or something, but a MessageContext isn't the
appropriate tool here.
--Glen
----- Original Message -----
From: "Hozefa Botee" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 04, 2002 6:19 PM
Subject: MessageContext?
> If I want to access the MessageContext to add a header to the
> response from a client call, where is the appropriate place in
> my code to call MessageContext.getCurrentContext()? if I put
> it in the constructor of my service with some debugging code,
> it appears that the constructor gets called twice, and only on
> the second call is there a non-null MessageContext. here's
> some sample code:
>
> the line 'making demo' shows up twice in my Tomcat window. the
> impl.Demo constructor is where I try to get a handle to the
> MessageContext.
>
> thoughts?
>
> /**
> * DemoSoapBindingImpl.java
> *
> * This file was auto-generated from WSDL
> * by the Apache Axis Wsdl2java emitter.
> */
>
> package samples;
>
> public class DemoSoapBindingImpl implements samples.Demo {
>
> private impl.Demo myObject;
>
> public DemoSoapBindingImpl()
> {
> try
> {
> myObject = new impl.Demo();
> System.err.println("making demo");
> }
> catch(java.lang.Exception e)
> {
> System.err.println("failed making demo");
> e.printStackTrace();
> }
> }
>
> public java.lang.String doSomething(java.lang.String in1,
> java.lang.String in2, int in3) throws java.rmi.RemoteException {
> return myObject.doSomething(in1, in2, in3);
> }
> }
>