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://XXXX.com"; xmlns="http://www.w3.org/2001/XMLSchema";>
        <element name="read" type="xsd:anyType" />
    </schema>
<schema targetNamespace="http://XXXX.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://XXXX.com/schema";> <xsd:import namespace="http://XXXX.com/schema/XXXX"; schemaLocation="XXXXX.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="XXXXXXPortType">
       <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:[email protected]
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

Reply via email to