Hi Chinthaka,

thanks for your motivation ;)
Apologies, this is the first web service I implement, and therefor the first 
touch with axis2. Everybody starts some time!
I really know that I have to learn a lot about axis2 and its concepts, and I'm 
really willing to.
I came up with this issue at the end of may. At that time I was not able to 
find any helpful article or thread in the list. 

You asked me to re-produce the scenario. In the following I post my client and 
service implementation (only the needed parts).
With this, I get the mentioned internal Server error 500.
To summarise:
- Client request is of SOAP 1.1
- I force the service to deliver back SOAP 1.2
- I use Tomcat 5.0.28 with the axis2 nightly build of the 06 or 07th of June

- If I send a SOAP1.2 request with the client it works.
- If it is useful to you to see the request / response messages, please let me 
know
        I'm not able to copy / paste the messages out of the SOAP Monitor, 
maybe I'm too stupid for that thing, too ;)
        


//  ------------------ Simple Client to test the service ----------------
public class SimpleClient {

        public static void main(String[] args) {                                
                        EndpointReference targetEpr = new 
EndpointReference("http://localhost:8080/axis2/services/LDAPQueryService";);
                        OMFactory fac = OMAbstractFactory.getOMFactory();
                                                
                        OMNamespace ns = 
fac.createOMNamespace("http://home.intranet.eon-energie.com/applications/";, 
"ws");
                        OMElement payload = 
fac.createOMElement("getEONGDSGroups", ns);
                        OMElement param1 = fac.createOMElement("kid", ns);
      param1.setText("S6157");
      payload.addChild(param1);
      OMElement param2 = fac.createOMElement("mu", ns);
      param2.setText("ruhr");
      payload.addChild(param2);
                
                        try {
                                Options options = new Options();
                                options.setTo(targetEpr);
                                
                                // in case of sending SOAP1.2 message           
                                
//options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                                
                                ServiceClient client = new ServiceClient();     
                        
                                client.setOptions(options);                     
        
                                OMElement response = 
client.sendReceive(payload);

                                System.out.println("Response: " + response);
                        } 
                        catch (AxisFault af) {
                                af.printStackTrace();
                        }
        }
}

//------------------- Service Implementation -----------------------
public class LDAPQueryService {
        
        private LDAPQuery ldapQuery = null;
        private MessageContext inMsgCtx = null;
        private MessageContext outMsgCtx = null;
        
        // ...  

        private String PATH_SEPARATOR;
        private static final String LOG_PROPS_FILENAME = 
"log4j_LDAPQueryService.properties";
        private static Logger logger = Logger.getLogger(LDAPQueryService.class);
        private static Logger timeout_logger = 
Logger.getLogger("timeout_logger");
        

        public void setOperationContext(OperationContext opctx) throws 
AxisFault {
                logger.debug("up to setOperationContext...");           
          this.inMsgCtx =       
opctx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
          this.outMsgCtx = 
opctx.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
        }

        // the service method, where the error occurs
        public OMElement getEONGDSGroups(OMElement input) throws AxisFault {

                // ... read the parameters from the request [params]
                // ... try to query directory using LDAP
                // ... in case of invalid data I would like to throw my 
UserException with some clear hints             
                
                OMElement result;

                if (Utils.isValidData(params)){
                        try {                   
                                ldapQuery = new LDAPQuery(false, 
LDAPQuery.EONGDS, "c=de");
                                // nur Groupmembership-Attribut ist relevant
                                ldapQuery.setReturnAtts(new String 
[]{"groupmembership"});
// TODO: generischer halten mit dem optionalen MU-Parameter                     
        
                                String base = "...some basedn...";
                                String filter = "(&(cn=" + params + 
")(objectClass=person))";

                                // this method throws the exception, if someone 
tries to query a non existent dn
                                NamingEnumeration data = 
ldapQuery.querySubtree(base, filter);
                                result = OMHelper.getSOAPFromLDAPResult(data);
                        } 
                        catch (NamingException ne){
                                result = null;
                                handleNamingException(ne, ldapQuery, 
"getEONGDSGroups");
                                throw new AxisFault("some userexception");
                        }
                }
                else {
                        String text = "invalid KID: KID' " + kid + "' not found 
in MU '" + mu + "'";
                        result = handleInvalidData(text, method);
                }       
                return result;
        }       
}

        private void handleNamingException(NamingException ne, LDAPQuery 
ldapQuery, String Method){
        
// zusammengeabut anhand der Spezifikation fuer den SOAPFault nach SOAP 1.2,
// w3c: 
http://www.w3.org/2000/xp/Group/2/06/LC/soap12-testcollection.html#1-soapfault-prop

// 
                SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); 
                SOAPFault soapFault = soapFactory.createSOAPFault();
                SOAPFaultCode faultCode = 
soapFactory.createSOAPFaultCode(soapFault);
                faultCode.setText("Server:UserException");
                SOAPFaultValue soapFaultValue = 
soapFactory.createSOAPFaultValue(faultCode);
                soapFaultValue.setText("Classname of my UserException");
                SOAPFaultReason soapFaultReason = 
soapFactory.createSOAPFaultReason(soapFault);
                SOAPFaultText soapFaultText = 
soapFactory.createSOAPFaultText(soapFaultReason);
                soapFaultText.setText(ne.getMessage());
                
                SOAPFaultDetail soapFaultDetail = 
soapFactory.createSOAPFaultDetail(soapFault);
                soapFaultDetail.setText("printing the stacktrace of the 
exception and some further details of the queried directory with all query 
Parameters");
                
                
inMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, faultCode);
    inMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, 
soapFaultReason);
    inMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, 
soapFaultDetail);
                                        
        }               
}

> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> Gesendet: 16.06.06 18:45:40
> An: [email protected]
> Betreff: Re: [axis2] problem with Userexception and AxisFault - Part 2


> [EMAIL PROTECTED] wrote:
> > ok, filling my own thread all alone.
> > Maybe my conclusions help somebody out there. This is what I realized:
> > 
> > - The all-dominant hint was to work with the incoming MessageContext. In 
> > all my further trials I worked with the  outgoing MessageContext, because I 
> > thought, that's what gets back to the client.
> > - Furthermore the request was SOAP 1.1. Forcing the service to deliver back 
> > SOAP 1.2 ended up in an internal Server Error 500, with the message
> 
> Seems you are getting into conclusions with little or no facts :).
> 
> The reason behind the implementation of fault handling with the incoming
>  message context is to enable some one to throw faults, even before the
> message is haded over to the service implementation. For example, what
> if there are problems in the addressing headers of the incoming message,
> when addressing is engaged. By the time you run you addressing handlers,
> or any other handlers in the IN flow, you only have access to the in
> message context.
> 
> And at the same time, you have not understood one more concept. Out
> message context represents only the out message that goes to the client,
> iff there aren't any fault. You can in any means treat out message
> context to be the fault message context.
> 
> 
> 
> > 
> >    org.apache.axiom.soap.SOAPProcessingException: Expecting SOAP 1.1 
> > implementation of SOAP Fault Code. But received some other implementation
> >     
> > org.apache.axiom.soap.impl.llom.soap11.SOAP11FaultImpl.setCode(SOAP11FaultImpl.java:85)
> > 
> >    although I used the SOAPFactory soapFactory = 
> > OMAbstractFactory.getSOAP12Factory();  in my service implementation  !!!
> 
> This may or may not be a bug. I have clearly asked you to help me to
> reproduce this problem. Without that how can I debug?
> I repeat myself, help me to re-create the scenario. I may be able to
> help you.
> 
> > - What I now did is to query the incoming SOAP Version and depending on 
> > this creating the matching SOAPFactory like this:
> >             SOAPFactory soapFactory = (inMsgCtx.isSOAP11()) ? 
> > OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
> >    I checked this using both versions on the request and it works fine for 
> > me.
> 
> This is the way you should actually do!!
> 
> -- Chinthaka
> 
> 


______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to