Excellent trick!  Thanks for the help.

I had been toying with passing the two values I need in with
.getStub()._setProperty("weblogic.webservice.client.proxyusername",myVal
ue) and "context.getProperty("weblogic.webservice.client.proxyusername")
and the password property.  Because no proxy server address was defined,
the username and password values were ignored by the control and
service, but my handler could still use them.  But I think your method
of using Headers is cleaner and not as "hackish".

Also, the solution needs to be thread safe as the client will be running
in a Weblogic application of its own, which may have multiple users
logged in at once accessing the application and making parallel calls to
the web service.  I still need to read up a little in this area; does
the control bean get shared among threads, or is a new instance
instantiated for each request.  Is a new Handler instantiated for each
request, etc.

Thanks again for your help,
Ben

-----Original Message-----
From: Andrew McCulloch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 30, 2006 6:15 PM
To: Beehive Users
Subject: Re: Pass properties to WS Handler

Ben,

There is a easy way to pass properties to either a client or server side
handler.  The difference is how the handler accesses these properties.
To
set properties you would use the setOuputHeaders(Element[]) method on
the
web service control before invoking the method you want to call.

Ex:
String fragment = "<MyHeaders><MyHeader>STOP</MyHeader></MyHeaders>";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document d = factory.newDocumentBuilder().parse(new InputSource(new
StringReader(fragment)));
NodeList nl = d.getElementsByTagName("MyHeader");
helloWorldServiceControl.setOutputHeaders(new Element[] { nl.item(0) }
);

In the server side handler (not the case you describe) you can simply
retrieve the headers from the message context object.

Unfortunately the headers are not put on the message context until after
you
client side handler is invoked, so, there is a more round-about way to
access this data from the client handler.

    public boolean handleRequest(MessageContext context)
    {
        List outboundHeaders = (List)context.getProperty(
weblogic.wsee.ws.dispatch.client.ConnectionHandler.OUTPUT_HEADERS);
        if (outboundHeaders != null) {
          Iterator iter = outboundHeaders.iterator();
          while (iter.hasNext()) {
            Element elt = (Element) iter.next();
            if ("STOP".equals(elt.getTextContent())) {
                throw new IllegalArgumentException("Stopping service
call
due to STOP header");
            }
          }
        }
        return true;
    }

I am sure there are other ways to accomplish what you are after but this
works for me :)
I hope this helps,
--Andrew




On 11/30/06, Burgess, Benjamin <[EMAIL PROTECTED]> wrote:
>
> Yes, I believe you are correct.  Here is the relevant part of my
Control
> (I changed the endpoint address):
>
> import org.apache.beehive.controls.api.bean.ControlExtension;
> import org.apache.beehive.controls.api.events.EventSet;
>
> import com.bea.control.ServiceControl;
>
> @ServiceControl.Location(urls = {
"http://my.server.address/appname/ws";
> })
> @ServiceControl.HttpSoapProtocol
> @ServiceControl.Handler(operation =
> {"org.tiaa.datalayer.DSVSecurityHandler"})
> @ServiceControl.SOAPBinding(style =
> ServiceControl.SOAPBinding.Style.DOCUMENT, use =
> ServiceControl.SOAPBinding.Use.LITERAL, parameterStyle =
> ServiceControl.SOAPBinding.ParameterStyle.WRAPPED)
> @ServiceControl.WSDL(resourcePath = "org/tiaa/datalayer/DSVNET.wsdl",
> service = "DSVNetWebServiceService")
> @ControlExtension
> @SuppressWarnings("serial")
> public interface DSVNetWebServiceControl extends ServiceControl {
>
> Ben
>
> -----Original Message-----
> From: Andrew McCulloch [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 30, 2006 12:22 PM
> To: Beehive Users
> Subject: Re: Pass properties to WS Handler
>
> Hi Ben,
>
> Can you tell me if this is a client/control side handler or
> server/web-service side handler?  Also a bit of the handler config
file
> would be helpful.
>
> P.S.
> I am assuming that when you said you are using a control from a
Weblogic
> application that you are using the BEA Workshop web service control
and
> not
> the web service control in the beehive svn tree [I don't believe the
one
> in
> svn is shipped with the apache beehive distribution or BEA Workshop].
> Is
> that correct?
>
> On 11/30/06, Burgess, Benjamin <[EMAIL PROTECTED]> wrote:
> >
> > I am fairly new to Web Services and very new to Beehive.  So far, I
> love
> > it.  I have a Weblogic application that will be calling a web
service
> > running on another box via a Control.
> >
> >
> >
> > Is there a way to pass dynamic properties to a handler that I have
> > configured?  If I use a handler config file, then I can setup
> > init-params, but these can't change from request to request.  The
> > "MessageContext" object can be used to pass properties between
> handlers,
> > but can it be accessed somehow from the client before starting the
> SOAP
> > request (in the Control)?
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Ben
> >
> >
> >
> > **************************************************************
> > This message, including any attachments, contains confidential
> information
> > intended for a specific individual and purpose, and is protected by
> law.  If
> > you are not the intended recipient, please contact sender
immediately
> by
> > reply e-mail and destroy all copies.  You are hereby notified that
any
> > disclosure, copying, or distribution of this message, or the taking
of
> any
> > action based on it, is strictly prohibited.
> > TIAA-CREF
> > **************************************************************
> >
> >
> >
>

Reply via email to