back out all the customised code in setClientHandlers to acquire servletRequest and servletResponse use this instead HttpServletResponse response = (HttpServletResponse) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
HttpServletRequest req = (HttpServletRequest) messageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST); Martin ______________________________________________ Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents. Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. From: m...@myriad-development.com To: axis-user@ws.apache.org Subject: calling Call.setClientHandlers from Stub causes SAXException Date: Mon, 4 May 2009 15:34:15 -0500 calling Call.setClientHandlers from Stub causes SAXException Hello everyone, and thanks in advance for your help. I'm developing a client to consume a web service. I used WSDL2Java (axis1-4) to produce stub classes and everything works great - I successfully process the service. However, I'm required to store the actual request/response documents with the transaction, and this is where I've run into trouble. The only way I could figure out how to do this properly was to modify the generated service stub. I added: public void setClientHandlers(org.apache.axis.Handler requestHandler, org.apache.axis.Handler responseHandler) { this.requestHandler = requestHandler; this.responseHandler = responseHandler; } And modified the webservice method stub as follows: org.apache.axis.client.Call _call = createCall(); //Added these lines... if (requestHandler != null && responseHandler != null) _call.setClientHandlers(requestHandler, responseHandler); //end add _call.setOperation(_operations[0]); try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters}); I created the following classes: public class MyRequestHandler extends org.apache.axis.handlers.LogHandler { public void invoke(org.apache.axis.MessageContext msgContext) throws org.apache.axis.AxisFault { try { SOAPMessageContext smc = (SOAPMessageContext)msgContext; SOAPMessage msg = smc.getMessage(); System.out.println("request:"); msg.writeTo(System.out); } catch (Exception e) { e.printStackTrace(); throw new org.apache.axis.AxisFault(e.getMessage()); } } } //super.invoke(msgContext); public class MyResponseHandler extends org.apache.axis.handlers.LogHandler { public void invoke(org.apache.axis.MessageContext msgContext) throws org.apache.axis.AxisFault { try { SOAPMessageContext smc = (SOAPMessageContext)msgContext; SOAPMessage msg = smc.getMessage(); System.out.println("response:"); msg.writeTo(System.out); } catch (Exception e) { e.printStackTrace(); throw new org.apache.axis.AxisFault(e.getMessage()); } } } And then set the handlers from the client code. With this code in place, I get the following exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeseriali zer.java:145) at org.apache.axis.encoding.DeserializationContext.startElement(Deserialization Context.java:1035) at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165) at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java: 1141) at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236) at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384) at org.apache.axis.client.Call.invoke(Call.java:2467) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812)... I've experimented with different version of handler classes (which are run by the way - I access the request and response), and even tried setting the handler explicitly to null (in the stub class). The bottom line: if I have the Call.setClientHandlers(handler, handler) in place, the exception is returned. Obviously I'm screwing something up, but not sure what. I did, but the way, consider setting handlers the more conventional way (handler chain from the client code), but this method only allows me to specify a class, not an instance, so I loose all context (which I need to be able to store the request/response along with the other transactional information). Please let me know if more information is needed. Michael Lee _________________________________________________________________ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009