Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor akki123's Avatar
    Join Date
    Jul 2012
    Posts
    82
    Hi,

    I am new Symbian.

    I have to send a XML File to the server .

    <root>
    <h>
    <msgt>restore</msgt>
    <msg/>
    <uid>919560922700</uid>
    <hp>919560922700</hp>
    <did>1908692458</did>
    <currec>1</currec>
    <totrec>1</totrec>
    <loc>en_us</loc>
    <ctime>1340189529699</ctime>
    <lstime>1340189528844</lstime>
    <synctype>
    <mod>cs</mod>
    <gran>contactlevel</gran>
    <adde>true</adde>
    <upde>true</upde>
    <dele>true</dele>
    </synctype>
    </h>
    <b>
    <hp>919560922700</hp>
    <username>919560922700</username>
    <password>474747</password>
    <phone_model>BlackBerry9300</phone_model>
    </b>
    </root>

    and Response xml from server is: -->

    <restore>OK</restore>


    i tried it by :-->


    HBufC8* iRegBuffer = HBufC8::NewL(1024);
    HBufC* ptr1 = HBufC::NewL(30);
    TPtr time = ptr1->Des();
    iConnectionStatus = 2;
    iRegBuffer->Des().Copy(_L("<root>"));
    //TBuf<30> tempbuf1;
    //tempbuf1->Des().Copy(_L("restore"));
    iRegBuffer->Des().Append(_L("restore"));
    //CreateHeaderXML(tempbuf1);
    iRegBuffer->Des().Append(_L("<h>"));
    iRegBuffer->Des().Append(_L("<msgt>"));
    //iRegBuffer.Append(msgType);
    iRegBuffer->Des().Append(_L("</msgt>"));
    iRegBuffer->Des().Append(_L("<uid>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</uid>"));
    iRegBuffer->Des().Append(_L("<hp>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</hp>"));
    iRegBuffer->Des().Append(_L("<did>"));
    iRegBuffer->Des().Append(PhoneImei());
    iRegBuffer->Des().Append(_L("</did>"));
    iRegBuffer->Des().Append(_L("<currec>"));
    iRegBuffer->Des().Append(1);
    iRegBuffer->Des().Append(_L("</currec>"));
    iRegBuffer->Des().Append(_L("<totrec>"));
    iRegBuffer->Des().Append(1);
    iRegBuffer->Des().Append(_L("</totrec>"));
    iRegBuffer->Des().Append(_L("loc>en_us</loc"));
    iRegBuffer->Des().Append(_L("<ctime>"));
    iRegBuffer->Des().Append(*currTime);
    iRegBuffer->Des().Append(_L("</ctime>"));
    iRegBuffer->Des().Append(_L("<lstime>"));
    GetSubStatusSyncTime(time);
    iRegBuffer->Des().Append(time);
    iRegBuffer->Des().Append(_L("</lstime>"));
    iRegBuffer->Des().Append(_L("<synctype><mod>cs</mod><gran>contactlevel</gran>\
    <adde>true</adde><upde>true</upde><dele>true</dele></synctype>"));
    iRegBuffer->Des().Append(_L("</h>"));
    iRegBuffer->Des().Append(_L("<b>"));
    iRegBuffer->Des().Append(_L("<hp>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</hp>"));
    iRegBuffer->Des().Append(_L("<username>"));
    iRegBuffer->Des().Append(iUserNames);
    iRegBuffer->Des().Append(_L("</username>"));
    iRegBuffer->Des().Append(_L("<password>"));
    iRegBuffer->Des().Append(iPassword);
    iRegBuffer->Des().Append(_L("</password>"));
    iRegBuffer->Des().Append(_L("<phone_model>"));
    iRegBuffer->Des().Append(iAxiomPhoneModel);
    iRegBuffer->Des().Append(_L("</phone_model>"));
    iRegBuffer->Des().Append(_L("</b>"));
    iRegBuffer->Des().Append(_L("</root>"));
    servlet_data = iRegBuffer;


    Is there any issue in this format. i am unable to sending it to the server.
    Please suggest for the same . How we will get the response from the server .

    Thanks in advance .

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,667
    You could simply write the stuff into a debug-file to see what's in there in the end.

    Anyway, you should really describe the problem, and also mention which API is giving the problem, and also the code segment that the problem is effecting to.

  3. #3
    Regular Contributor akki123's Avatar
    Join Date
    Jul 2012
    Posts
    82
    i am trying to send the mentioned xml file to the server using

    if(iSocketWriterContactsStatus == NULL)
    {

    TRAPD(socketerr, iSocketWriterContactsStatus = CSocketsEngineWriter::NewL(*this));
    if(socketerr == KErrNoMemory)
    User::Exit(KErrNoMemory);

    if(iSocketWriterContactsStatus != NULL)
    {
    iSocketWriterContactsStatus->SetServerName(iServerAddr);
    iSocketWriterContactsStatus->SetPort(iPort);
    iSocketWriterContactsStatus->iBuffer.FillZ();
    iSocketWriterContactsStatus->iSendBuffer.FillZ();
    iSocketWriterContactsStatus->iBuffer.Copy(*servlet_data);
    iSocketWriterContactsStatus->iSendBuffer.Copy(*servlet_data);
    ConnectToServer();
    delete servlet_data;
    servlet_data = NULL;
    }
    }

    But not able to send the same.
    Not able to establish the connection with the server .

  4. #4
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,667
    then you should check what happens inside the CSocketsEngineWriter.

    Anyway, any good reason you have not considered on using HTTP API ?

  5. #5
    Regular Contributor akki123's Avatar
    Join Date
    Jul 2012
    Posts
    82
    Quote Originally Posted by symbianyucca View Post
    then you should check what happens inside the CSocketsEngineWriter.

    Anyway, any good reason you have not considered on using HTTP API ?

    . Please suggest a link to the example of the same.
    Last edited by akki123; 2012-08-22 at 11:22.

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    If you already have a working server and it is not HTTP, you may want to think that switch again.

    However your code
    iRegBuffer->Des().Copy(_L("<root>"));
    //TBuf<30> tempbuf1;
    //tempbuf1->Des().Copy(_L("restore"));
    iRegBuffer->Des().Append(_L("restore"));
    //CreateHeaderXML(tempbuf1);
    iRegBuffer->Des().Append(_L("<h>"));
    iRegBuffer->Des().Append(_L("<msgt>"));
    //iRegBuffer.Append(msgType);
    iRegBuffer->Des().Append(_L("</msgt>"));
    certainly results in different XML than what you need.

    Just read it line-by-line:
    iRegBuffer->Des().Copy(_L("<root>"));
    <root>
    //TBuf<30> tempbuf1;
    //tempbuf1->Des().Copy(_L("restore"));
    these were comments, the content is still <root>
    iRegBuffer->Des().Append(_L("restore"));
    restore is appended, so it is <root>restore now
    //CreateHeaderXML(tempbuf1);
    comment, the content is unchanged, <root>restore
    iRegBuffer->Des().Append(_L("<h>"));
    <h> is appended, the content is <root>restore<h> now
    iRegBuffer->Des().Append(_L("<msgt>"));
    <msgt> is appended, the content becomes <root>restore<h><msgt>
    //iRegBuffer.Append(msgType);
    comment, the content remains <root>restore<h><msgt>
    iRegBuffer->Des().Append(_L("</msgt>"));
    </msgt> is appended, the content is <root>restore<h><msgt></msgt> here.

    Writing in a similar style as your example:
    <root>
    restore
    <h>
    <msgt></msgt>

    I hope you can see the difference. It was 5 minutes to write this post, and you do not even have to write it just read your code and check against the expected output.
    Last edited by wizard_hu_; 2012-08-22 at 12:30. Reason: replaced an &lt;

  7. #7
    Regular Contributor akki123's Avatar
    Join Date
    Jul 2012
    Posts
    82
    Thank you for the suggestion.

    Please suggest the link of example for the same. I have modified my xml file now it is like -

    HBufC* currTime = NULL;
    TTime ctime;
    ctime.HomeTime();
    currTime = GetTimeStamp(ctime);
    HBufC8* iRegBuffer = HBufC8::NewL(1024);
    HBufC* ptr1 = HBufC::NewL(30);
    TPtr time = ptr1->Des();
    iConnectionStatus = 2;
    iRegBuffer->Des().Copy(_L("<root>"));
    iRegBuffer->Des().Append(_L("<h>"));
    iRegBuffer->Des().Append(_L("<msgt>"));
    iRegBuffer->Des().Append(_L("restore"));
    iRegBuffer->Des().Append(_L("</msgt>"));
    iRegBuffer->Des().Append(_L("<msg/>"));
    iRegBuffer->Des().Append(_L("<uid>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</uid>"));
    iRegBuffer->Des().Append(_L("<hp>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</hp>"));
    iRegBuffer->Des().Append(_L("<did>"));
    iRegBuffer->Des().Append(PhoneImei());
    iRegBuffer->Des().Append(_L("</did>"));
    iRegBuffer->Des().Append(_L("<currec>"));
    iRegBuffer->Des().Append(1);
    iRegBuffer->Des().Append(_L("</currec>"));
    iRegBuffer->Des().Append(_L("<totrec>"));
    iRegBuffer->Des().Append(1);
    iRegBuffer->Des().Append(_L("</totrec>"));
    iRegBuffer->Des().Append(_L("loc>en_us</loc"));
    iRegBuffer->Des().Append(_L("<ctime>"));
    iRegBuffer->Des().Append(*currTime);
    iRegBuffer->Des().Append(_L("</ctime>"));
    iRegBuffer->Des().Append(_L("<lstime>"));
    GetSubStatusSyncTime(time);
    iRegBuffer->Des().Append(time);
    iRegBuffer->Des().Append(_L("</lstime>"));
    iRegBuffer->Des().Append(_L("<synctype><mod>cs</mod><gran>contactlevel</gran>\
    <adde>true</adde><upde>true</upde><dele>true</dele></synctype>"));
    iRegBuffer->Des().Append(_L("</h>"));
    iRegBuffer->Des().Append(_L("<b>"));
    iRegBuffer->Des().Append(_L("<hp>"));
    iRegBuffer->Des().Append(iMobileNo);
    iRegBuffer->Des().Append(_L("</hp>"));
    iRegBuffer->Des().Append(_L("<username>"));
    iRegBuffer->Des().Append(iUserNames);
    iRegBuffer->Des().Append(_L("</username>"));
    iRegBuffer->Des().Append(_L("<password>"));
    iRegBuffer->Des().Append(iPassword);
    iRegBuffer->Des().Append(_L("</password>"));
    iRegBuffer->Des().Append(_L("<phone_model>"));
    iRegBuffer->Des().Append(iAxiomPhoneModel);
    iRegBuffer->Des().Append(_L("</phone_model>"));
    iRegBuffer->Des().Append(_L("</b>"));
    iRegBuffer->Des().Append(_L("</root>"));
    servlet_data = iRegBuffer;
    Last edited by wizard_hu_; 2012-08-22 at 12:29. Reason: oops, nothing

  8. #8
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,667
    Wizard is right, if you have socket server listening in your server, then you would need to go with the RSocket based implementation, and you would need to check what inside the CSocketsEngineWriter is going on, and what is failing there.

    incase you don't know how your server is implemented, I would suggest checking that out first.

  9. #9
    Regular Contributor akki123's Avatar
    Join Date
    Jul 2012
    Posts
    82
    Quote Originally Posted by symbianyucca View Post
    Wizard is right, if you have socket server listening in your server, then you would need to go with the RSocket based implementation, and you would need to check what inside the CSocketsEngineWriter is going on, and what is failing there.

    incase you don't know how your server is implemented, I would suggest checking that out first.


    Ok thank you for the suggestion

Similar Threads

  1. Sending File to Server using HttpConnection
    By sandeepkumar03 in forum Mobile Java Networking & Messaging & Security
    Replies: 12
    Last Post: 2009-11-26, 13:55
  2. Sending information from file to a server?
    By SanjayKhuntia in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2008-08-25, 15:59
  3. Sending XML file from server to mobile
    By bvsbh in forum Mobile Java General
    Replies: 1
    Last Post: 2005-11-30, 14:21
  4. sending a file to server
    By faisalahmedkhan in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-02-09, 13:57
  5. Sending a File to a Server
    By Fencer04 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-12-04, 15:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved