Kishanjvaghela / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Getting error when trying to call a method from a Web Service #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Host Web service on Glassfish
2. Created the code to send and receive the Soap Messages
public static final String SERVICE_NAMESPACE = "za.co.n7.mobilebackup";
public static final String SERVICE_URL = 
"http://ipaddress:8080/MobileBackupServiceImplService/MobileBackupServiceImpl/";
3.
final String METHOD_NAME = "Login";
    SoapObject results = null;
    SoapObject request = null;
    HttpTransportSE loginHttpTransport = null;
    try {
        request = new SoapObject(MBUtil.SERVICE_NAMESPACE, METHOD_NAME);
        request.addProperty("username", username);
        request.addProperty("password", MBUtil.hashPassword(password));

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.bodyOut=request;
        envelope.enc = SoapSerializationEnvelope.ENC;
        envelope.env="http://schemas.xmlsoap.org/soap/envelope/";

        // Web method call
        loginHttpTransport = new HttpTransportSE(MBUtil.SERVICE_URL);
        loginHttpTransport.debug = true;
        loginHttpTransport.call(MBUtil.SERVICE_URL + METHOD_NAME, envelope);

        results = (SoapObject) envelope.getResponse();

        System.out.println("Received Result without issue");

    } catch (Exception e) {
        e.printStackTrace();
        System.out.println(loginHttpTransport.requestDump);
        System.out.println(loginHttpTransport.responseDump);
    } finally {
        finish();
    }

What is the expected output? What do you see instead?
this is the Dump of the Soap Request
<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:Login id="o0" c:root="1" xmlns:n0="za.co.n7.mobilebackup">
         <username i:type="d:string">umohduke</username>
         <password i:type="d:string">c4066ed69b81d6b2b25f76405195c83ddaeecd8dbd3866f17912b895a72bc059</password>
      </n0:Login>
   </v:Body>
</v:Envelope>

It works fine on soap UI.
expected response is 
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:LoginResponse xmlns:ns2="za.co.n7.mobilebackup">
         <return>1</return>
      </ns2:LoginResponse>
   </S:Body>
</S:Envelope>

error Message i'm getting is
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT 
null@1:0 in   java.io.InputStreamReader@4056c7a8) 
at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1413)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
at za.co.n7.mobilebackup.LoginActivity.connect(LoginActivity.java:149)
at 
za.co.n7.mobilebackup.LoginActivity$DoLoginRequest.run(LoginActivity.java:116)
at android.os.Handler.handleCallback(Handler.java:587) at 
android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

What version of the product are you using? On what operating system?
2.6.2

Please provide any additional information below.
Please can anyne assist, i've only been using ksoap2 for a few hours. so I 
don't have a lot of experience with this.

Original issue reported on code.google.com by umohd...@gmail.com on 8 Apr 2012 at 4:53

GoogleCodeExporter commented 9 years ago
Operating system is windows 7

Original comment by umohd...@gmail.com on 8 Apr 2012 at 4:56

GoogleCodeExporter commented 9 years ago
Did you try to debug this and see what the response dump is? Looks like it 
might be null or so... see the wiki on how to debug.. 

Original comment by mosa...@gmail.com on 10 Apr 2012 at 3:48

GoogleCodeExporter commented 9 years ago
Most likely this is not an issue with ksoap2 at all but the implementers code.

Original comment by mosa...@gmail.com on 30 Apr 2012 at 7:31

GoogleCodeExporter commented 9 years ago
 SOAP version is the same VER11?

It worked for me.

Original comment by JHandal7@gmail.com on 13 Jun 2013 at 5:41