G
Guest
I have a url, I pass it to Webclient, and I get response without any problem.
String* uriString = S"trade7.masterlink.com.tw/futures/QuotePrice.jsp";
String* postData = S"";
// Create a new WebClient instance.
WebClient* myWebClient = new WebClient();
// Apply ASCII Encoding to obtain the String* as a Byte array.
Byte postArray[]= Encoding::ASCII->GetBytes(postData);
myWebClient->Headers->Add(S"Content-Type",
S"application/x-www-form-urlencoded");
//UploadData implicitly sets HTTP POST as the request method.
Byte responseArray[] = myWebClient->UploadData(uriString, postArray);
Now I pass the same string to HttpWebRequest. However, I do not get any
response
and get time-out exception. What is wrong with my HttpWebRequest call?
String* uriString = S"trade7.masterlink.com.tw/futures/QuotePrice.jsp";
HttpWebRequest *request = dynamic_cast<HttpWebRequest*>
(WebRequest::Create(uriString));
request->Method = "POST";
request->Credentials = CredentialCache:efaultCredentials;
request->ContentType = S"application/x-www-form-urlencoded";
HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());
// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();
Encoding* encode = System::Text::Encoding::GetEncoding(S"utf-8");
// Pipes the stream to a higher level stream reader with the required
encoding format.
StreamReader* readStream = new StreamReader(receiveStream, encode);
String* responseText = readStream->ReadToEnd();
response->Close();
String* uriString = S"trade7.masterlink.com.tw/futures/QuotePrice.jsp";
String* postData = S"";
// Create a new WebClient instance.
WebClient* myWebClient = new WebClient();
// Apply ASCII Encoding to obtain the String* as a Byte array.
Byte postArray[]= Encoding::ASCII->GetBytes(postData);
myWebClient->Headers->Add(S"Content-Type",
S"application/x-www-form-urlencoded");
//UploadData implicitly sets HTTP POST as the request method.
Byte responseArray[] = myWebClient->UploadData(uriString, postArray);
Now I pass the same string to HttpWebRequest. However, I do not get any
response
and get time-out exception. What is wrong with my HttpWebRequest call?
String* uriString = S"trade7.masterlink.com.tw/futures/QuotePrice.jsp";
HttpWebRequest *request = dynamic_cast<HttpWebRequest*>
(WebRequest::Create(uriString));
request->Method = "POST";
request->Credentials = CredentialCache:efaultCredentials;
request->ContentType = S"application/x-www-form-urlencoded";
HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());
// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();
Encoding* encode = System::Text::Encoding::GetEncoding(S"utf-8");
// Pipes the stream to a higher level stream reader with the required
encoding format.
StreamReader* readStream = new StreamReader(receiveStream, encode);
String* responseText = readStream->ReadToEnd();
response->Close();