get QName of calling service in a customer Handler of Axis soap engine

i write a Handler extends BasicHandler.
And in invoke() method i wannt to get QName of calling service. How can i do this ?
Thanks much.
hoaivanAsked:
Who is Participating?
 
aozarovCommented:
Not sure what you mean by "QName of calling service" but Axis exposes all the available information
via the MessageContext passed by the invoke method (also can be accessed using the static getCurrentContext() method).
see: http://ws.apache.org/axis/java/apiDocs/org/apache/axis/MessageContext.html
Some information is retreived directly by the standard api calls and some is retreived by calling the msgContext.getProperty(....)
For more on getProperties options see XXXConstants  (XXX stands for the transport type e.g HttpConstants).
If you were looking for the Action URI then you can use either getSOAPActionURI()  or getProperty(HttpConstants.MC_HTTP_SOAPACTION) [ deprecated])
0
 
hoaivanAuthor Commented:
exactly, i put myHandler at clientside and i want to get the string represent the url of service being called.
i tried this but fail, it returns null or blank value all the time:
public void invoke(MessageContext mc) throws AxisFault {
            String tempS = null;
            tempS = (String)getOption(KrbWSConstants.DEPLOYMENT_PLACE);
            if (tempS == null){
                  tempS = (String)mc.getProperty(KrbWSConstants.DEPLOYMENT_PLACE);
                  if (tempS ==null){
                        log.error("Deployment place problem");
                        return;
                  }
            }
            try{      
                  if (tempS.equalsIgnoreCase(KrbWSConstants.DEPLOYMENT_CLIENT)){
                        clientInvoke(mc)                  ;
                  }
                  else if (tempS.equalsIgnoreCase(KrbWSConstants.DEPLOYMENT_SERVER)){
                        serverInvoke(mc);
                  }
                  else
                        log.error("Unknow deployment place of Handler: check your config file");
            }catch(Exception e){
                  log.error(e.getMessage());
            }
      }      
      private void clientInvoke(MessageContext mc) throws Exception {                  
            log.debug("Target Service: "+mc.getTargetService());
            log.debug("SOAPActionURL: "+mc.getSOAPActionURI());
            log.debug("Name: "+getName());
            log.debug(""+mc.getProperty(HTTPConstants.MC_HTTP_SOAPACTION));
            Iterator ite = m.getAllPropertyNames();
            while (ite.hasNext()){
                  String pName = (String )ite.next();
                  log.debug("Properties Name and Value =>"+pName+" = "+(String)m.getProperty(pName));
            }
            
            log.debug("client Request Handler invoke");

            //get list of actions from config file
            Vector actions = analyseAction();
            Iterator it = actions.iterator();
            if (it.hasNext()){
                  String action = (String)it.next();
                  
                  if (action.equalsIgnoreCase("sign")){
                        handleSign(mc);
                  }
                  else if (action.equalsIgnoreCase("encrypt")){
                        handleEncrypt(mc);
                  }
                  else
                        throw new Exception("Unknown Action: check config file for valid krbws_action");
            }
      }

and here is my log file:
0     DEBUG [main] AddClient.main(AddClient.java:27) - Main program running ...
0     DEBUG [main] AddClient.main(AddClient.java:27) - Main program running ...
1632  WARN  [main] org.apache.axis.utils.JavaUtils.isAttachmentSupported(JavaUtils.java:1212) - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
2744  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:91) - Target Service:
2744  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:91) - Target Service:
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:92) - SOAPActionURL:
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:92) - SOAPActionURL:
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:93) - Name: null
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:93) - Name: null
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:94) - Name: null
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:94) - Name: null
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:95) -
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:95) -
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:102) - client Request Handler invoke
2754  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityRequestHandler.clientInvoke(AxisKerberosSecurityRequestHandler.java:102) - client Request Handler invoke
3245  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityResponseHandler.clientInvoke(AxisKerberosSecurityResponseHandler.java:63) - client response handler invoke
3245  DEBUG [main] vn.edu.hut.krbws.axis.AxisKerberosSecurityResponseHandler.clientInvoke(AxisKerberosSecurityResponseHandler.java:63) - client response handler invoke


i still wonder that why in my log file, everything is duplicated, here is my log4j con fig file:
log4j.rootLogger=INFO, A2

log4j.logger.vn.edu.hut=DEBUG, A2

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=E:/LuanAn/jcreator_workspace/krbws/log4j-client.log
log4j.appender.A2.Append=false
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5r %-5p [%t] %l - %m%n

Thanks for your answerring me
0
 
hoaivanAuthor Commented:
for example:
at client side i send a SOAPMessage request to a service: http://localhost:8080/axis/services/Hello
and in mycustomHandler (in invoke method) i want to get the above service URL.
How can i do this ?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
hoaivanAuthor Commented:
huhraaa,
i solved my problem, thanks aozarov anyway
0
 
hoaivanAuthor Commented:
althrough your solution doesnt directly solve my problem, i still give you 500 points
:)
0
 
aozarovCommented:
:-) thanks.
What was exactly the problem then?
I assume this was a typo: m.getAllPropertyNames(); -> mc.getPropertyNames()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.