You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jansen Werner <We...@eon-is.com> on 2006/07/03 14:10:21 UTC

Adding own handler in Java Code?

Hallo everybody,

I need to add handlers to Axis dynamically in Java Code. I found
examples of adding handlers (logHandlers, for example) to
server-config.wsdd. But I need to add them dynamically and on the client
side of the SOAP call.

Could anyone give me a hint? 

Thanks in advance, 

Werner Jansen

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


axis engine 'runs' from ? HELP!! axis1.4

Posted by Enrico Silterra <es...@cornell.edu>.

I am trying to deploy a service into a
axis engine that is running within another webapp.

But I don't know the meaning of the phrase 'axis engine "runs" from'



the hierarchy looks something like:

webapps/Glunk/
and the axis servlet is defined as:

     <servlet-mapping>
         <servlet-name>XXXServlet</servlet-name>
         <url-pattern>/xearch/*</url-pattern>
     </servlet-mapping>

  <servlet>
     <servlet-name>XXXServlet</servlet-name>
     <servlet-class>
         ORG.oclc.os.xxx.XXXServlet
     </servlet-class>
     <init-param>
       <param-name>PropertiesFile</param-name>
       <param-value>/resources/XX/XXXServer.properties</param-value>
     </init-param>
     <!--load-on-startup>100</load-on-startup-->
   </servlet>
and the XXXServlet.java is derived from AxisServlet.

so, that
.../Glunk/xearch

gives you the listing of available services.

If I try to run using the Client deploy:
libdev: ./deploy.sh  org.apache.axis.client.AdminClient 
-lhttp://www.edu:8080/Glunk/xearch -ddd  xxx_deploy.wsdd
Processing file xxx_deploy.wsdd
Exception: AxisFault
  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
  faultSubcode:
  faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a 
child element, which is NOT expected, in something it was trying to 
deserialize.
  faultActor:
  faultNode:
  faultDetail:
         {http://xml.apache.org/axis/}hostname:libdev

But this is the same deploy file I was using when using the standalong axis 
engine.
I don't understand the error message, of the client deploy,
and I can't figure out where to run the 'local' deploy.

HELP!!!!

Rick






Re: Adding own handler in Java Code?

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Werner,

The way I described to register handlers on the client side is the 
JAX-RPC 1.1 compliant way. It works on Axis 1.x and any other JAX-RPC 
1.1 compliant SOAP engine.
However, it requires you to use the interfaces in javax.xml.rpc. I do 
not know what would happen if you mix it with Axis' org.apache.axis classes.
If you do not care about JAX-RPC compliance and do not mind a direct 
dependence on Axis code, read Rodrigo's replies. I am not familiar with 
that way, but it should work too.

 > This is my code (service is an instance of
 > org.apache.axis.client.Service, Loghandler is
 > org.apache.axis.handlers.LogHandler, the rest is like you wrote it):

Can you try using the javax.xml.rpc equivalents?

Refer also to the following example:
axis-1_3\samples\jaxrpc\hello

Hope that helps!
Regards,
Dies


Jansen Werner wrote:
> Good morning Dies,
> 
> thanks for your help! I tried what you wrote and couldn't get it
> working.
> 
> This is my code (service is an instance of
> org.apache.axis.client.Service, Loghandler is
> org.apache.axis.handlers.LogHandler, the rest is like you wrote it):
> 
> private static void registerHandlers(Service service)
>     {
>         HandlerRegistry hr = service.getHandlerRegistry();
> 
>         List<HandlerInfo> hl = new ArrayList<HandlerInfo>();
>         hl.add(new HandlerInfo(LogHandler.class, null, null));
>         hr.setHandlerChain(new QName(
>                 "http://www.eon-is.com/namespaces/soap/1.0", "log"),
> hl);
>     } 
> 
> service is initialized using its default constructor before calling
> registerHandlers (Service service = new Service();). After calling
> registerHandlers and registerTypeMappings (adding Classes, Serializers
> and so on), this instance is used to create a call (call = (Call)
> service.createCall();) that is filled with parameters, values, endpoint,
> ... and then executed.
> 
> When I run my SOAP call that calls registerHandlers before executing,
> nothing happens. At least nothing different from when the Handler was
> not included. What did I do wrong? If there's any information needed for
> further help, let me know. I'm stuck, I feel like finding lost contact
> lenses in a dark alley if you had quite a few beers. Not that I know how
> this feels like, but it must be similar to this :)
> 
> Greetings from Munich,
> 
> Werner
> 
> 
>> -----Original Message-----
>> Sent: Tuesday, July 04, 2006 1:55 AM
>> To: axis-user@ws.apache.org
>> Subject: Re: Adding own handler in Java Code?
>>
>> Hello Werner,
>>
>> Refer to the JAX-RPC1.1 spec to see how to use a client handler in a 
>> portable way. I believe it goes something like this:
>>
>>    sf = javax.xml.rpc.ServiceFactory.newInstance();
>>    SEIService si = (SEIService)sf.loadService(SEIService.class);
>>
>>    // register client handler
>>    javax.xml.rpc.handler.HandlerRegistry hr = si.getHandlerRegistry();
>>    java.util.List hl = new java.util.ArrayList();
>>    hl.add(new 
>> javax.xml.rpc.handler.HandlerInfo(YourHandler.class,null,null));
>>    hr.setHandlerChain(new 
>> QName("http://localhost/xxx/","yourPort"),hl);
>>
>>    SEI sei = si.getSEIPort();
>>
>> YourHandler should implement javax.xml.rpc.handler.Handler.
>> I don't know whether the LogHandler you are referring to is a JAX-RPC 
>> compliant one..
>>
>> Hope that helps,
>> Dies
>>
>>
>> Jansen Werner wrote:
>>>> If you mean "selecting a subset among an already well-known set of 
>>>> available handlers", the answer is that it is easier :-)
>>>>
>>>> You will have to create a handler that could act as a 
>>>> "handler chain", 
>>>> and put into it the logic to take the decision about what 
>> handlers to 
>>>> actually call when invoked. Depending on what you need, 
>> this handler 
>>>> will have the information needed to find out the handlers to 
>>>> call (for 
>>>> example, by parsing a policy), or you may have to include the 
>>>> mechanisms 
>>>> to communicate with it from the service implementations or 
>>>> other points, 
>>>> and configure it at runtime.
>>> OK, this sounds like my problem.
>>>
>>> For an example, let's take the LogHandler packaged with 
>> axis. How can I
>>> add this (simple, easy) Handler to Axis at runtime? (And 
>> remove it later
>>> ...).
>>>
>>> I have found a way to access the HandlerRegistry
>>> (Service.getHandlerRegistry()). But - without deeper 
>> knowledge of the
>>> HandlerChains available - how do I add my Handler (or the LogHandler
>>> mentioned above)?
>>>
>>>> Just keep in mind that you need to respect the handlers 
>>>> interface, and 
>>>> call their methods in the appropriate order. That is, to 
>>>> initialise them 
>>>> before invoking them, and the like.
>>> This is something I will concentrate on when I managed to add the
>>> LogHandler provided by Axis :)
>>>
>>> Ah, before I forget it again, our Axis version is 1.3 :)
>>>
>>> Thanks in advance :)
>>>
>>> CU
>>> Werner


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: Adding own handler in Java Code?

Posted by Jansen Werner <We...@eon-is.com>.
Good morning Dies,

thanks for your help! I tried what you wrote and couldn't get it
working.

This is my code (service is an instance of
org.apache.axis.client.Service, Loghandler is
org.apache.axis.handlers.LogHandler, the rest is like you wrote it):

private static void registerHandlers(Service service)
    {
        HandlerRegistry hr = service.getHandlerRegistry();

        List<HandlerInfo> hl = new ArrayList<HandlerInfo>();
        hl.add(new HandlerInfo(LogHandler.class, null, null));
        hr.setHandlerChain(new QName(
                "http://www.eon-is.com/namespaces/soap/1.0", "log"),
hl);
    } 

service is initialized using its default constructor before calling
registerHandlers (Service service = new Service();). After calling
registerHandlers and registerTypeMappings (adding Classes, Serializers
and so on), this instance is used to create a call (call = (Call)
service.createCall();) that is filled with parameters, values, endpoint,
... and then executed.

When I run my SOAP call that calls registerHandlers before executing,
nothing happens. At least nothing different from when the Handler was
not included. What did I do wrong? If there's any information needed for
further help, let me know. I'm stuck, I feel like finding lost contact
lenses in a dark alley if you had quite a few beers. Not that I know how
this feels like, but it must be similar to this :)

Greetings from Munich,

Werner





> -----Original Message-----
> From: Dies Koper [mailto:dies@jp.fujitsu.com] 
> Sent: Tuesday, July 04, 2006 1:55 AM
> To: axis-user@ws.apache.org
> Subject: Re: Adding own handler in Java Code?
> 
> Hello Werner,
> 
> Refer to the JAX-RPC1.1 spec to see how to use a client handler in a 
> portable way. I believe it goes something like this:
> 
>    sf = javax.xml.rpc.ServiceFactory.newInstance();
>    SEIService si = (SEIService)sf.loadService(SEIService.class);
> 
>    // register client handler
>    javax.xml.rpc.handler.HandlerRegistry hr = si.getHandlerRegistry();
>    java.util.List hl = new java.util.ArrayList();
>    hl.add(new 
> javax.xml.rpc.handler.HandlerInfo(YourHandler.class,null,null));
>    hr.setHandlerChain(new 
> QName("http://localhost/xxx/","yourPort"),hl);
> 
>    SEI sei = si.getSEIPort();
> 
> YourHandler should implement javax.xml.rpc.handler.Handler.
> I don't know whether the LogHandler you are referring to is a JAX-RPC 
> compliant one..
> 
> Hope that helps,
> Dies
> 
> 
> Jansen Werner wrote:
> >> If you mean "selecting a subset among an already well-known set of 
> >> available handlers", the answer is that it is easier :-)
> >>
> >> You will have to create a handler that could act as a 
> >> "handler chain", 
> >> and put into it the logic to take the decision about what 
> handlers to 
> >> actually call when invoked. Depending on what you need, 
> this handler 
> >> will have the information needed to find out the handlers to 
> >> call (for 
> >> example, by parsing a policy), or you may have to include the 
> >> mechanisms 
> >> to communicate with it from the service implementations or 
> >> other points, 
> >> and configure it at runtime.
> > 
> > OK, this sounds like my problem.
> > 
> > For an example, let's take the LogHandler packaged with 
> axis. How can I
> > add this (simple, easy) Handler to Axis at runtime? (And 
> remove it later
> > ...).
> > 
> > I have found a way to access the HandlerRegistry
> > (Service.getHandlerRegistry()). But - without deeper 
> knowledge of the
> > HandlerChains available - how do I add my Handler (or the LogHandler
> > mentioned above)?
> > 
> >> Just keep in mind that you need to respect the handlers 
> >> interface, and 
> >> call their methods in the appropriate order. That is, to 
> >> initialise them 
> >> before invoking them, and the like.
> > 
> > This is something I will concentrate on when I managed to add the
> > LogHandler provided by Axis :)
> > 
> > Ah, before I forget it again, our Axis version is 1.3 :)
> > 
> > Thanks in advance :)
> > 
> > CU
> > Werner
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code?

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Werner,

Refer to the JAX-RPC1.1 spec to see how to use a client handler in a 
portable way. I believe it goes something like this:

   sf = javax.xml.rpc.ServiceFactory.newInstance();
   SEIService si = (SEIService)sf.loadService(SEIService.class);

   // register client handler
   javax.xml.rpc.handler.HandlerRegistry hr = si.getHandlerRegistry();
   java.util.List hl = new java.util.ArrayList();
   hl.add(new 
javax.xml.rpc.handler.HandlerInfo(YourHandler.class,null,null));
   hr.setHandlerChain(new QName("http://localhost/xxx/","yourPort"),hl);

   SEI sei = si.getSEIPort();

YourHandler should implement javax.xml.rpc.handler.Handler.
I don't know whether the LogHandler you are referring to is a JAX-RPC 
compliant one..

Hope that helps,
Dies


Jansen Werner wrote:
>> If you mean "selecting a subset among an already well-known set of 
>> available handlers", the answer is that it is easier :-)
>>
>> You will have to create a handler that could act as a 
>> "handler chain", 
>> and put into it the logic to take the decision about what handlers to 
>> actually call when invoked. Depending on what you need, this handler 
>> will have the information needed to find out the handlers to 
>> call (for 
>> example, by parsing a policy), or you may have to include the 
>> mechanisms 
>> to communicate with it from the service implementations or 
>> other points, 
>> and configure it at runtime.
> 
> OK, this sounds like my problem.
> 
> For an example, let's take the LogHandler packaged with axis. How can I
> add this (simple, easy) Handler to Axis at runtime? (And remove it later
> ...).
> 
> I have found a way to access the HandlerRegistry
> (Service.getHandlerRegistry()). But - without deeper knowledge of the
> HandlerChains available - how do I add my Handler (or the LogHandler
> mentioned above)?
> 
>> Just keep in mind that you need to respect the handlers 
>> interface, and 
>> call their methods in the appropriate order. That is, to 
>> initialise them 
>> before invoking them, and the like.
> 
> This is something I will concentrate on when I managed to add the
> LogHandler provided by Axis :)
> 
> Ah, before I forget it again, our Axis version is 1.3 :)
> 
> Thanks in advance :)
> 
> CU
> Werner


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code? [SOLVED]

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Greetings!

Enabling and disabling other arbitrary handlers is the hard option. 
Implement a handler that can enable/disable itself is considerably 
easier :-D

CU & Good luck!

Jansen Werner wrote:
> Hi again :)
> 
> My handlers are working. But I gave up the initial idea. This is how it works:
> 
> - The handler is included in client-config.wsdd ("hardcoded")
> - The handler checks for itself if it should do anything. So I can activate and deactivate handlers "on the fly". (or, better, activate and deactivate functionality provided by those handlers)
> 
> But there's still an open issue: BeanSerializers and Namespaces. But I will post that in another mail to this list, so the subject doesn't get confused.
> 
> Have a nice day! :)
> 
> CU
> Werner 
> 
>> -----Original Message-----
>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>> Sent: Tuesday, July 04, 2006 3:02 PM
>> To: axis-user@ws.apache.org
>> Subject: Re: Adding own handler in Java Code?
>>
>> Ok, what I described you allows you to configure your chain in a 
>> per-call basis. If you just need it per-execution, it becomes 
>> simpler :-)
>>
>> But... why do you want to do this programmatically? Is it for 
>> usability 
>> reasons?
>>
>> If you want to select the set of handlers to use before starting your 
>> application, you can implement a standalone tool that could allow you
>> to "visually" edit your client-config.wsdd, and show a 
>> simplified GUI to 
>> select among the available handlers. I would like a copy of 
>> such a tool :-D
>>
>> If you know which handlers you will need before starting to use Axis, 
>> you can generate your client-config.wsdd from within your 
>> application, 
>> and use the generated WSDD as the configuration for your Axis engine.
>>
>> If you want to go through the Axis API and modify the 
>> configuration once 
>> all has started, the quick answer is "you can't". Axis is not 
>> prepared 
>> to let you add and remove handlers as you like. There are several 
>> conditions that will change what you need to call/do in order to make 
>> things work.
>>
>> First, you cannot remove handlers from chains. They have no 
>> methods for 
>> this.
>>
>> Second, handlers (and chains) can optionally be deployed as 
>> singletons. 
>> When in singleton mode, changes to the WSDD deployment 
>> descriptor will 
>> not affect an existing instance, and you will have to directly modify 
>> the instance itself. When not in this mode, Axis will create a new 
>> instance each time the "get" method is called, and so, any change you 
>> make to an instance will not have effect on the actual flow.
>>
>> Third, you can only add handlers to the end of a chain, but usually 
>> handlers must be deployed in different order depending on 
>> which flow you 
>> are adding them to. The response flow uses a reversed order 
>> with respect 
>> to the request one. This means that you must add all 
>> necessary handlers 
>> at once. Adding them incrementally will not work.
>>
>> And fourth, the things you need to do require using several internal 
>> classes that are not considered part of the Axis stable API. 
>> This means 
>> that you may have severe problems whenever you want to 
>> upgrade the Axis 
>> version.
>>
>> Although it may seem too complex, I still think that the approach I 
>> proposed you before is the best one. You can make 
>> DynamicChain get the 
>> list of active handlers from a Singleton class of your own, 
>> and use that 
>> class to specify which handlers you add or remove. This way your 
>> application code is kept simple.
>>
>>
>> Hope this helps,
>> Rodrigo Ruiz
>>
>>
>> Jansen Werner wrote:
>>> Hi Rodrigo,
>>>
>>> is it really that complicated to include a handler? Within 
>> server-config.wsdd, it's just a single line to include the 
>> (example) LogHandler, why is it so complicated to inject it via API? 
>>> As a resumee, this is what I want to do:
>>>
>>> - add a Handler to Message Processing. Nothing complicated. 
>> Complexity similar to the org.apache.axis.handlers.LogHandler 
>> provided by Axis.
>>> - do this in client and server
>>> - within the server, this is easy using <handler>-Tags in 
>> server-config.wsdd, because the handler is needed always. 
>> This works already.
>>> - within the client, client-config.wsdd is inappropriate, 
>> because the handler isn't used on every run of the client.
>>> - How is it possible to inject a (simple) Handler via Java 
>> Calls the way it would be in client-config.wsdd or 
>> server-config.wsdd. As an example, I'm still trying to use 
>> the LogHandler provided by Axis (which extends 
>> org.apache.axis.handlers.BaseHandler, which itself implements 
>> org.apache.axis.Handler (which does only extend Serializable, 
>> and no javax.rpc-Interface).
>>>  
>>> I thought this must be a very simple thing to do. What you 
>> wrote sounds profound but is very complicated for a (in my 
>> eyes) simple thing: adding a Handler to message Processing.
>>> ... hoping for an answer ... :)
>>>
>>> CU
>>> Werner
>>>
>>>> -----Original Message-----
>>>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>>>> Sent: Tuesday, July 04, 2006 11:06 AM
>>>> To: axis-user@ws.apache.org
>>>> Subject: Re: Adding own handler in Java Code?
>>>>
>>>> Hi Jansen,
>>>>
>>>> Ideally you should be able to create a custom chain and 
>> deploy it in 
>>>> your client-config.wsdd as an actual chain. Unfortunately, 
>> Axis WSDD 
>>>> syntax does not allow to deploy custom chains. When you 
>> put a <chain> 
>>>> tag, it always creates a SimpleChain instance.
>>>>
>>>> I would create a JIRA report to ask for the ability to specify a 
>>>> different class name for the Chain implementation. Something 
>>>> similar to 
>>>> the type attribute for handlers.
>>>>
>>>> In the meantime, you could try to write your own custom chain 
>>>> and deploy 
>>>> it as any other regular handler. Your chain would allow you 
>>>> to configure 
>>>> the list of handlers to be included, *before* performing the call, 
>>>> through the MessageContext, or any other appropriate 
>> channel. If I am 
>>>> not wrong, setting a property on the service client stub makes it 
>>>> available from the MessageContext during handlers invocation.
>>>>
>>>> Configuring the handlers within your custom chain should 
>> be straight 
>>>> forward once the WSDD syntax is extended. With the current 
>> syntax you 
>>>> have two options:
>>>>
>>>> 1. Use a secondary WSDD file with the contained handler 
>>>> configurations 
>>>> and parse it from your chain init() method.
>>>>
>>>> 2. Define all your handlers in your wsdd configuration file 
>>>> with unique 
>>>> names, set a property for your chain containing a list of 
>>>> handler names, 
>>>> and obtain the handler instances from the init() method.
>>>>
>>>> Instead of adding/removing handlers, it is easier to 
>> enable/disable 
>>>> them. This way, you can initialise all the handlers once, 
>> and specify 
>>>> its ordering at configuration time. At runtime you will 
>> just have to 
>>>> supply a list(or set) of the handlers that must be enabled 
>> for a call.
>>>> I attach a simple template class that may be of help. It 
>>>> implements the 
>>>> second option mentioned above.
>>>>
>>>> Regards,
>>>> Rodrigo Ruiz
>>>>
>>>> Jansen Werner wrote:
>>>>> Thanks for you reply! 
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>>>>>> Sent: Monday, July 03, 2006 3:57 PM
>>>>>> To: axis-user@ws.apache.org
>>>>>> Subject: Re: Adding own handler in Java Code?
>>>>>>
>>>>>> Hi Jansen,
>>>>>>
>>>>>> The answer depends on what you mean be "add dynamically". :-)
>>>>>>
>>>>>> If you mean "add a jar at runtime and have it automatically 
>>>>>> recognized", 
>>>>>> the answer is that it is very hard. You will need Axis 2 
>>>> to have this 
>>>>>> feature built in, or implement yourself a dynamic 
>>>>>> class-loader like the 
>>>>>> one used by Axis 2, and a handler with the ability to detect 
>>>>>> the changes 
>>>>>> at runtime, and call these "dynamic" handlers when appropriate.
>>>>> No, I'm lucky, this is not what I meant :)
>>>>>
>>>>>
>>>>>> If you mean "selecting a subset among an already 
>> well-known set of 
>>>>>> available handlers", the answer is that it is easier :-)
>>>>>>
>>>>>> You will have to create a handler that could act as a 
>>>>>> "handler chain", 
>>>>>> and put into it the logic to take the decision about what 
>>>> handlers to 
>>>>>> actually call when invoked. Depending on what you need, 
>>>> this handler 
>>>>>> will have the information needed to find out the handlers to 
>>>>>> call (for 
>>>>>> example, by parsing a policy), or you may have to include the 
>>>>>> mechanisms 
>>>>>> to communicate with it from the service implementations or 
>>>>>> other points, 
>>>>>> and configure it at runtime.
>>>>> OK, this sounds like my problem.
>>>>>
>>>>> For an example, let's take the LogHandler packaged with 
>>>> axis. How can I
>>>>> add this (simple, easy) Handler to Axis at runtime? (And 
>>>> remove it later
>>>>> ...).
>>>>>
>>>>> I have found a way to access the HandlerRegistry
>>>>> (Service.getHandlerRegistry()). But - without deeper 
>>>> knowledge of the
>>>>> HandlerChains available - how do I add my Handler (or the 
>> LogHandler
>>>>> mentioned above)?
>>>>>
>>>>>> Just keep in mind that you need to respect the handlers 
>>>>>> interface, and 
>>>>>> call their methods in the appropriate order. That is, to 
>>>>>> initialise them 
>>>>>> before invoking them, and the like.
>>>>> This is something I will concentrate on when I managed to add the
>>>>> LogHandler provided by Axis :)
>>>>>
>>>>> Ah, before I forget it again, our Axis version is 1.3 :)
>>>>>
>>>>> Thanks in advance :)
>>>>>
>>>>> CU
>>>>> Werner
>>>>>
>>>>>
>>>>>
>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>>>
>>>>>
>>>>>
>>>> -- 
>>>> -------------------------------------------------------------------
>>>> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
>>>> Parc Bit - Son Espanyol
>>>> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
>>>> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
>>>> http://www.gridsystems.com
>>>> -------------------------------------------------------------------
>>>>
>>>
>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>>
>> -- 
>> -------------------------------------------------------------------
>> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
>> Parc Bit - Son Espanyol
>> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
>> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
>> http://www.gridsystems.com
>> -------------------------------------------------------------------
>>
>>
>> -- 
>> No virus found in this outgoing message.
>> Checked by AVG Free Edition.
>> Version: 7.1.394 / Virus Database: 268.9.8/381 - Release 
>> Date: 03/07/2006
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
Baleares - España              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 04/07/2006


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: Adding own handler in Java Code? [SOLVED]

Posted by Jansen Werner <We...@eon-is.com>.
Hi again :)

My handlers are working. But I gave up the initial idea. This is how it works:

- The handler is included in client-config.wsdd ("hardcoded")
- The handler checks for itself if it should do anything. So I can activate and deactivate handlers "on the fly". (or, better, activate and deactivate functionality provided by those handlers)

But there's still an open issue: BeanSerializers and Namespaces. But I will post that in another mail to this list, so the subject doesn't get confused.

Have a nice day! :)

CU
Werner 

> -----Original Message-----
> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> Sent: Tuesday, July 04, 2006 3:02 PM
> To: axis-user@ws.apache.org
> Subject: Re: Adding own handler in Java Code?
> 
> Ok, what I described you allows you to configure your chain in a 
> per-call basis. If you just need it per-execution, it becomes 
> simpler :-)
> 
> But... why do you want to do this programmatically? Is it for 
> usability 
> reasons?
> 
> If you want to select the set of handlers to use before starting your 
> application, you can implement a standalone tool that could allow you
> to "visually" edit your client-config.wsdd, and show a 
> simplified GUI to 
> select among the available handlers. I would like a copy of 
> such a tool :-D
> 
> If you know which handlers you will need before starting to use Axis, 
> you can generate your client-config.wsdd from within your 
> application, 
> and use the generated WSDD as the configuration for your Axis engine.
> 
> If you want to go through the Axis API and modify the 
> configuration once 
> all has started, the quick answer is "you can't". Axis is not 
> prepared 
> to let you add and remove handlers as you like. There are several 
> conditions that will change what you need to call/do in order to make 
> things work.
> 
> First, you cannot remove handlers from chains. They have no 
> methods for 
> this.
> 
> Second, handlers (and chains) can optionally be deployed as 
> singletons. 
> When in singleton mode, changes to the WSDD deployment 
> descriptor will 
> not affect an existing instance, and you will have to directly modify 
> the instance itself. When not in this mode, Axis will create a new 
> instance each time the "get" method is called, and so, any change you 
> make to an instance will not have effect on the actual flow.
> 
> Third, you can only add handlers to the end of a chain, but usually 
> handlers must be deployed in different order depending on 
> which flow you 
> are adding them to. The response flow uses a reversed order 
> with respect 
> to the request one. This means that you must add all 
> necessary handlers 
> at once. Adding them incrementally will not work.
> 
> And fourth, the things you need to do require using several internal 
> classes that are not considered part of the Axis stable API. 
> This means 
> that you may have severe problems whenever you want to 
> upgrade the Axis 
> version.
> 
> Although it may seem too complex, I still think that the approach I 
> proposed you before is the best one. You can make 
> DynamicChain get the 
> list of active handlers from a Singleton class of your own, 
> and use that 
> class to specify which handlers you add or remove. This way your 
> application code is kept simple.
> 
> 
> Hope this helps,
> Rodrigo Ruiz
> 
> 
> Jansen Werner wrote:
> > Hi Rodrigo,
> > 
> > is it really that complicated to include a handler? Within 
> server-config.wsdd, it's just a single line to include the 
> (example) LogHandler, why is it so complicated to inject it via API? 
> > 
> > As a resumee, this is what I want to do:
> > 
> > - add a Handler to Message Processing. Nothing complicated. 
> Complexity similar to the org.apache.axis.handlers.LogHandler 
> provided by Axis.
> > - do this in client and server
> > - within the server, this is easy using <handler>-Tags in 
> server-config.wsdd, because the handler is needed always. 
> This works already.
> > - within the client, client-config.wsdd is inappropriate, 
> because the handler isn't used on every run of the client.
> > - How is it possible to inject a (simple) Handler via Java 
> Calls the way it would be in client-config.wsdd or 
> server-config.wsdd. As an example, I'm still trying to use 
> the LogHandler provided by Axis (which extends 
> org.apache.axis.handlers.BaseHandler, which itself implements 
> org.apache.axis.Handler (which does only extend Serializable, 
> and no javax.rpc-Interface).
> >  
> > I thought this must be a very simple thing to do. What you 
> wrote sounds profound but is very complicated for a (in my 
> eyes) simple thing: adding a Handler to message Processing.
> > 
> > ... hoping for an answer ... :)
> > 
> > CU
> > Werner
> > 
> >> -----Original Message-----
> >> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> >> Sent: Tuesday, July 04, 2006 11:06 AM
> >> To: axis-user@ws.apache.org
> >> Subject: Re: Adding own handler in Java Code?
> >>
> >> Hi Jansen,
> >>
> >> Ideally you should be able to create a custom chain and 
> deploy it in 
> >> your client-config.wsdd as an actual chain. Unfortunately, 
> Axis WSDD 
> >> syntax does not allow to deploy custom chains. When you 
> put a <chain> 
> >> tag, it always creates a SimpleChain instance.
> >>
> >> I would create a JIRA report to ask for the ability to specify a 
> >> different class name for the Chain implementation. Something 
> >> similar to 
> >> the type attribute for handlers.
> >>
> >> In the meantime, you could try to write your own custom chain 
> >> and deploy 
> >> it as any other regular handler. Your chain would allow you 
> >> to configure 
> >> the list of handlers to be included, *before* performing the call, 
> >> through the MessageContext, or any other appropriate 
> channel. If I am 
> >> not wrong, setting a property on the service client stub makes it 
> >> available from the MessageContext during handlers invocation.
> >>
> >> Configuring the handlers within your custom chain should 
> be straight 
> >> forward once the WSDD syntax is extended. With the current 
> syntax you 
> >> have two options:
> >>
> >> 1. Use a secondary WSDD file with the contained handler 
> >> configurations 
> >> and parse it from your chain init() method.
> >>
> >> 2. Define all your handlers in your wsdd configuration file 
> >> with unique 
> >> names, set a property for your chain containing a list of 
> >> handler names, 
> >> and obtain the handler instances from the init() method.
> >>
> >> Instead of adding/removing handlers, it is easier to 
> enable/disable 
> >> them. This way, you can initialise all the handlers once, 
> and specify 
> >> its ordering at configuration time. At runtime you will 
> just have to 
> >> supply a list(or set) of the handlers that must be enabled 
> for a call.
> >>
> >> I attach a simple template class that may be of help. It 
> >> implements the 
> >> second option mentioned above.
> >>
> >> Regards,
> >> Rodrigo Ruiz
> >>
> >> Jansen Werner wrote:
> >>> Thanks for you reply! 
> >>>
> >>>> -----Original Message-----
> >>>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> >>>> Sent: Monday, July 03, 2006 3:57 PM
> >>>> To: axis-user@ws.apache.org
> >>>> Subject: Re: Adding own handler in Java Code?
> >>>>
> >>>> Hi Jansen,
> >>>>
> >>>> The answer depends on what you mean be "add dynamically". :-)
> >>>>
> >>>> If you mean "add a jar at runtime and have it automatically 
> >>>> recognized", 
> >>>> the answer is that it is very hard. You will need Axis 2 
> >> to have this 
> >>>> feature built in, or implement yourself a dynamic 
> >>>> class-loader like the 
> >>>> one used by Axis 2, and a handler with the ability to detect 
> >>>> the changes 
> >>>> at runtime, and call these "dynamic" handlers when appropriate.
> >>> No, I'm lucky, this is not what I meant :)
> >>>
> >>>
> >>>> If you mean "selecting a subset among an already 
> well-known set of 
> >>>> available handlers", the answer is that it is easier :-)
> >>>>
> >>>> You will have to create a handler that could act as a 
> >>>> "handler chain", 
> >>>> and put into it the logic to take the decision about what 
> >> handlers to 
> >>>> actually call when invoked. Depending on what you need, 
> >> this handler 
> >>>> will have the information needed to find out the handlers to 
> >>>> call (for 
> >>>> example, by parsing a policy), or you may have to include the 
> >>>> mechanisms 
> >>>> to communicate with it from the service implementations or 
> >>>> other points, 
> >>>> and configure it at runtime.
> >>> OK, this sounds like my problem.
> >>>
> >>> For an example, let's take the LogHandler packaged with 
> >> axis. How can I
> >>> add this (simple, easy) Handler to Axis at runtime? (And 
> >> remove it later
> >>> ...).
> >>>
> >>> I have found a way to access the HandlerRegistry
> >>> (Service.getHandlerRegistry()). But - without deeper 
> >> knowledge of the
> >>> HandlerChains available - how do I add my Handler (or the 
> LogHandler
> >>> mentioned above)?
> >>>
> >>>> Just keep in mind that you need to respect the handlers 
> >>>> interface, and 
> >>>> call their methods in the appropriate order. That is, to 
> >>>> initialise them 
> >>>> before invoking them, and the like.
> >>> This is something I will concentrate on when I managed to add the
> >>> LogHandler provided by Axis :)
> >>>
> >>> Ah, before I forget it again, our Axis version is 1.3 :)
> >>>
> >>> Thanks in advance :)
> >>>
> >>> CU
> >>> Werner
> >>>
> >>>
> >>>
> >> 
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >>> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>>
> >>>
> >>>
> >> -- 
> >> -------------------------------------------------------------------
> >> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
> >> Parc Bit - Son Espanyol
> >> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
> >> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
> >> http://www.gridsystems.com
> >> -------------------------------------------------------------------
> >>
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> > 
> > 
> > 
> 
> -- 
> -------------------------------------------------------------------
> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
> Parc Bit - Son Espanyol
> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
> http://www.gridsystems.com
> -------------------------------------------------------------------
> 
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.9.8/381 - Release 
> Date: 03/07/2006
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code?

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Ok, what I described you allows you to configure your chain in a 
per-call basis. If you just need it per-execution, it becomes simpler :-)

But... why do you want to do this programmatically? Is it for usability 
reasons?

If you want to select the set of handlers to use before starting your 
application, you can implement a standalone tool that could allow you
to "visually" edit your client-config.wsdd, and show a simplified GUI to 
select among the available handlers. I would like a copy of such a tool :-D

If you know which handlers you will need before starting to use Axis, 
you can generate your client-config.wsdd from within your application, 
and use the generated WSDD as the configuration for your Axis engine.

If you want to go through the Axis API and modify the configuration once 
all has started, the quick answer is "you can't". Axis is not prepared 
to let you add and remove handlers as you like. There are several 
conditions that will change what you need to call/do in order to make 
things work.

First, you cannot remove handlers from chains. They have no methods for 
this.

Second, handlers (and chains) can optionally be deployed as singletons. 
When in singleton mode, changes to the WSDD deployment descriptor will 
not affect an existing instance, and you will have to directly modify 
the instance itself. When not in this mode, Axis will create a new 
instance each time the "get" method is called, and so, any change you 
make to an instance will not have effect on the actual flow.

Third, you can only add handlers to the end of a chain, but usually 
handlers must be deployed in different order depending on which flow you 
are adding them to. The response flow uses a reversed order with respect 
to the request one. This means that you must add all necessary handlers 
at once. Adding them incrementally will not work.

And fourth, the things you need to do require using several internal 
classes that are not considered part of the Axis stable API. This means 
that you may have severe problems whenever you want to upgrade the Axis 
version.

Although it may seem too complex, I still think that the approach I 
proposed you before is the best one. You can make DynamicChain get the 
list of active handlers from a Singleton class of your own, and use that 
class to specify which handlers you add or remove. This way your 
application code is kept simple.


Hope this helps,
Rodrigo Ruiz


Jansen Werner wrote:
> Hi Rodrigo,
> 
> is it really that complicated to include a handler? Within server-config.wsdd, it's just a single line to include the (example) LogHandler, why is it so complicated to inject it via API? 
> 
> As a resumee, this is what I want to do:
> 
> - add a Handler to Message Processing. Nothing complicated. Complexity similar to the org.apache.axis.handlers.LogHandler provided by Axis.
> - do this in client and server
> - within the server, this is easy using <handler>-Tags in server-config.wsdd, because the handler is needed always. This works already.
> - within the client, client-config.wsdd is inappropriate, because the handler isn't used on every run of the client.
> - How is it possible to inject a (simple) Handler via Java Calls the way it would be in client-config.wsdd or server-config.wsdd. As an example, I'm still trying to use the LogHandler provided by Axis (which extends org.apache.axis.handlers.BaseHandler, which itself implements org.apache.axis.Handler (which does only extend Serializable, and no javax.rpc-Interface).
>  
> I thought this must be a very simple thing to do. What you wrote sounds profound but is very complicated for a (in my eyes) simple thing: adding a Handler to message Processing.
> 
> ... hoping for an answer ... :)
> 
> CU
> Werner
> 
>> -----Original Message-----
>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>> Sent: Tuesday, July 04, 2006 11:06 AM
>> To: axis-user@ws.apache.org
>> Subject: Re: Adding own handler in Java Code?
>>
>> Hi Jansen,
>>
>> Ideally you should be able to create a custom chain and deploy it in 
>> your client-config.wsdd as an actual chain. Unfortunately, Axis WSDD 
>> syntax does not allow to deploy custom chains. When you put a <chain> 
>> tag, it always creates a SimpleChain instance.
>>
>> I would create a JIRA report to ask for the ability to specify a 
>> different class name for the Chain implementation. Something 
>> similar to 
>> the type attribute for handlers.
>>
>> In the meantime, you could try to write your own custom chain 
>> and deploy 
>> it as any other regular handler. Your chain would allow you 
>> to configure 
>> the list of handlers to be included, *before* performing the call, 
>> through the MessageContext, or any other appropriate channel. If I am 
>> not wrong, setting a property on the service client stub makes it 
>> available from the MessageContext during handlers invocation.
>>
>> Configuring the handlers within your custom chain should be straight 
>> forward once the WSDD syntax is extended. With the current syntax you 
>> have two options:
>>
>> 1. Use a secondary WSDD file with the contained handler 
>> configurations 
>> and parse it from your chain init() method.
>>
>> 2. Define all your handlers in your wsdd configuration file 
>> with unique 
>> names, set a property for your chain containing a list of 
>> handler names, 
>> and obtain the handler instances from the init() method.
>>
>> Instead of adding/removing handlers, it is easier to enable/disable 
>> them. This way, you can initialise all the handlers once, and specify 
>> its ordering at configuration time. At runtime you will just have to 
>> supply a list(or set) of the handlers that must be enabled for a call.
>>
>> I attach a simple template class that may be of help. It 
>> implements the 
>> second option mentioned above.
>>
>> Regards,
>> Rodrigo Ruiz
>>
>> Jansen Werner wrote:
>>> Thanks for you reply! 
>>>
>>>> -----Original Message-----
>>>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>>>> Sent: Monday, July 03, 2006 3:57 PM
>>>> To: axis-user@ws.apache.org
>>>> Subject: Re: Adding own handler in Java Code?
>>>>
>>>> Hi Jansen,
>>>>
>>>> The answer depends on what you mean be "add dynamically". :-)
>>>>
>>>> If you mean "add a jar at runtime and have it automatically 
>>>> recognized", 
>>>> the answer is that it is very hard. You will need Axis 2 
>> to have this 
>>>> feature built in, or implement yourself a dynamic 
>>>> class-loader like the 
>>>> one used by Axis 2, and a handler with the ability to detect 
>>>> the changes 
>>>> at runtime, and call these "dynamic" handlers when appropriate.
>>> No, I'm lucky, this is not what I meant :)
>>>
>>>
>>>> If you mean "selecting a subset among an already well-known set of 
>>>> available handlers", the answer is that it is easier :-)
>>>>
>>>> You will have to create a handler that could act as a 
>>>> "handler chain", 
>>>> and put into it the logic to take the decision about what 
>> handlers to 
>>>> actually call when invoked. Depending on what you need, 
>> this handler 
>>>> will have the information needed to find out the handlers to 
>>>> call (for 
>>>> example, by parsing a policy), or you may have to include the 
>>>> mechanisms 
>>>> to communicate with it from the service implementations or 
>>>> other points, 
>>>> and configure it at runtime.
>>> OK, this sounds like my problem.
>>>
>>> For an example, let's take the LogHandler packaged with 
>> axis. How can I
>>> add this (simple, easy) Handler to Axis at runtime? (And 
>> remove it later
>>> ...).
>>>
>>> I have found a way to access the HandlerRegistry
>>> (Service.getHandlerRegistry()). But - without deeper 
>> knowledge of the
>>> HandlerChains available - how do I add my Handler (or the LogHandler
>>> mentioned above)?
>>>
>>>> Just keep in mind that you need to respect the handlers 
>>>> interface, and 
>>>> call their methods in the appropriate order. That is, to 
>>>> initialise them 
>>>> before invoking them, and the like.
>>> This is something I will concentrate on when I managed to add the
>>> LogHandler provided by Axis :)
>>>
>>> Ah, before I forget it again, our Axis version is 1.3 :)
>>>
>>> Thanks in advance :)
>>>
>>> CU
>>> Werner
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>>
>> -- 
>> -------------------------------------------------------------------
>> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
>> Parc Bit - Son Espanyol
>> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
>> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
>> http://www.gridsystems.com
>> -------------------------------------------------------------------
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
Baleares - España              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.8/381 - Release Date: 03/07/2006


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: Adding own handler in Java Code?

Posted by Jansen Werner <We...@eon-is.com>.
Hi Rodrigo,

is it really that complicated to include a handler? Within server-config.wsdd, it's just a single line to include the (example) LogHandler, why is it so complicated to inject it via API? 

As a resumee, this is what I want to do:

- add a Handler to Message Processing. Nothing complicated. Complexity similar to the org.apache.axis.handlers.LogHandler provided by Axis.
- do this in client and server
- within the server, this is easy using <handler>-Tags in server-config.wsdd, because the handler is needed always. This works already.
- within the client, client-config.wsdd is inappropriate, because the handler isn't used on every run of the client.
- How is it possible to inject a (simple) Handler via Java Calls the way it would be in client-config.wsdd or server-config.wsdd. As an example, I'm still trying to use the LogHandler provided by Axis (which extends org.apache.axis.handlers.BaseHandler, which itself implements org.apache.axis.Handler (which does only extend Serializable, and no javax.rpc-Interface).
 
I thought this must be a very simple thing to do. What you wrote sounds profound but is very complicated for a (in my eyes) simple thing: adding a Handler to message Processing.

... hoping for an answer ... :)

CU
Werner

> -----Original Message-----
> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> Sent: Tuesday, July 04, 2006 11:06 AM
> To: axis-user@ws.apache.org
> Subject: Re: Adding own handler in Java Code?
> 
> Hi Jansen,
> 
> Ideally you should be able to create a custom chain and deploy it in 
> your client-config.wsdd as an actual chain. Unfortunately, Axis WSDD 
> syntax does not allow to deploy custom chains. When you put a <chain> 
> tag, it always creates a SimpleChain instance.
> 
> I would create a JIRA report to ask for the ability to specify a 
> different class name for the Chain implementation. Something 
> similar to 
> the type attribute for handlers.
> 
> In the meantime, you could try to write your own custom chain 
> and deploy 
> it as any other regular handler. Your chain would allow you 
> to configure 
> the list of handlers to be included, *before* performing the call, 
> through the MessageContext, or any other appropriate channel. If I am 
> not wrong, setting a property on the service client stub makes it 
> available from the MessageContext during handlers invocation.
> 
> Configuring the handlers within your custom chain should be straight 
> forward once the WSDD syntax is extended. With the current syntax you 
> have two options:
> 
> 1. Use a secondary WSDD file with the contained handler 
> configurations 
> and parse it from your chain init() method.
> 
> 2. Define all your handlers in your wsdd configuration file 
> with unique 
> names, set a property for your chain containing a list of 
> handler names, 
> and obtain the handler instances from the init() method.
> 
> Instead of adding/removing handlers, it is easier to enable/disable 
> them. This way, you can initialise all the handlers once, and specify 
> its ordering at configuration time. At runtime you will just have to 
> supply a list(or set) of the handlers that must be enabled for a call.
> 
> I attach a simple template class that may be of help. It 
> implements the 
> second option mentioned above.
> 
> Regards,
> Rodrigo Ruiz
> 
> Jansen Werner wrote:
> > Thanks for you reply! 
> > 
> >> -----Original Message-----
> >> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> >> Sent: Monday, July 03, 2006 3:57 PM
> >> To: axis-user@ws.apache.org
> >> Subject: Re: Adding own handler in Java Code?
> >>
> >> Hi Jansen,
> >>
> >> The answer depends on what you mean be "add dynamically". :-)
> >>
> >> If you mean "add a jar at runtime and have it automatically 
> >> recognized", 
> >> the answer is that it is very hard. You will need Axis 2 
> to have this 
> >> feature built in, or implement yourself a dynamic 
> >> class-loader like the 
> >> one used by Axis 2, and a handler with the ability to detect 
> >> the changes 
> >> at runtime, and call these "dynamic" handlers when appropriate.
> > 
> > No, I'm lucky, this is not what I meant :)
> > 
> > 
> >> If you mean "selecting a subset among an already well-known set of 
> >> available handlers", the answer is that it is easier :-)
> >>
> >> You will have to create a handler that could act as a 
> >> "handler chain", 
> >> and put into it the logic to take the decision about what 
> handlers to 
> >> actually call when invoked. Depending on what you need, 
> this handler 
> >> will have the information needed to find out the handlers to 
> >> call (for 
> >> example, by parsing a policy), or you may have to include the 
> >> mechanisms 
> >> to communicate with it from the service implementations or 
> >> other points, 
> >> and configure it at runtime.
> > 
> > OK, this sounds like my problem.
> > 
> > For an example, let's take the LogHandler packaged with 
> axis. How can I
> > add this (simple, easy) Handler to Axis at runtime? (And 
> remove it later
> > ...).
> > 
> > I have found a way to access the HandlerRegistry
> > (Service.getHandlerRegistry()). But - without deeper 
> knowledge of the
> > HandlerChains available - how do I add my Handler (or the LogHandler
> > mentioned above)?
> > 
> >> Just keep in mind that you need to respect the handlers 
> >> interface, and 
> >> call their methods in the appropriate order. That is, to 
> >> initialise them 
> >> before invoking them, and the like.
> > 
> > This is something I will concentrate on when I managed to add the
> > LogHandler provided by Axis :)
> > 
> > Ah, before I forget it again, our Axis version is 1.3 :)
> > 
> > Thanks in advance :)
> > 
> > CU
> > Werner
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> > 
> > 
> > 
> 
> -- 
> -------------------------------------------------------------------
> GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
> Parc Bit - Son Espanyol
> 07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
> Baleares - España              Tel:+34-971435085 Fax:+34-971435082
> http://www.gridsystems.com
> -------------------------------------------------------------------
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code?

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Hi Jansen,

Ideally you should be able to create a custom chain and deploy it in 
your client-config.wsdd as an actual chain. Unfortunately, Axis WSDD 
syntax does not allow to deploy custom chains. When you put a <chain> 
tag, it always creates a SimpleChain instance.

I would create a JIRA report to ask for the ability to specify a 
different class name for the Chain implementation. Something similar to 
the type attribute for handlers.

In the meantime, you could try to write your own custom chain and deploy 
it as any other regular handler. Your chain would allow you to configure 
the list of handlers to be included, *before* performing the call, 
through the MessageContext, or any other appropriate channel. If I am 
not wrong, setting a property on the service client stub makes it 
available from the MessageContext during handlers invocation.

Configuring the handlers within your custom chain should be straight 
forward once the WSDD syntax is extended. With the current syntax you 
have two options:

1. Use a secondary WSDD file with the contained handler configurations 
and parse it from your chain init() method.

2. Define all your handlers in your wsdd configuration file with unique 
names, set a property for your chain containing a list of handler names, 
and obtain the handler instances from the init() method.

Instead of adding/removing handlers, it is easier to enable/disable 
them. This way, you can initialise all the handlers once, and specify 
its ordering at configuration time. At runtime you will just have to 
supply a list(or set) of the handlers that must be enabled for a call.

I attach a simple template class that may be of help. It implements the 
second option mentioned above.

Regards,
Rodrigo Ruiz

Jansen Werner wrote:
> Thanks for you reply! 
> 
>> -----Original Message-----
>> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
>> Sent: Monday, July 03, 2006 3:57 PM
>> To: axis-user@ws.apache.org
>> Subject: Re: Adding own handler in Java Code?
>>
>> Hi Jansen,
>>
>> The answer depends on what you mean be "add dynamically". :-)
>>
>> If you mean "add a jar at runtime and have it automatically 
>> recognized", 
>> the answer is that it is very hard. You will need Axis 2 to have this 
>> feature built in, or implement yourself a dynamic 
>> class-loader like the 
>> one used by Axis 2, and a handler with the ability to detect 
>> the changes 
>> at runtime, and call these "dynamic" handlers when appropriate.
> 
> No, I'm lucky, this is not what I meant :)
> 
> 
>> If you mean "selecting a subset among an already well-known set of 
>> available handlers", the answer is that it is easier :-)
>>
>> You will have to create a handler that could act as a 
>> "handler chain", 
>> and put into it the logic to take the decision about what handlers to 
>> actually call when invoked. Depending on what you need, this handler 
>> will have the information needed to find out the handlers to 
>> call (for 
>> example, by parsing a policy), or you may have to include the 
>> mechanisms 
>> to communicate with it from the service implementations or 
>> other points, 
>> and configure it at runtime.
> 
> OK, this sounds like my problem.
> 
> For an example, let's take the LogHandler packaged with axis. How can I
> add this (simple, easy) Handler to Axis at runtime? (And remove it later
> ...).
> 
> I have found a way to access the HandlerRegistry
> (Service.getHandlerRegistry()). But - without deeper knowledge of the
> HandlerChains available - how do I add my Handler (or the LogHandler
> mentioned above)?
> 
>> Just keep in mind that you need to respect the handlers 
>> interface, and 
>> call their methods in the appropriate order. That is, to 
>> initialise them 
>> before invoking them, and the like.
> 
> This is something I will concentrate on when I managed to add the
> LogHandler provided by Axis :)
> 
> Ah, before I forget it again, our Axis version is 1.3 :)
> 
> Thanks in advance :)
> 
> CU
> Werner
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
Baleares - España              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------

RE: Adding own handler in Java Code?

Posted by Jansen Werner <We...@eon-is.com>.
Thanks for you reply! 

> -----Original Message-----
> From: Rodrigo Ruiz [mailto:rruiz@gridsystems.com] 
> Sent: Monday, July 03, 2006 3:57 PM
> To: axis-user@ws.apache.org
> Subject: Re: Adding own handler in Java Code?
> 
> Hi Jansen,
> 
> The answer depends on what you mean be "add dynamically". :-)
> 
> If you mean "add a jar at runtime and have it automatically 
> recognized", 
> the answer is that it is very hard. You will need Axis 2 to have this 
> feature built in, or implement yourself a dynamic 
> class-loader like the 
> one used by Axis 2, and a handler with the ability to detect 
> the changes 
> at runtime, and call these "dynamic" handlers when appropriate.

No, I'm lucky, this is not what I meant :)


> If you mean "selecting a subset among an already well-known set of 
> available handlers", the answer is that it is easier :-)
> 
> You will have to create a handler that could act as a 
> "handler chain", 
> and put into it the logic to take the decision about what handlers to 
> actually call when invoked. Depending on what you need, this handler 
> will have the information needed to find out the handlers to 
> call (for 
> example, by parsing a policy), or you may have to include the 
> mechanisms 
> to communicate with it from the service implementations or 
> other points, 
> and configure it at runtime.

OK, this sounds like my problem.

For an example, let's take the LogHandler packaged with axis. How can I
add this (simple, easy) Handler to Axis at runtime? (And remove it later
...).

I have found a way to access the HandlerRegistry
(Service.getHandlerRegistry()). But - without deeper knowledge of the
HandlerChains available - how do I add my Handler (or the LogHandler
mentioned above)?

> 
> Just keep in mind that you need to respect the handlers 
> interface, and 
> call their methods in the appropriate order. That is, to 
> initialise them 
> before invoking them, and the like.

This is something I will concentrate on when I managed to add the
LogHandler provided by Axis :)

Ah, before I forget it again, our Axis version is 1.3 :)

Thanks in advance :)

CU
Werner


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code?

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Hi Jansen,

The answer depends on what you mean be "add dynamically". :-)

If you mean "add a jar at runtime and have it automatically recognized", 
the answer is that it is very hard. You will need Axis 2 to have this 
feature built in, or implement yourself a dynamic class-loader like the 
one used by Axis 2, and a handler with the ability to detect the changes 
at runtime, and call these "dynamic" handlers when appropriate.

If you mean "selecting a subset among an already well-known set of 
available handlers", the answer is that it is easier :-)

You will have to create a handler that could act as a "handler chain", 
and put into it the logic to take the decision about what handlers to 
actually call when invoked. Depending on what you need, this handler 
will have the information needed to find out the handlers to call (for 
example, by parsing a policy), or you may have to include the mechanisms 
to communicate with it from the service implementations or other points, 
and configure it at runtime.

Just keep in mind that you need to respect the handlers interface, and 
call their methods in the appropriate order. That is, to initialise them 
before invoking them, and the like.

Regards,
Rodrigo Ruiz

Jansen Werner wrote:
> Ah, always the same thing I forget to mention: We're _not_ using Axis2.
> :) 
> 
>> -----Original Message-----
>> From: Michele Mazzucco [mailto:Michele.Mazzucco@ncl.ac.uk] 
>> Sent: Monday, July 03, 2006 2:52 PM
>> To: axis-user@ws.apache.org
>> Subject: Re: Adding own handler in Java Code?
>>
>> Maybe ServiceClient.engageModule() is what you are looking for (if
>> you're using Axis2).
>>
>> Michele
>>
>> Jansen Werner wrote:
>>> Hallo everybody,
>>>
>>> I need to add handlers to Axis dynamically in Java Code. I found
>>> examples of adding handlers (logHandlers, for example) to
>>> server-config.wsdd. But I need to add them dynamically and 
>> on the client
>>> side of the SOAP call.
>>>
>>> Could anyone give me a hint? 
>>>
>>> Thanks in advance, 
>>>
>>> Werner Jansen
>>>
>>>
-- 
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:rruiz@gridsystems.com
Baleares - España              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 30/06/2006


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: Adding own handler in Java Code?

Posted by Jansen Werner <We...@eon-is.com>.
Ah, always the same thing I forget to mention: We're _not_ using Axis2.
:) 

> -----Original Message-----
> From: Michele Mazzucco [mailto:Michele.Mazzucco@ncl.ac.uk] 
> Sent: Monday, July 03, 2006 2:52 PM
> To: axis-user@ws.apache.org
> Subject: Re: Adding own handler in Java Code?
> 
> Maybe ServiceClient.engageModule() is what you are looking for (if
> you're using Axis2).
> 
> Michele
> 
> Jansen Werner wrote:
> > Hallo everybody,
> > 
> > I need to add handlers to Axis dynamically in Java Code. I found
> > examples of adding handlers (logHandlers, for example) to
> > server-config.wsdd. But I need to add them dynamically and 
> on the client
> > side of the SOAP call.
> > 
> > Could anyone give me a hint? 
> > 
> > Thanks in advance, 
> > 
> > Werner Jansen
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Adding own handler in Java Code?

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
Maybe ServiceClient.engageModule() is what you are looking for (if
you're using Axis2).

Michele

Jansen Werner wrote:
> Hallo everybody,
> 
> I need to add handlers to Axis dynamically in Java Code. I found
> examples of adding handlers (logHandlers, for example) to
> server-config.wsdd. But I need to add them dynamically and on the client
> side of the SOAP call.
> 
> Could anyone give me a hint? 
> 
> Thanks in advance, 
> 
> Werner Jansen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org