Thanks Vidyanand,
It works fine now. I was actually trying to implement this way, but I was
stuck. You helped me a lot. I really appreciate.
Again, thanks,
--Bahman
----- Original Message -----
From: "Vidyanand Murunikkara" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 06, 2002 3:20 PM
Subject: RE: How to get an operation Name in a Requstor Handler
Try this out Bahman
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.MessageContext;
import org.apache.axis.Message;
import org.apache.axis.AxisFault;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.Handler;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.Name;
import java.util.Iterator;
import java.util.ArrayList;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
public class MyHandler extends BasicHandler {
public void invoke( MessageContext msgContext ) throws AxisFault {
try {
Message m = msgContext.getRequestMessage();
SOAPEnvelope env = m.getSOAPEnvelope();
SOAPBody body = env.getBody();
Iterator iter = body.getChildElements();
if( iter.hasNext()) {
SOAPElement el = (SOAPElement) iter.next();
Name opQName = el.getElementName();
String opName = opQName.getLocalName();
ServiceDesc service =
msgContext.getService().getServiceDescription();
OperationDesc opDesc = getOperationDesc(service, opName
);
System.out.println( "\n Operation Desc \n" + opDesc );
}
}catch( Exception e){
throw new AxisFault(e.getMessage(), e);
}
}
private OperationDesc getOperationDesc(ServiceDesc service , String
opName ){
//ServiceDesc service =
msgContext.getService().getServiceDescription();
if( service != null ) {
ArrayList operations = service.getOperations();
for( int i = 0; i < operations.size(); i++ ) {
OperationDesc op = (OperationDesc)operations.get(i);
if( op.getName().equals( opName))
return op;
}
}
return null;
}
}
Vidyanand.
-----Original Message-----
From: Bahman Kalali [mailto:bkalali@;csg.uwaterloo.ca]
Sent: Wednesday, November 06, 2002 11:47 AM
To: [EMAIL PROTECTED]
Subject: How to get an operation Name in a Requstor Handler
----- Original Message -----
From: Bahman <mailto:bkalali@;csg.uwaterloo.ca> Kalali
To: [EMAIL PROTECTED] <mailto:axis-user@;xml.apache.org>
Sent: Wednesday, November 06, 2002 2:23 PM
Subject: Re: How to get an operation Name in a Requstor Handler
Thanks Bobby,
I had even tried that one, but I got the same error
message(java.lang.NullPointerException)
I just read an APIdocs of OperationDesc, I guess there is something
wrong with OperationDesc.
http://www.cs.unc.edu/Courses/comp190/docs/documentation/axis/apiDocs/or
g/apache/axis/description/OperationDesc.html
<http://www.cs.unc.edu/Courses/comp190/docs/documentation/axis/apiDocs/o
rg/apache/axis/description/OperationDesc.html>
I am using
xml-Axis-1.0 Release Oct 7, 2002
JDK1.3.1_04
Tomcat4.1
--Bahman
----- Original Message -----
From: Bobby Carp <mailto:bobby.carp@;blackpearl.com>
To: '[EMAIL PROTECTED]' <mailto:'[EMAIL PROTECTED]'>
Sent: Wednesday, November 06, 2002 1:43 PM
Subject: RE: How to get an operation Name in a Requstor Handler
OperationDesc oper = msgCxt.getOperation();
oper.getName();
-----Original Message-----
From: Bahman Kalali [mailto:bkalali@;csg.uwaterloo.ca]
Sent: Wednesday, November 06, 2002 9:58 AM
To: [EMAIL PROTECTED] <mailto:axis-user@;xml.apache.org>
Subject: How to get an operation Name in a Requstor Handler
I am trying to write a Service requestor Handler. Inside the Handler's
invoke method, I want to get the method name of service provider:
I can get an operation name from a MessageContext as follows.
public void invoke(MessageContext msgContext) throws AxisFault
{
Handler serviceHandler = msgContext.getService();
Message msg=msgContext.getRequestMessage();
SOAPEnvelope envelope=msg.getSOAPEnvelope();
Element envElement=envelope.getAsDOM();
Document doc= envelope.getAsDocument();
String operationName=mygetOperation(doc);
}
Is there any other way that I can get an operation name and its expected
passing parameters in my Handlers from a MessageContext?
I tried this, but it gives me NULL pointer exception error.
OperationDesc op =msgContext.getOperation();
Method t= op.getMethod();
System.out.println(t.getName())===>java.lang.NullPointerException
I really appreciate your input.
--Bahman