Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

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.
0
hoaivan
Asked:
hoaivan
  • 4
  • 2
1 Solution
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now