Hi,
I have a web service class as shown below.
import org.w3c.dom.Document;
public class EchoXml {
public Document echo(Document xml) {
return xml;
}
}
*I will not be able to modify this class by using OMElement instead of
Document. I have to use the class in this format only.*
When the service is deployed, it has generated the WSDL with schema
generated for the Document also.
<xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified"
targetNamespace="http://ws.apache.org/axis2">
<xs:import namespace="http://dom.w3c.org/xsd"/>
<xs:element name="echo">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="xml" nillable="true"
type="ax24:Document"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="echoResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true"
type="ax24:Document"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified"
targetNamespace="http://dom.w3c.org/xsd">
<xs:complexType name="Document">
<xs:sequence>
<xs:element minOccurs="0" name="doctype" nillable="true"
type="ax23:DocumentType"/>
<xs:element minOccurs="0" name="documentElement" nillable="true"
type="ax23:Element"/>
<xs:element minOccurs="0" name="documentURI" nillable="true"
type="xs:string"/>
<xs:element minOccurs="0" name="domConfig" nillable="true"
type="ax23:DOMConfiguration"/>
<xs:element minOccurs="0" name="implementation" nillable="true"
type="ax23:DOMImplementation"/>
<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="ax23: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="ax23: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:sequence>
</xs:complexType>
<xs:complexType name="Element">
<xs:sequence>
<xs:element minOccurs="0" name="schemaTypeInfo" nillable="true"
type="ax23:TypeInfo"/>
<xs:element minOccurs="0" name="tagName" nillable="true"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TypeInfo">
<xs:sequence>
<xs:element minOccurs="0" name="typeName" nillable="true"
type="xs:string"/>
<xs:element minOccurs="0" name="typeNamespace" nillable="true"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DOMConfiguration">
<xs:sequence>
<xs:element minOccurs="0" name="parameterNames" nillable="true"
type="ax23:DOMStringList"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DOMStringList">
<xs:sequence>
<xs:element minOccurs="0" name="length" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DOMImplementation">
<xs:sequence/>
</xs:complexType>
</xs:schema>
I generated the stub using WSDL2Java utility as shown below
public static void main(String[] args) throws Exception {
WSDL2Java.main(new String[] { "-uri",
"http://localhost:8080/axis2/services/EchoXml?wsdl", "-o",
".",
"-uw" });
It generated stub. But the stub,echo() method is taking a
org.apache.ws.axis2.EchoXmlStub.Document instance. Actually in the client
side, I have an org.w3c.Document instance.
I tried to generate the org.apache.ws.axis2.EchoXmlStub.Document instance
from org.w3c.Document object.
org.w3c.dom.Document inputDoc = getDocument();
OMElement om = XMLUtils.toOM(inputDoc.getDocumentElement());
System.out.println(om);
EchoXmlStub stub = new EchoXmlStub();
Document xml = Document.Factory.parse(om.getXMLStreamReader());
Document echo = stub.echo(xml);
But it is not working.
I tried the same service in Axis 1. There the WSDL generated is different.
The return type is *apachesoap:Document*. And it is working fine.
<schema elementFormDefault="qualified" targetNamespace="
http://DefaultNamespace">
<import namespace="http://xml.apache.org/xml-soap"/>
<import namespace="http://rpc.xml.coldfusion"/>
<element name="echoXml">
<complexType>
<sequence>
<element name="argXml" type="apachesoap:Document"/>
</sequence>
</complexType>
</element>
<element name="echoXmlResponse">
<complexType>
<sequence>
<element name="echoXmlReturn" type="apachesoap:Document"/>
</sequence>
</complexType>
</element>
<element name="fault" type="tns1:CFCInvocationException"/>
</schema>
Is there anyway, I can use apachesoap:Document instead of axis 2 trying to
figure out the schema by introspecting the Document class?
Any idea how I could use org.w3c.Document object for the service?
Please help..
Thanks in advance.
Paul