Chinthaka, Making those changes fixes up the SOAPFault. Here's what the debugger says the envelope looks like just before I throw the AxisFault:
<?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <soapenv:Fault> <faultcode xmlns:m="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2">m:FaultException</faultcode> <faultstring>com.sas.web.services.maker.FaultException</faultstring> <detail> <FaultException xmlns="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2"> <ExceptionMessage>Service "myService1234" already exists.</ExceptionMessage> </FaultException> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope> This is good! now I do the following: AxisFault axisFault = new AxisFault(soapFault); throw axisFault; This is what the client sees: <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header /> <soapenv:Body> <soapenv:Fault> <faultcode>m:FaultException</faultcode> <faultstring>unknown</faultstring> <faultactor>http://myAxisServer/role/default</faultactor> <detail> <soapenv:Exception>org.apache.axis2.AxisFault at com.sas.web.services.maker.axis2.WebServiceMakerPortTypeSkeleton.MakeWebService(WebServiceMakerPortTypeSkeleton.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.axis2.receivers.RawXMLINOutMessageReceiver.invokeBusinessLogic(RawXMLINOutMessageReceiver.java:124) at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:331) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:274) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:150) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:534) </soapenv:Exception> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope> This is not what I want. How can I get the soapFault that I formulated back to the client? Thanks. -----Original Message----- From: Eran Chinthaka [mailto:[EMAIL PROTECTED] Sent: Friday, March 10, 2006 12:53 AM To: [email protected] Subject: Re: [AXIS2] soapFault question Hi Tony, Seems like you have tried to create the faults using SOAP 1.1 api. You may also agree that the fault hierarchy in SOAP 1.1 and 1.2 are different. So some time back we decided to have the SOAP 1.2 api across the engine for consistency and developer convenience. Users must always create all the SOAP messages using SOAP 1.2 api. And if they want to change the version, they just need to switch the factories. Axiom SOAP implementation will take care of all the other work (like serialization) transparent to the user. I changed your code so that it will run properly with the above explanation. I added some hypothetical information, as I wanted to re-create the bug. Here we go. Exception t = new Exception("Eureka, Says Archimedes and runs naked on the road"); SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope(); SOAPBody soapBody = soapFactory.createSOAPBody(soapEnvelope); SOAPFault soapFault = soapFactory.createSOAPFault(soapBody); SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(soapFault); soapFaultCode.declareNamespace("http://someuri.org", "m"); SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode); soapFaultValue.setText("m:FaultException"); SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason(soapFault); SOAPFaultText soapFaultText = soapFactory.createSOAPFaultText(soapFaultReason); soapFaultText.setText("This is some fault reason"); SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(soapFault); QName qName = new QName("http://someuri.org", "FaultException"); OMElement detail = soapFactory.createOMElement(qName, null); qName = new QName("http://someuri.org", "ExceptionMessage"); Throwable e = t; while (e != null) { OMElement exception = soapFactory.createOMElement(qName, null); exception.setText(t.getMessage()); detail.addChild(exception); e = e.getCause(); } System.out.println("soapEnvelope = " + soapEnvelope); } But I agree that throwing an NPE in this case is not a good idea :). -- Chinthaka Tony Dean wrote: >Hi, > >What is wrong with the following: > > SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory(); > SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope(); > SOAPBody soapBody = soapFactory.createSOAPBody(soapEnvelope); > SOAPFault soapFault = soapFactory.createSOAPFault(soapBody); > SOAPFaultCode soapFaultCode = > soapFactory.createSOAPFaultCode(soapFault); > soapFaultCode.declareNamespace(Constants.WEBSERVICEMAKER_NS, > "m"); > soapFaultCode.setText("m:FaultException"); > SOAPFaultReason soapFaultReason = > soapFactory.createSOAPFaultReason(soapFault); > soapFaultReason.setText(FaultException.class.getName()); > SOAPFaultDetail soapFaultDetail = > soapFactory.createSOAPFaultDetail(soapFault); > > QName qName = new QName(Constants.WEBSERVICEMAKER_NS, > "FaultException"); > OMElement detail = soapFactory.createOMElement(qName, null); > qName = new QName(Constants.WEBSERVICEMAKER_NS, > "ExceptionMessage"); > Throwable e = t; > while (e != null) { > OMElement exception = > soapFactory.createOMElement(qName, null); > exception.setText(t.getMessage()); > detail.addChild(exception); > e = e.getCause(); > } > > AxisFault axisFault = new AxisFault(soapFault); > throw axisFault; > >I end up with a nullPointerException message in the fault as presented to the >client instead of what I intended. Should be something like: > ><Body> > <Fault> > <faultcode xmlns:m="myNamespace">m:FaultException</faultcode> > <faultstring>com.sas.web.services.maker.FaultException</faultcode> > <detail> > <FaultException xmlns="myNamespace"> > <ExceptionMessage>first exception msg...</ExceptionMessage> > <ExceptionMessage>second exception msg...</ExceptionMessage> > ... > </FaultException> > </detail> > </Fault> ></Body> > >Thanks for any advice. > >Tony Dean >SAS Institute Inc. >919.531.6704 >[EMAIL PROTECTED] > >SAS... The Power to Know >http://www.sas.com > > > >
