void HttpRequestHelper::GetContent(void) { AppLog("GetContent."); result r = E_SUCCESS; HttpSession* pSession = null; HttpTransaction* pTransaction = null; String hostAddr(L"http://www.somesite.com"); pSession = new HttpSession(); r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null); pTransaction = pSession->OpenTransactionN(); r = pTransaction->AddHttpTransactionListener(*this); // Get the request instance. HttpRequest* pRequest = pTransaction->GetRequest(); // Set the uri. r = pRequest->SetUri(L"http://www.somesite.com/do"); // Set the method. NetHttpMethod method = NET_HTTP_METHOD_POST; r = pRequest->SetMethod(method); String sessionKey = ""; const char* pBodyArray = "<body><getContent><sid></sid></getContent></body>"; HttpHeader* pHeader = null; pHeader = pRequest->GetHeader(); // Add the content-length to header. r = pHeader->AddField(L"Content-Type", L"application/xml"); r = pHeader->AddField(L"User-Agent", L"SomeUserAgent=="); r = pHeader->AddField(L"Accept", L"text/xml"); int len = strlen(pBodyArray); String contentLength = Integer::ToString(len); String msg1 = "contentLength : " + contentLength; AppLog("%ls", msg1.GetPointer()); r = pHeader->AddField(L"Content-Length", contentLength); r = pHeader->AddField(L"Transfer-Encoding", L"chunked"); pTransaction->EnableTransactionReadyToWrite(); ByteBuffer reqBody; reqBody.Construct(len); reqBody.SetArray((byte*)pBodyArray, 0, len); reqBody.Flip(); pRequest->WriteBody(reqBody); AppLog("Submitting."); pTransaction->Submit(); } void HttpRequestHelper::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen){ AppLog("OnTransactionReadyToRead"); } void HttpRequestHelper::OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r){ AppLog("OnTransactionAborted(%s)", GetErrorMessage(r)); delete &httpTransaction; } void HttpRequestHelper::OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize){ AppLog("OnTransactionReadyToWrite"); } void HttpRequestHelper::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool bAuthRequired){ AppLog("OnTransactionHeaderCompleted"); } void HttpRequestHelper::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction){ AppLog("OnTransactionCompleted"); delete &httpTransaction; } void HttpRequestHelper::OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::String* pCert){ AppLog("OnTransactionCertVerificationRequiredN"); httpTransaction.Resume(); delete pCert; } bool HttpRequestHelper::OnTransactionCertVerificationRequestedN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::Collection::IList* pCertList){ AppLog("OnTransactionCertVerificationRequestedN"); return true; }
Hello there,
I've started development with Tizen recently, and i am trying to consume a Web Service that returns XML content.
I was able to construct the POST HttpRequest and call it successfully (Wireshark shows the request and the response correctly). However, something goes wrong when the IHttpTransactionEventListener event are being called (im guessing....), because in the stack strace the last log is something like :
Tizen::Base::Runtime::_Event::ProcessListeners(std::tr1::shared_ptr<Tizen::Base::Runtime::IEventArg>) + 0x41a (0xb460286a) [/usr/lib/osp/libosp-appfw.so] + 0x1b386a
I am using the emulator.
Also, no Callback events from IHttpTransactionEventListener are being called.
Can someone help me out with this? Has anyone had the same problem?
Many Thanks
Nuno