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 Dan O'Neill <do...@gmail.com> on 2005/03/21 13:25:56 UTC

Client-Side handlers and Service Specific Handler problems.

Hi,

I have a simple service and client with a number of handlers on either
end. But I want a different handler(on client side) for different
services. And This below doesn't seem to be working -

Client-config.wsdd:
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
            xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
 <globalConfiguration>
   <parameter name="disablePrettyXML" value="true"/>
 </globalConfiguration>
 <handler name="request" type="java:RequestHandler1"/>
 <service name="TestService1">
    <requestFlow>
      <handler type="request"/>
    </requestFlow>
    <responseFlow>
      <handler type="request"/>
    </responseFlow>
 </service>

 <transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
 <transport name="local"
pivot="java:org.apache.axis.transport.local.LocalSender"/>
 <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/>
</deployment>

But If I change it and put the handler in Global it works but thats a
problem because I need to log different information depending on the
service the client calls?

Any help would be much appreciated,

Dan

PS handler code here but I know it works....
RequestHandler1:
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;

public class RequestHandler1 extends BasicHandler{

	public void invoke(MessageContext msgContext) throws AxisFault{
		try{
		System.out.println("Hi, you've reached the requestHandler on the
client side... yay!");
		}catch (Exception e) {
        	throw AxisFault.makeFault(e);
		}
	}
	
}

Re: Client-Side handlers and Service Specific Handler problems.

Posted by Dan O'Neill <do...@gmail.com>.
Hi all, I found a workaround for the service specific handlers... Well
kind of..
This below I found in the mailing list explaining how to get the
method name out of the request so maybe this could be used to help the
handler decide what to do according to the method request. It might
not work in all situations - same method different services but It
might come in handy.....



Kevin Colussi wrote:
This is just a follow up on what I found....

The OperationDesc in the MessageContext will be null when:

1) The deployed interface/impl has over loaded methods.
2) When the client envelope is well formed (ie SAX parser is
       happy) but the method the client is trying to invoke
       doesn't exist.

So I did find a problem where the method was over loaded and
that fixed one of my problem.... However, I still had intermittent
problems w/ the MessageContext.getOperation() returning null for
some calls... So i figured out this and it seems to be working...

=========== snip =====================================
String operationName = "";
 try {
    Iterator i = messageContext.getCurrentMessage().
       getSOAPEnvelope().getBody().getChildElements();
    while (i.hasNext()) {
       try {
         RPCElement o= (RPCElement) i.next();
         operationName = o.getMethodName();
         break;
       } catch (ClassCastException e) {
        }
    }
    if (operationName.equals("")) {
       throw new
         Exception("Invalid request.  Only RPC is supported.");
    }
 } catch (NullPointerException ne) {
       throw new Exception(
       "Problem getting child elements: " + ne.toString());
 } catch (SOAPException e) {
       throw new CallerIdException(e.toString());
 }
 System.out.println("operationName = " + operationName);
=========== snip =====================================

Hope this helps someone else...  I would still like to see
how others are getting the calling method from the MessageContext
object...

Cheers,
-- Kevin

Kevin Colussi wrote:
> Hello,
>
> I have been running Axis 1.1 for a while... With a handler
> that calls messageContext.getOperation() to log the client
> method request... The service runs in a WAS 5.1 env on AIX...
>
> Out of the blue I start getting null pointers from the
> handler... I traces it down this line:
>
> public void invoke(MessageContext messageContext) throws AxisFault {
>     ............
>     String name = messageContext.getOperation().getName();
>     ............
> }
>
> So I started searching.... Sure enough the getOperation() returns
> null from an Axis test client and JMeter script... In the debugger
> I can see the AxisServer.class and the msgContext in this line:
>
> setCurrentMessageContext(msgContext);
>
> whose operation is null.... huh?  There are other services deployed
> in this same container that use the same handler just fine.....
>
> The Axis JavaDoc says it's ok for the messageContext.getOperation() to
> return null....  If that is the case how does the Axis servlet know
> which method to call in the service class implementation?  Should I be
> using something other than messageContext.getOperation() to get the
> method the client is calling?
>
> Thanks a ton for any advise....
> -- Kevin

Re: Client-Side handlers and Service Specific Handler problems.

Posted by Peter Smith <pe...@fast.fujitsu.com.au>.
Dan,

I had this exact same question some weeks ago (1-MAR-05) with my emails

Subj: "Handler configuration in client-config.wsdd"

and

Subj: "<handlerInfoChain> in client-config.wsdd?"

but alas.... no replies   :-(

Good luck.
Peter.



Dan O'Neill wrote:

>Hi,
>
>I have a simple service and client with a number of handlers on either
>end. But I want a different handler(on client side) for different
>services. And This below doesn't seem to be working -
>
>Client-config.wsdd:
><?xml version="1.0" encoding="UTF-8"?>
><deployment name="defaultClientConfig"
>            xmlns="http://xml.apache.org/axis/wsdd/"
>            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
> <globalConfiguration>
>   <parameter name="disablePrettyXML" value="true"/>
> </globalConfiguration>
> <handler name="request" type="java:RequestHandler1"/>
> <service name="TestService1">
>    <requestFlow>
>      <handler type="request"/>
>    </requestFlow>
>    <responseFlow>
>      <handler type="request"/>
>    </responseFlow>
> </service>
>
> <transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
> <transport name="local"
>pivot="java:org.apache.axis.transport.local.LocalSender"/>
> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/>
></deployment>
>
>But If I change it and put the handler in Global it works but thats a
>problem because I need to log different information depending on the
>service the client calls?
>
>Any help would be much appreciated,
>
>Dan
>
>PS handler code here but I know it works....
>RequestHandler1:
>import org.apache.axis.AxisFault;
>import org.apache.axis.MessageContext;
>import org.apache.axis.handlers.BasicHandler;
>
>public class RequestHandler1 extends BasicHandler{
>
>	public void invoke(MessageContext msgContext) throws AxisFault{
>		try{
>		System.out.println("Hi, you've reached the requestHandler on the
>client side... yay!");
>		}catch (Exception e) {
>        	throw AxisFault.makeFault(e);
>		}
>	}
>	
>}
>
>
>  
>

This is an email from Fujitsu Australia Software Technology Pty Ltd, ABN 27 003 693 481. It is confidential to the ordinary user of the email address to which it was addressed and may contain copyright and/or legally privileged information. No one else may read, print, store, copy or forward all or any of it or its attachments. If you receive this email in error, please return to sender. Thank you.

If you do not wish to receive commercial email messages from Fujitsu Australia Software Technology Pty Ltd, please email unsubscribe@fast.fujitsu.com.au