kSOAP and JAXM

"Kelvin Zhengfang" <[email protected]> Thu, 23 Jan 2003 20:51:57 -0500
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
Hi,,,

I am a Master student of Systems Science at University of Ottawa, Canada.
I've met some problems when I am implmenting my thesis project about 
Wired/Wireless Web Services using Sun's JAX package and kSOAP.  

I am wodering if the kSOAP is compatible with the JAXM (Java API for XML 
Messaging)? I used the SoapObject to create a request SOAP message which 
is being sent to the Servlet by HttpTransport. But the Servlet seems not 
able to parse the SOAP message that created by the kSOAP's SOAPObject. 

The basic function of this Servlet is to parse the request SOAP message 
and get the information, then send back the response message. JAXM 
package (javax.xml.soap.*) is used here to generate the request 
SOAPMessage instance (javax.xml.soap.SOAPMessage) based on the 
HttpServletRequest, which acts as an InputStream, then some methods like 
getSOAPPart(),getEnvelope() or getBody() could be used to retrieve the 
desired data. Everything is fine in the environment of J2EE, in which 
the request SOAP message is created by JAXM iteself at the client 
request program and the SOAP message is regenerated correctly at the 
server side by JAXM. But when I use HttpTransport to send the SOAP 
message in J2ME environment, the "Null" exception always pops up. I 
traced the program, surprisingly the SOAP message is created by the 
HttpServletRequest, the whole XML structure looks so well, but the SOAP 
body cannot be retrieved by the methods of msg.getSOAPPart().getEnvelope
().getBody(). Here are the SOAP messages got at the server side:

SOAP message by JAXM:

<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-
env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
	<RequestCourses:request-courses 
xmlns:RequestCourses="http://www.uottawa.ca">
		<category>1</category>
		<username>kelvin</username>
	</RequestCourses:request-courses>
</soap-env:Body>
</soap-env:Envelope>

SOAP message created by kSOAP's SoapObject:

<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-
env="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:RequestCourses="www.uottawa.ca" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <soap-env:Body SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <RequestCourses:request-courses id="o0" SOAP-ENC:root="1">
   <category xsi:type="xsd:string">1</category>
   <username xsi:type="xsd:string">kelvin</username>
  </RequestCourses:request-courses>
 </soap-env:Body>
</soap-env:Envelope>

The XML structure is same except some namespaces. As I know the 
namespace for type (xsi:type) is only for the match between SOAP and 
Java types at client side. It should not affect the parsing at the 
server side. Am I right?

If the problem is stubborn...the possible solution for me is to use SAX 
or DOM to parse the request SAOP message insteading of using JAXM. But I 
still hope some hints about that problem for a better solution.

Thanks, Regards

Kelvin Xu

@Multimedia Communication Reserach Lab