×

Discussion Board

Results 1 to 5 of 5

Thread: KXML2 problem

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    6

    KXML2 problem

    Hey,

    I have a problem with Kxml2. I hope someone is able to help me.

    In my application it is nescessary to first send an XML (actually SOAP) message and after that, parse the result. The code I use for this is given just below. This works all great...

    Code:
    httpConn = (HttpConnection)Connector.open(url);
    
    httpConn.setRequestMethod(HttpConnection.POST);
           
    httpConn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
    
    outputstream = httpConn.openOutputStream();
    
    //**Blablabla some XML in string "WalletCard" :-)
    
    outputstream.write(WalletCard.getBytes());
    
    KXmlParser Walletparser = new KXmlParser();
    
    Walletparser.setInput(new InputStreamReader(httpConn.openInputStream()));
    
    //**Here comes the actual parsing
    But now I need to do a "Rollback" to the webservice. Therefore I need to send a second XML file in the same HTTP session (because I need to send back the session number for security). Just setting up a new output stream using the same parser results in the error 'already reached end of document'. Using a new parser results in the error 'connection already open'...

    Does anyone has an idea?

    Thanks!

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: KXML2 problem

    Hi,
    Quote Originally Posted by Thomassius View Post
    Hey,

    I have a problem with Kxml2. I hope someone is able to help me.

    In my application it is nescessary to first send an XML (actually SOAP) message and after that, parse the result. The code I use for this is given just below. This works all great...

    Code:
    httpConn = (HttpConnection)Connector.open(url);
    
    httpConn.setRequestMethod(HttpConnection.POST);
           
    httpConn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
    
    outputstream = httpConn.openOutputStream();
    
    //**Blablabla some XML in string "WalletCard" :-)
    
    outputstream.write(WalletCard.getBytes());
    
    KXmlParser Walletparser = new KXmlParser();
    
    Walletparser.setInput(new InputStreamReader(httpConn.openInputStream()));
    
    //**Here comes the actual parsing
    But now I need to do a "Rollback" to the webservice. Therefore I need to send a second XML file in the same HTTP session (because I need to send back the session number for security). Just setting up a new output stream using the same parser results in the error 'already reached end of document'. Using a new parser results in the error 'connection already open'...

    Does anyone has an idea?

    Thanks!
    u can flush the streams after writing and reading and then repeat the process. Also u can close the streams after one cycle get complete and then repeat the process with the same connection. But its depend at the server side that after uploading the next file what process they follow. Whether they overwrite the data or they append the data to the prvious one.
    Well u have to confirm from the server side that what process thay follow.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  3. #3
    Super Contributor
    Join Date
    Jun 2007
    Location
    Mumbai
    Posts
    539

    Re: KXML2 problem

    Hi, See u can't read InputStream which is already read once. And tell me how is going to identify that ur second xml is comming? one way is u set an identification message between two xmls, and u dont give the input stream directly to parser better read it in a byte[] array and use it.. once u get ur identification message fro second xml read input stream into another byte[] now u have diff byte[] for different xmls. and both u can parse individually by creating inputstream from byte[].
    au revoir
    Prakash Raman

  4. #4
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: KXML2 problem

    Hi Thomassius,
    You can do like this , When you open a connection to the server at first time , get the http session value from the header and store it some ware and for rest of the request you explicitily set the session value with httpConn.setRequestProperty("Session:" , "value");

  5. #5
    Registered User
    Join Date
    Nov 2008
    Posts
    6

    Re: KXML2 problem

    Quote Originally Posted by bhanuchandar.k View Post
    Hi Thomassius,
    You can do like this , When you open a connection to the server at first time , get the http session value from the header and store it some ware and for rest of the request you explicitily set the session value with httpConn.setRequestProperty("Session:" , "value");

    To end this thread, the right answer can be found at this location:

    http://developers.sun.com/mobility/m...cles/sessions/

    And thanks all for the help! Spacially bhanuchandar.k for pointing me the best direction!

Similar Threads

  1. Problem with CAknDoubleStyleListBox with a CAknSearchField
    By jjig in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-09-17, 00:58
  2. SyncML link problem
    By samuel_ in forum Symbian C++
    Replies: 4
    Last Post: 2009-03-27, 08:02
  3. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36
  5. problem kxml, kxml2 class not found
    By kmsoomro in forum Mobile Java General
    Replies: 0
    Last Post: 2005-02-22, 08:55

Posting Permissions

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