怎样实现一个在第2版和第三版上可用的Http post架构,我现在的想法是要实现一个请求WebService服务的功能,将XML数据直接POST到服务器,,请提供援助。。
------解决方案--------------------------------------------------------
楼主你好:
1、你有《Series 60应用程序开发》这本书么?
有的话,在书的第十章(Post具体是在375页)又讲这个的;
2、有一个HTTP客户端的示例代码:
http://www.forum.nokia.com/info/sw.nokia.com/id/6ae1a078-1545-4c2c-b98f-68366474aa6d/S60_Platform_HTTP_Client_API_Example_v2_1_en.zip
你可以参考一下;
不好意思的说,我就用过Get,Post我没有用过,希望上面的东西能对你有用。
------解决方案--------------------------------------------------------
可以参考一下blog:http://blog.csdn.net/Eddy_0825/archive/2007/05/10/1603270.aspx#794800
------解决方案--------------------------------------------------------
/**
*
* @brief Definition of CHTTPExampleEngine
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "HTTPExampleEngine.h"
// System includes
#include <chttpformencoder.h> // CHTTPFormEncoder
#include <httpstringconstants.h> // HTTP string table
#include <rhttpheaders.h> // RHTTPHeaders
// User includes
#include "HTTPExample.hrh" // EMaxNameLength
// CONSTANTS
// HTTP header values
_LIT8(KUserAgent, "HTTPExample (1.0)"); // Name of this client app
_LIT8(KAccept, "text/*"); // Accept any (but only) text content
_LIT8(KPostParamName, "NAME"); // Name of the parameter sent in a POST request
_LIT8(KPostContentType, "text/plain"); // Content type sent in a POST request
// URL for POST request.
//_LIT8(KPostUri, "http://cgi.www.emccsoft.com/cgi-bin/www.emccsoft.com/post.pl");
_LIT8(KPostUri, "http://www.magpiemobile.com/cgi-bin/book_post.cgi");
// ================= MEMBER FUNCTIONS =======================
/**
* 2-phase constructor
*
* @param aObserver An observer of this engine (e.g. the UI)
*/
CHTTPExampleEngine* CHTTPExampleEngine::NewL(MHTTPExampleEngineObserver& aObserver)
{
CHTTPExampleEngine* self = new (ELeave) CHTTPExampleEngine(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
/**
* C++ constructor
*
* @param aObserver An observer of this engine (e.g. the UI)
*/
CHTTPExampleEngine::CHTTPExampleEngine(MHTTPExampleEngineObserver& aObserver)
: iObserver(aObserver)
{
}
/**
* 2nd-phase constructor
*/
void CHTTPExampleEngine::ConstructL()
{
// Open the RHTTPSession
iSession.OpenL();
// Construct the form encoder
iFormEncoder = CHTTPFormEncoder::NewL();
}
/**
* C++ destructor
*/
CHTTPExampleEngine::~CHTTPExampleEngine()
{
// Close session
iSession.Close(); // Will also close any open transactions
delete iResponseBuffer;
delete iFormEncoder;
delete iUri;
}
/**
* Override of pure virtual method in MHTTPTransactionCallback.
* Called to report progress by a currently outstanding transaction.
*
* @param aTransaction The transaction reporting progress
* @param aEvent The event being notified
*/
void CHTTPExampleEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{
// HTTP response headers have been received.
// Pass status information to observer.
RHTTPResponse resp = aTransaction.Response();
// Get status code
TInt statusCode = resp.StatusCode();
// Get status text
RStringF statusStr = resp.StatusText();
HBufC* statusBuf = HBufC::NewLC(statusStr.DesC().Length());