[AXIS2] Handling XML Document in parameters
Hi all, I've created a web service which takes a XML document in parameter (more precisely an OMElement). This web service has 2 wsdl (message and document type) linked to a XSD. I've generated stubs for each wsdl and they look fine to me Then, I needed to test this web service from: 1. a Internet explorer by passing the xml string to the web service like this: http://localhost:8080/app/services/service/read?xml=aa/aa 2. a the message stub from a test program 3. a the document stub from a test program So... : 1. I call the web service from an Internet explorer 2. I wrote a message test program: ... org.apache.axis.message.SOAPBodyElement soapObjReturn = (org.apache.axis.message.SOAPBodyElement)messageService.read(xml); Where xml is a org.w3c.dom.Document 3. I wrote a Document test program in which I've just used the generated type to call the service My web service method looks like this : public OMElement read(OMElement xml){ ... Conversion of OMElement to org.w3c.dom.Document ... } So far so good but I've noticed that depending on the way I'm calling the stub, the OMElement in the web service method is populated differently For instance, to get the XML string in order to convert it into a org.w3c.dom.Document, I had to developp some ugly code if (!xml.getText().equals()){ xmlToParse=xml.getText(); }else if (!xml.getFirstElement().getText().equals()){ xmlToParse=xml.getFirstElement().getText(); }else if (!xml.toString().equals()){ xmlToParse=xml.toString(); } It works fine but I think I'm missing something really important on how to handle org.w3c.dom.Document with OMElement Does someone have best practices on OMElement and w3c document? Thanks Here an extract of the message WSDL (type part) wsdl:types schema targetNamespace=http://.com; xmlns=http://www.w3.org/2001/XMLSchema; element name=read type=xsd:anyType / /schema schema targetNamespace=http://.com/ws/stub/XXX/message/literal; xmlns=http://www.w3.org/2001/XMLSchema; element name=readReturn type=xsd:anyType / /schema /wsdl:types wsdl:message name=readRequest wsdl:part name=part element=tns1:read/ /wsdl:message wsdl:message name=readResponse wsdl:part element=impl:readReturn name=readReturn / /wsdl:message wsdl:portType name=XXXPortType wsdl:operation name=read wsdl:input message=axis2:readRequest wsaw:Action=urn:read/ wsdl:output message=axis2:readResponse wsaw:Action=urn:readResponse/ /wsdl:operation /wsdl:portType Here the extract for WSDL document wsdl:types part. wsdl:types schema xmlns=http://www.w3.org/2001/XMLSchema; xmlns:xsdXXX=http://.com/schema; xsd:import namespace=http://.com/schema/; schemaLocation=X.xsd/ /schema /wsdl:types wsdl:message name=readRequest wsdl:part element=xsdXXX:XXX name=part / /wsdl:message wsdl:message name=readResponse wsdl:part element=xsdXXX:XXX name=readReturn / /wsdl:message wsdl:portType name=XXPortType wsdl:operation name=read wsdl:input message=axis2:readRequest wsaw:Action=urn:read/ wsdl:output message=axis2:readResponse wsaw:Action=urn:readResponse/ /wsdl:operation /wsdl:portType --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. begin:vcard fn:Laurent EVEN n:EVEN;Laurent org;quoted-printable:SAB Ing=C3=A9nierie Informatique;Service RIC - Bureau 203 adr;dom:Rue Henri Becquerel;;CP27 - P.I.B.S.;VANNES;;56038 email;internet:laurent-e...@sab2i.com title;quoted-printable:Ing=C3=A9nieur d'=C3=A9tudes tel;work:+33 (0)2 97 01 59 59 tel;fax:+33 (0)2 97 01 59 50 url:http://www.sab-tm.com version:2.1 end:vcard
Re: [AXIS2] Accessing classes inside aar from a jar located in the lib directory
Andreas, thanks for your response. Basically, my class in the WEB-INF/lib contains core functions which are used by all services. Each service contains specific code. for each service call, I have service - core (web-inf/lib) - service Is there a simple way to get the classloader dynamically for a class in WEB-INF/lib directory? Laurent Andreas Veithen a écrit : Laurent, By design, there is a distinct class loader for each AAR. This is important to isolate services from each other. The classes in the JARs in WEB-INF/lib are loaded by the Web app class loader, which is the parent of the AAR class loaders. It is therefore normal that a class in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR file. There are ways around this, but first you should make sure that you are not running into this issue because of a flaw in your design. What is actually the use case for this? Andreas 2009/5/14 Laurent Even laurent-e...@sab2i.com: Hi all, I have some classes in a jar which is located in the WEB-INF/lib directory of my application. I deployed several services in this application. So far so good but (always a but ;) ) I'm doing a classforname from my jar fil (WEB-INF/lib) that try to instantiate a class inside a service (aar) I'm getting a classnotfound exception. I found several post on the internet talking of classnotfound exception but only for service deployment I also used the parameter ServiceTCCL for my service (parameter name=ServiceTCCL locked=falsecomposite/parameter) without success. If you have any clue on how to solve this problem, please, let me know Bye Laurent --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. begin:vcard fn:Laurent EVEN n:EVEN;Laurent org;quoted-printable:SAB Ing=C3=A9nierie Informatique;Service RIC - Bureau 203 adr;dom:Rue Henri Becquerel;;CP27 - P.I.B.S.;VANNES;;56038 email;internet:laurent-e...@sab2i.com title;quoted-printable:Ing=C3=A9nieur d'=C3=A9tudes tel;work:+33 (0)2 97 01 59 59 tel;fax:+33 (0)2 97 01 59 50 url:http://www.sab-tm.com version:2.1 end:vcard
Re: [AXIS2] Accessing classes inside aar from a jar located in the lib directory
Great! it works! Thanks Andreas!! Andreas Veithen a écrit : In that case you should change the code in WEB-INF/lib to use Thread.getContextClassLoader(). If the ServiceTCCL parameter is set correctly, then that method should return the appropriate class loader. Andreas 2009/5/15 Laurent Even laurent-e...@sab2i.com: Andreas, thanks for your response. Basically, my class in the WEB-INF/lib contains core functions which are used by all services. Each service contains specific code. for each service call, I have service - core (web-inf/lib) - service Is there a simple way to get the classloader dynamically for a class in WEB-INF/lib directory? Laurent Andreas Veithen a écrit : Laurent, By design, there is a distinct class loader for each AAR. This is important to isolate services from each other. The classes in the JARs in WEB-INF/lib are loaded by the Web app class loader, which is the parent of the AAR class loaders. It is therefore normal that a class in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR file. There are ways around this, but first you should make sure that you are not running into this issue because of a flaw in your design. What is actually the use case for this? Andreas 2009/5/14 Laurent Even laurent-e...@sab2i.com: Hi all, I have some classes in a jar which is located in the WEB-INF/lib directory of my application. I deployed several services in this application. So far so good but (always a but ;) ) I'm doing a classforname from my jar fil (WEB-INF/lib) that try to instantiate a class inside a service (aar) I'm getting a classnotfound exception. I found several post on the internet talking of classnotfound exception but only for service deployment I also used the parameter ServiceTCCL for my service (parameter name=ServiceTCCL locked=falsecomposite/parameter) without success. If you have any clue on how to solve this problem, please, let me know Bye Laurent --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. --- Un geste responsable aujourd hui pour preserver demain. N'imprimez ce message que si necessaire. Please, consider the environment before printing this email. --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. begin:vcard fn:Laurent EVEN n:EVEN;Laurent org;quoted-printable:SAB Ing=C3=A9nierie Informatique;Service RIC - Bureau 203 adr;dom:Rue Henri Becquerel;;CP27 - P.I.B.S.;VANNES;;56038 email;internet:laurent-e...@sab2i.com title;quoted-printable:Ing=C3=A9nieur d'=C3=A9tudes tel;work:+33 (0)2 97 01 59 59 tel;fax:+33 (0)2 97 01 59 50 url:http://www.sab-tm.com version:2.1 end:vcard
[AXIS2] Accessing classes inside aar from a jar located in the lib directory
Hi all, I have some classes in a jar which is located in the WEB-INF/lib directory of my application. I deployed several services in this application. So far so good but (always a but ;) ) I'm doing a classforname from my jar fil (WEB-INF/lib) that try to instantiate a class inside a service (aar) I'm getting a classnotfound exception. I found several post on the internet talking of classnotfound exception but only for service deployment I also used the parameter ServiceTCCL for my service (parameter name=ServiceTCCL locked=falsecomposite/parameter) without success. If you have any clue on how to solve this problem, please, let me know Bye Laurent --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. begin:vcard fn:Laurent EVEN n:EVEN;Laurent org;quoted-printable:SAB Ing=C3=A9nierie Informatique;Service RIC - Bureau 203 adr;dom:Rue Henri Becquerel;;CP27 - P.I.B.S.;VANNES;;56038 email;internet:laurent-e...@sab2i.com title;quoted-printable:Ing=C3=A9nieur d'=C3=A9tudes tel;work:+33 (0)2 97 01 59 59 tel;fax:+33 (0)2 97 01 59 50 url:http://www.sab-tm.com version:2.1 end:vcard
[AXIS2] Web service that extends an abstract class
Hi all, Does someone managed to publish a web service in axis 2 that extends an abstract class containing the method to call. Here's an example to illustrate: package pack; import pack.MyAbstractClass; public class MyWebService extends MyAbstractClass{ public MyWebService (){ }; } public abstract class MyAbstractClass{ public OMElement read(OMElement xml){ ... } } my services.xml service name=mywebservice parameter name=ServiceClasspack.MyWebService/parameter operation name=read messageReceiver class=org.apache.axis2.receivers.RawXMLINOutMessageReceiver/ /operation /service Here an extract of the wsdl generated by axis2 *wsdl:types /* wsdl:message name=*readRequest* / wsdl:message name=*readResponse* / - # wsdl:portType name=*soldemvtPortType* I'm getting the following error when calling the web service: ... The ServiceClass object does not implement the required method in the following form: OMElement read(OMElement e) ... Is there a constraint with abstract classes? Thanks in advance --- Un geste responsable aujourd hui pour preserver demain. N imprimez ce message que si necessaire. Please, consider the environment before printing this email. begin:vcard fn:Laurent EVEN n:EVEN;Laurent org;quoted-printable:SAB Ing=C3=A9nierie Informatique;Service RIC - Bureau 203 adr;dom:Rue Henri Becquerel;;CP27 - P.I.B.S.;VANNES;;56038 email;internet:laurent-e...@sab2i.com title;quoted-printable:Ing=C3=A9nieur d'=C3=A9tudes tel;work:+33 (0)2 97 01 59 59 tel;fax:+33 (0)2 97 01 59 50 url:http://www.sab-tm.com version:2.1 end:vcard
Re: Handle org.w3c.dom.Document in parameters
Hi again, Does someone have a clue on how to solve this problem? I managed to get it work with OMElement but I'm still stuck with this w3c.document Thanks in advance Laurent Even a écrit : Hi all, Here is a simple java program package c; import org.w3c.dom.Document; public class b{ public b(){ } public Document testB(Document xml){ return xml; } } AAR deployment was OK I'm trying to interrogate the web service http://localhost:8080/axis2/b/testB?xml=... Here the exception I'm getting in my tomcat logs ... [ERROR] org.w3c.dom.Document org.apache.axis2.AxisFault: org.w3c.dom.Document at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:30) at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:410) at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:722) at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:670)... Caused by: java.lang.InstantiationException: org.w3c.dom.Document at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) ... WSDL generated by AXIS2 ?xml version=1.0 encoding=UTF-8 ? - wsdl:definitions xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:ns1=http://org.apache.axis2/xsd; xmlns:ns=http://c; xmlns:wsaw=http://www.w3.org/2006/05/addressing/wsdl; xmlns:http=http://schemas.xmlsoap.org/wsdl/http/; xmlns:ax21=http://dom.w3c.org/xsd; xmlnss=http://www.w3.org/2001/XMLSchema; xmlns:mime=http://schemas.xmlsoap.org/wsdl/mime/; xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/; xmlns:soap12=http://schemas.xmlsoap.org/wsdl/soap12/; targetNamespace=http://c; wsdl:documentationb/wsdl:documentation - wsdl:types - xs:schema attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http://dom.w3c.org/xsd; - xs:complexType name=Document - xs:sequence xs:element minOccurs=0 name=doctype nillable=true type=ax21ocumentType / xs:element minOccurs=0 name=documentElement nillable=true type=ax21:Element / xs:element minOccurs=0 name=documentURI nillable=true type=xs:string / xs:element minOccurs=0 name=domConfig nillable=true type=ax21OMConfiguration / xs:element minOccurs=0 name=implementation nillable=true type=ax21OMImplementation / xs:element minOccurs=0 name=inputEncoding nillable=true type=xs:string / xs:element minOccurs=0 name=strictErrorChecking type=xs:boolean / xs:element minOccurs=0 name=xmlEncoding nillable=true type=xs:string / xs:element minOccurs=0 name=xmlStandalone type=xs:boolean / xs:element minOccurs=0 name=xmlVersion nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=DocumentType - xs:sequence xs:element minOccurs=0 name=entities nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=internalSubset nillable=true type=xs:string / xs:element minOccurs=0 name=name nillable=true type=xs:string / xs:element minOccurs=0 name=notations nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=publicId nillable=true type=xs:string / xs:element minOccurs=0 name=systemId nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=NamedNodeMap - xs:sequence xs:element minOccurs=0 name=length type=xs:int / xs:element minOccurs=0 name=namedItem nillable=true type=ax21:Node / xs:element minOccurs=0 name=namedItemNS nillable=true type=ax21:Node / /xs:sequence /xs:complexType - xs:complexType name=Node - xs:sequence xs:element minOccurs=0 name=attributes nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=baseURI nillable=true type=xs:string / xs:element minOccurs=0 name=childNodes nillable=true type=ax21:NodeList / xs:element minOccurs=0 name=firstChild nillable=true type=ax21:Node / xs:element minOccurs=0 name=lastChild nillable=true type=ax21:Node / xs:element minOccurs=0 name=localName nillable=true type=xs:string / xs:element minOccurs=0 name=namespaceURI nillable=true type=xs:string / xs:element minOccurs=0 name=nextSibling nillable=true type=ax21:Node / xs:element minOccurs=0 name=nodeName nillable=true type=xs:string / xs:element minOccurs=0 name=nodeType type=xs:short / xs:element minOccurs=0 name=nodeValue nillable=true type=xs:string / xs:element minOccurs=0 name=ownerDocument nillable=true type=ax21ocument / xs:element minOccurs=0 name=parentNode nillable=true type=ax21:Node / xs:element minOccurs=0 name=prefix nillable=true type=xs:string / xs:element minOccurs=0 name=previousSibling nillable=true type=ax21:Node / xs:element minOccurs=0 name=textContent nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=NodeList - xs:sequence xs:element minOccurs=0 name=length type=xs:int / /xs:sequence /xs:complexType - xs:complexType name=Element - xs:sequence xs:element minOccurs=0 name=attributeNode nillable=true type=ax21:Attr / xs:element minOccurs=0 name=attributeNodeNS nillable=true type=ax21:Attr
Handle org.w3c.dom.Document in parameters
Hi all, Here is a simple java program package c; import org.w3c.dom.Document; public class b{ public b(){ } public Document testB(Document xml){ return xml; } } AAR deployment was OK I'm trying to interrogate the web service http://localhost:8080/axis2/b/testB?xml=... Here the exception I'm getting in my tomcat logs ... [ERROR] org.w3c.dom.Document org.apache.axis2.AxisFault: org.w3c.dom.Document at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:30) at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:410) at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:722) at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:670)... Caused by: java.lang.InstantiationException: org.w3c.dom.Document at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) ... WSDL generated by AXIS2 ?xml version=1.0 encoding=UTF-8 ? - wsdl:definitions xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:ns1=http://org.apache.axis2/xsd; xmlns:ns=http://c; xmlns:wsaw=http://www.w3.org/2006/05/addressing/wsdl; xmlns:http=http://schemas.xmlsoap.org/wsdl/http/; xmlns:ax21=http://dom.w3c.org/xsd; xmlnss=http://www.w3.org/2001/XMLSchema; xmlns:mime=http://schemas.xmlsoap.org/wsdl/mime/; xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/; xmlns:soap12=http://schemas.xmlsoap.org/wsdl/soap12/; targetNamespace=http://c; wsdl:documentationb/wsdl:documentation - wsdl:types - xs:schema attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http://dom.w3c.org/xsd; - xs:complexType name=Document - xs:sequence xs:element minOccurs=0 name=doctype nillable=true type=ax21ocumentType / xs:element minOccurs=0 name=documentElement nillable=true type=ax21:Element / xs:element minOccurs=0 name=documentURI nillable=true type=xs:string / xs:element minOccurs=0 name=domConfig nillable=true type=ax21OMConfiguration / xs:element minOccurs=0 name=implementation nillable=true type=ax21OMImplementation / xs:element minOccurs=0 name=inputEncoding nillable=true type=xs:string / xs:element minOccurs=0 name=strictErrorChecking type=xs:boolean / xs:element minOccurs=0 name=xmlEncoding nillable=true type=xs:string / xs:element minOccurs=0 name=xmlStandalone type=xs:boolean / xs:element minOccurs=0 name=xmlVersion nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=DocumentType - xs:sequence xs:element minOccurs=0 name=entities nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=internalSubset nillable=true type=xs:string / xs:element minOccurs=0 name=name nillable=true type=xs:string / xs:element minOccurs=0 name=notations nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=publicId nillable=true type=xs:string / xs:element minOccurs=0 name=systemId nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=NamedNodeMap - xs:sequence xs:element minOccurs=0 name=length type=xs:int / xs:element minOccurs=0 name=namedItem nillable=true type=ax21:Node / xs:element minOccurs=0 name=namedItemNS nillable=true type=ax21:Node / /xs:sequence /xs:complexType - xs:complexType name=Node - xs:sequence xs:element minOccurs=0 name=attributes nillable=true type=ax21:NamedNodeMap / xs:element minOccurs=0 name=baseURI nillable=true type=xs:string / xs:element minOccurs=0 name=childNodes nillable=true type=ax21:NodeList / xs:element minOccurs=0 name=firstChild nillable=true type=ax21:Node / xs:element minOccurs=0 name=lastChild nillable=true type=ax21:Node / xs:element minOccurs=0 name=localName nillable=true type=xs:string / xs:element minOccurs=0 name=namespaceURI nillable=true type=xs:string / xs:element minOccurs=0 name=nextSibling nillable=true type=ax21:Node / xs:element minOccurs=0 name=nodeName nillable=true type=xs:string / xs:element minOccurs=0 name=nodeType type=xs:short / xs:element minOccurs=0 name=nodeValue nillable=true type=xs:string / xs:element minOccurs=0 name=ownerDocument nillable=true type=ax21ocument / xs:element minOccurs=0 name=parentNode nillable=true type=ax21:Node / xs:element minOccurs=0 name=prefix nillable=true type=xs:string / xs:element minOccurs=0 name=previousSibling nillable=true type=ax21:Node / xs:element minOccurs=0 name=textContent nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType name=NodeList - xs:sequence xs:element minOccurs=0 name=length type=xs:int / /xs:sequence /xs:complexType - xs:complexType name=Element - xs:sequence xs:element minOccurs=0 name=attributeNode nillable=true type=ax21:Attr / xs:element minOccurs=0 name=attributeNodeNS nillable=true type=ax21:Attr / xs:element minOccurs=0 name=schemaTypeInfo nillable=true type=ax21:TypeInfo / xs:element minOccurs=0 name=tagName nillable=true type=xs:string / /xs:sequence /xs:complexType - xs:complexType