Open Method (IXMLHTTPRequest2, Windows 8)

 

Initializes an IXMLHTTPRequest2 request and specifies the method, URL, and authentication information for the request.

C/C++ Syntax

HRESULT Open(const WCHAR *pwszMethod,  
const WCHAR *pwszUrl,   
IXMLHTTPRequest2Callback *pStatusCallback,  
const WCHAR *pwszUserName,  
const WCHAR *pwszPassword,  
const WCHAR *pwszProxyUserName,  
const WCHAR *pwszProxyPassword  
);  

Parameters

pwszMethod[in, string, ref]
The HTTP method used to open the connection, such as GET or POST.

pwszUrl[in, string, ref]
The requested URL. This can be either an absolute URL, such as "http://Myserver/Mypath/Myfile.asp".

pStatusCallback[in]
A callback function that is called when a callback event occurs.

pwszUserName[in, string, unique]
The name of the user for authentication. If this parameter is Null and the site requires authentication, the component displays a logon window unless the SetProperty method has been called to disable user input prompts, authentication, or both.

pwszPassword[in, string, unique]
The password for authentication. This parameter is ignored if the pwszUserName parameter is Null or missing.

pwszProxyUserName[in, string, unique]
The name of the user for authentication to the proxy server. If this parameter is Null and the proxy server requires authentication, the component displays a logon window unless the SetProperty method has been called to disable user input prompts, authentication, or both.

pwszProxyPassword[in, string, unique]
The password for authentication to the proxy server. This parameter is ignored if the pwszProxyUserName parameter is Null or missing.

Return Values

S_OK
The value returned if successful.

Example

HRESULT hr;
IXMLHttpRequest *pIXMLHttpRequest = NULL;

try
{
   // Create XMLHttpRequest object and initialize pIXMLHttpRequest.
   hr = pIXMLHttpRequest->open(_bstr_t(_T("PUT")), 
      _bstr_t(_T("GET","http://MyServer/Sample.xml", false)), 
      _variant_t(VARIANT_FALSE), _variant_t(""), _variant_t(""));
   if(SUCCEEDED(hr))
      ::MessageBox(NULL, _T("Success !"), _T(""), MB_OK);
}
catch(...)
{
   DisplayErrorToUser();
}
// Release pIXMLHttpRequest when finished with it.

Remarks

After calling this method, you must call Send to send the request and data, if any, to the server.

Note

Although this method accepts credentials passed via parameter, those credentials are not automatically sent to the server on the first request. The pwszUserName and pwszPassword parameters are not sent to the server unless the server challenges the client for credentials with a 401 - Access Denied response.

Versioning

Implemented in: MSXML 6.0

See Also

Abort Method (IXMLHTTPRequest2, Windows 8)
Send Method (IXMLHTTPRequest2, Windows 8)
SetProperty Method (Windows 8, C++)
IXMLHTTPRequest2 (Windows 8)