Custom response for parsing errors
Hi, I 'd like to return a custom message when the message sent to my Webservice is not well formed. Instead of returning a SOAPFault I would like to return a normal response. An element of the response will be used to set a specific status code for parsing error. I tried to do that with an Axis handler overriding the invoke(MessageContext ctx) throws AxisFault and onFault(MessageContext messagecontext) methods but it does not work. But none method of the handler is invoked when the message is not well formed. (not that my handler is invoked properly when the message is well formed). How can i intercept parsing errors ? Thanks, Luc ?xml version=1.0 encoding=utf-8? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; soapenv:Body soapenv:Fault faultcodesoapenv:Server.userException/faultcode faultstringorg.xml.sax.SAXParseException: The end-tag for element type quot;Folderquot; must end with a 'gt;' delimiter./faultstring detail ns1:hostname xmlns:ns1=http://xml.apache.org/axis/;myhost/ns1:hostname /detail /soapenv:Fault /soapenv:Body /soapenv:Envelope
Message transformation
Hi,I have multiple businessservices interfacesthat I would like to expose with Xfire as web services. The problem is that I need to transform the input and output parameters of the interface to/from someexternal formats (I have the respective XML schemas for the external formats) I would like Axis2 to use the external XML schemas in the types section of the generated WSDL. Can Axis2 handle such requirements ? How would you perform such scenario ? Actuallyone solution that I thought would be to write a web service that accepts a xsd:string and returns a xsd:string and then add a router + transformer that would transform the message from the external format to an internal object and invoke the correct business services using the XML namespace of the incoming message. The main problem with this solution is that my web service is not self descriptive anymore and the WSDL does not give any informationon the service. Thanks in advance, Luc
About the operation element in server-config.wsdd
Hi,I don't really understand what's the point of having an operation element in the server-config.wsdd.Actually, I generated my Axis stubs and skeletons from the WSDL2Java utility.The prefixes in the SOAP request and response are not what I expected and I wanted to tweak them in the operation element of the server-config.wsdd.But when I have a look at the generated stub and skeleton of my web ServiceI see static initialization of operation description like this (extract of the skeleton): static { _operations = new org.apache.axis.description.OperationDesc[1]; _initOperationDesc1(); } private static void _initOperationDesc1(){ org.apache.axis.description.OperationDesc oper; org.apache.axis.description.ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper.setName(call); param = new org.apache.axis.description.ParameterDesc (new javax.xml.namespace.QName(http://www.mycompany.com, CallRq), org.apache.axis.description.ParameterDesc.IN , new javax.xml.namespace.QName(http://www.mycompany.com, CallRqType), com.fis.infra.webservices.model.CallRqType.class, false, false); oper.addParameter (param); oper.setReturnType(new javax.xml.namespace.QName(http://www.mycompany.com, CallRsType)); oper.setReturnClass(com.fis.infra.webservices.model.CallRsType.class ); ...}So i don't really understand what's the point of operation element ?Can anyone enlight me ?Thanks in advance,Luc
Controlling prefix in doc/lit WS
Hi,I am just wondering how I can control the prefix used in my document/literal webservice. I am using the stub and skeleton of Axis generated with WSDL2Java and its autogenerated beans(from the XML schemas of my WSDL) I was wondering if it's possible to control the prefix used in my document literal parameter and reponse(there's no prefix so far)I captured the following message in my SOAP request :soapenv:Body CallRq xmlns=http://www.mycompany...and I should provide (for B2B interoperability) the following:mc:CallRq xmlns:mc= http://www.mycompany...Also for the SOAP-Response, i got this:soapenv:Body CallRs xmlns=http://www.mycompany...and should have the followingsoapenv:Body mc:CallRs xmlns:mc=http://www.mycompany... Is it something that can be configured ?ThanksLuc
Axis faults
Hi, I have questions about SOAPFault generated by Axis that might be related: 1) When I throw my application exception (which is declared in the WSDL and SEI, and has been generated by WSDL2Java) , Axis appends some elements like {http://xml.apache.org/axis/}exceptionName with the server stack trace included it. Is it possible to disable this behaviour and configure Axis to not append this ? 2) Axis put in the faultcode element a message like Server.* when I throw my custom exception. Is is possible to control what's in the faultcode in my case it should be only Server ? 3) My input parameters are strongly typed and associated beans have been generated by WSDL2Java task. When a deserialization error occurs an AxisFault is sent and I would like to throw my custom fault. I guess the strategy for this is to write a handler which intercepts the soapfault detach the AxisFault of the SOAPEnvelope and throw mine but is there a better way to do this ? Thanks Luc Thanks Luc
Strange error with attachment
Hi, I have a strange error when I try to attach an XML document to the SOAPMessageContext and don't know if Axis API 1.3 are involved in this. Here's my code: SOAPMessageContext soapmcontext = (SOAPMessageContext) mc; String test =test/test; SOAPMessage soapmessage = soapmcontext.getMessage(); StreamSource source = new StreamSource(new StringReader(test); DataHandler dh = new DataHandler(source,text/xml); AttachmentPart attachment = soapmessage.createAttachmentPart(dh); attachment.setDataHandler(dh); soapmessage.addAttachmentPart(attachment); and here's what i get: java.io.IOException: text/xml DataContentHandler requires String object, was given object of type class javax.xml.transform.stream.StreamSource at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:103) (see the complete stack trace below) It's strange because the error message says exactly the opposite of JAX-RPC specs: the text/xml mime type is sppusosed to be mapped to javax.xml.transform.stream.StreamSource If i replace the line DataHandler dh = new DataHandler(source,text/xml); with: DataHandler dh = new DataHandler(test,text/xml); it works ! Thanks for your help java.io.IOException: text/xml DataContentHandler requires String object, was given object of type class javax.xml.transform.stream.StreamSource at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:103) at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:839) at javax.activation.DataHandler.writeTo(DataHandler.java:295) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1201) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:707) at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233) at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:67) at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:839) at javax.activation.DataHandler.writeTo(DataHandler.java:295) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1201) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1611) at org.apache.axis.attachments.MimeUtils.writeToMultiPartStream(MimeUtils.java:202) at org.apache.axis.attachments.AttachmentsImpl.writeContentToStream(AttachmentsImpl.java:493) at org.apache.axis.Message.writeTo(Message.java:545) at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:511) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at com.test.infra.ws.InsuranceMsgSvcCallBindingStub.call(AcordMsgSvcCallBindingStub.java:933) at com.test.infra.ws.StubTestCallWS.testWithSingleXMLAttachment(StubTestCallWS.java:156)
Using JAX-RPC exceptions
Hi, I have hard time trying to make my JAX-RPC webservice endpoint integrate to Axis. I have a Webservice Service Endpoint Interface, its implementation class and a WSDL. The WSDL declares a SOAP fault. If i use the skeleton generated by Axis and throw my custom exception from it, the custom exception appears in the details element of the soapenv:Fault element. If I use my own JAX-RPC implementation and throw my custom exception from it I get: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. Actually in my JAX-RPC class, I use the exception class generated by Axis WSDL2Java which extends org.apache.axis.AxisFault. and i suppose that it has to be declared in the server-config.wsdd. I have noticed that the Axis BindingSkeleton declares the exception in a static block. _fault = new org.apache.axis.description.FaultDesc(); _fault.setName(InsuranceFault); _fault.setQName(new javax.xml.namespace.QName(http://, InsuranceDetails)); _fault.setClassName(com.fis.infra.ws.InsuranceFault); _fault.setXmlType(new javax.xml.namespace.QName(http://www.w3.org/2001/XMLSchema, string)); _oper.addFault(_fault); Is it possible to use an Axis exception from a standard JAX-RPC implementation class ? I am really reluctant to use the skeletons generated by Axis and put my code in them and would prefer to stick to standard JAX-RPC implementations. I guess it would be better to use also a true JAX-RPC exception also but I haven't found out how to do it. Would someone have an example of a standard JAX-RPC Web service which throws a custom exception with Apache Axis ? Thanks, bengali
Can SOAPMonitor display faults ?
Hi, I have enabled SOAPMonitor and it works fine when no exception occurs. It shows me the SOAP enveloppes of the request and response but I wanted to test my custom exceptions (which are mapped to soap-faults declared in the WSDL) but I can't see them in the SOAPMonitor. Actually I don't see any response (when an exception is thrown) in SOAPMonitor but my client code catches well the appropriate exception and I also can see the server messages in the details of the exception. Is it a normal behaviour of SOAPMonitor to not display the SOAP envelopes when a fault occurs ? Do I have to configure something in the WSDD ? Thanks, bengali
ClassCastException
Hi, I have a problem with Axis 1.3 (and 1.2). When I invoke the Webservice I get a ClassCastException org.apache.axis.message.Text I am running the Webservice on Tomcat 5.5 with JDK 1.5.03. I also had this exception when the WS was a RPC type (not doc/literal) but the ClassCastException was a java.lang.String ClassCastException. I really have no idea of what's wrong and don't understand why I get ClassCastException for my really simple WS. Thanks for your help. The service part of server-config.wsdd: service name=LoginFacade provider=java:RPC style=document use=literal wsdlFile/LoginFacade.wsdl/wsdlFile parameter name=allowedMethods value=*/ parameter name=className value=com.presentation.web.services.LoginFacade/ /service The WSDL file. ?xml version=1.0 encoding=UTF-8? definitions targetNamespace=urn:soap.snakeoil.com xmlns=http://schemas.xmlsoap.org/wsdl/ xmlns:apachesoap=http://xml.apache.org/xml-soap xmlns:impl=urn:soap.snakeoil.com xmlns:intf=urn:soap.snakeoil.com xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/ xmlns:xsd=http://www.w3.org/2001/XMLSchema message name=loginRequest part name=loginData type=xsd:string/ /message message name=loginResponse part name=loginReturn type=xsd:string/ /message portType name=LoginFacade operation name=login parameterOrder=loginData input message=impl:loginRequest name=loginRequest/ output message=impl:loginResponse name=loginResponse/ /operation /portType binding name=LoginFacadeSoapBinding type=impl:LoginFacade soap:binding style=document transport=http://schemas.xmlsoap.org/soap/http/ operation name=login soap:operation soapAction=/ input name=loginRequest soap:body namespace=http://soap.snakeoil.com use=literal/ /input output name=loginResponse soap:body namespace=http://soap.snakeoil.com use=literal/ /output /operation /binding service name=LoginFacadeService port binding=impl:LoginFacadeSoapBinding name=LoginFacade soap:address location=http://localhost:8080/PresentationWeb/LoginFacade/ /port /service /definitions The StackTrace: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.ClassCastException: org.apache.axis.message.Text faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.lang.ClassCastException: org.apache.axis.message.Text at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:97) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453) at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) 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:595) {http://xml.apache.org/axis/}hostname:ldewavrin {http://xml.apache.org/axis/}isRuntimeException:true java.lang.ClassCastException: org.apache.axis.message.Text at org.apache.axis.AxisFault.makeFault(AxisFault.java:101) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)