×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Jan 2011
    Posts
    103

    Problem with xmlparsing through ksoup

    Hello,
    I am doing xmlparsing by using ksoap2.
    I had added ksoap2.jar file in my library.And done this coding:----
    **************************************************
    import java.io.IOException;
    import java.util.Vector;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import org.ksoap2.SoapEnvelope;
    import org.ksoap2.SoapFault;

    import org.ksoap2.serialization.SoapObject;
    import org.ksoap2.serialization.SoapSerializationEnvelope;
    import org.ksoap2.transport.HttpTransport;


    public class KsoapMidlet extends MIDlet {

    Display display;
    String strUserName= "Hello";
    String strPassword = "World";
    long ParentID;
    String ChildIMEINumber;
    String ChildName;
    String serviceUrl = "http://www.semaphore.co.in/ChildTrackerService/ChildTrackerService.asmx";
    String serviceNameSpace = "http://tempuri.org/";
    String soapAction ="http://tempuri.org/AddChild";
    String methodName = "AddChild";
    Vector v=new Vector();



    public void startApp() {
    display = Display.getDisplay(this);
    parsing();
    // v.addElement("Hello");
    // v.addElement("World");
    // Constants d=new Constants();
    // d.callSoap(methodName,v);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    }
    public void parsing(){
    SoapObject request = new SoapObject(serviceNameSpace,methodName);
    request.addProperty("strUserName", strUserName);
    request.addProperty("strPassword", strPassword);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    envelope.bodyOut = request;
    envelope.encodingStyle = SoapSerializationEnvelope.ENC;
    HttpTransport transport = new HttpTransport("http://www.semaphore.co.in/ChildTrackerService/ChildTrackerService.asmx");
    transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    transport.debug = true;
    String result = null;

    try {
    transport.call("http://tempuri.org/" + methodName, envelope);
    result = (envelope.getResponse()).toString();
    System.out.println("***********************result********************************");
    System.out.println("result=="+result);
    System.out.println("Result :" + result.toString());
    }
    catch (org.xmlpull.v1.XmlPullParserException ex2) {
    System.out.println("XmlPullParserException :" + ex2.toString());
    System.out.println("Request \n" + transport.requestDump);
    System.out.println("Response \n" + transport.responseDump);
    } catch (SoapFault sf) {
    System.out.println("SoapFault :" + sf.faultstring);
    System.out.println("Request \n" + transport.requestDump);
    System.out.println("Response \n" + transport.responseDump);
    } catch (IOException ioe) {
    System.out.println("IOException :" + ioe.toString());
    System.out.println("Request \n" + transport.requestDump);
    System.out.println("Response \n" + transport.responseDump);
    }
    }
    }


    But i am getting IO exception in line -----transport.call("http://tempuri.org/" + methodName, envelope);

    The error mesage is:--
    IOException :java.io.IOException: malformed header field <html>
    Request
    <?xml version="1.0" encoding="UTF-8"?><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><AddChild xmlns="http://tempuri.org/" id="o0" c:root="1"><strUserName i:type="d:string">Hello</strUserName><strPassword i:type="d:string">World</strPassword></AddChild></v:Body></v:Envelope>

    Response
    null




    Please help me.
    How can i solve this error.
    Where i am wrong.Please help me it is very urgent.

  2. #2
    Regular Contributor
    Join Date
    Jan 2011
    Posts
    103

    Re: Problem with xmlparsing through ksoup

    I got the solution of my problem.I was having proxy setting in my PC which was not allowing to communicate to the webservices.

    But now i am having on cofusion that can if i am doing pasring by using ksoap that whether it will support to the device having MIDP2.0 and CLDC 1.0.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    376

    Re: Problem with xmlparsing through ksoup

    If it works on simulator will surely work on mobiles .and if you want to make sure change the MIDP version and CLDC version in your configurations of j2me project and test it yourself

Similar Threads

  1. Problem with navigation through edit boxes
    By vdharankar in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-05-08, 20:56
  2. Socket Problem with IP Pass through
    By vipinbansal in forum Symbian
    Replies: 0
    Last Post: 2007-09-18, 07:24
  3. Problem in connection with web server through mobile
    By Hiteshkumar in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-07-20, 06:09
  4. Problem with sending SMS through J2ME
    By gtarmidi in forum Mobile Java General
    Replies: 2
    Last Post: 2007-04-30, 07:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×