I'm struggle to solve the following problem.
I have a working JAX-WS service and I would like to access it from android emulator. After I done a research I decide it to use kSOAP2 package. I developed the client starting from some examples found it over the Internet (Temperature Converter I tested it on my emulator and worked fine). Here is a sniped form my client code:
- Code: Select all
final String SOAP_ACTION = "getMedia";
final String METHOD_NAME = "getMedia";
final String NAMESPACE = "http://my_name_space";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport ath = new AndroidHttpTransport(current);
try {
ath.call(SOAP_ACTION, envelope);
String soapRes = envelope.bodyIn.toString();
result.setText("RESULT: "+soapRes);
} catch (Exception e) {
// TODO: handle exception
result.setText("Error: " + e.getMessage());
The error that I got on the emulator is:
- Code: Select all
Expected: END_TAG{http://schemas.xmlsoap.org/soap/envelope/}Body:(position END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}S:Fault>@1:317 in java.io.nputStreamReader@43e59d78
The SOAP messages exchanged (captured using TCP Monitor from AXIS):
- Code: Select all
POST /ServFact/servFact HTTP/1.1
user-agent: kSOAP/2.0
soapaction: getMedia
content-type: text/xml
connection: close
content-length: 337
Host: 127.0.0.1:8081
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:getMedia id="o0" c:root="1" xmlns:n0="http://my_name_space/" />
</v:Body></v:Envelope>
=====RESPONSE========
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Fri, 01 Oct 2010 15:03:45 GMT
Connection: close
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>Cannot find dispatch method for {http://my_name_space/}getMedia</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
The log on the server side is:
- Code: Select all
Oct 1, 2010 4:03:45 PM com.sun.xml.ws.transport.http.HttpAdapter fixQuotesAroundSoapAction
WARNING: Received WS-I BP non-conformant Unquoted SoapAction HTTP header: getMedia
If I'm using the client made in Java for my service, everything works well. I notice a difference in the SOAP body request message:
- Code: Select all
==== Request ====
POST /ServFact/servFact HTTP/1.1
Content-type: text/xml;charset="utf-8"
Soapaction: "getMedia"
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.6 in JDK 6
Host: 127.0.0.1:8081
Connection: keep-alive
Content-Length: 116
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body></S:Body>
</S:Envelope>
comparably with the one send it by the kSOAP2 where I have:
- Code: Select all
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:getMedia id="o0" c:root="1" xmlns:n0="http://my_name_space/" />
</v:Body></v:Envelope>
The method that i need to invoke is called "getMedia()" with no arguments ant returns an ComplexType from a schema imported in WSDL.
Could someone give a hint how to solve this problem?
Looking forward to hearing from you soon!
Thank you!
-Daniel

