Initializes a Microsoft.XMLHTTP request, and specifies the method, URL, and authentication information for the request. After calling this method you must call send to send the request and data (if any) to the server.
Visual Basic Syntax
oXMLHttpRequest.open(bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword)
C/C++ Syntax
HRESULT open(
BSTR bstrMethod,
BSTR bstrUrl,
VARIANT bAsync,
VARIANT bstrUser,
VARIANT bstrPassword);
Parameters
bstrMethod
[in]
HTTP method used to open the connection, such as PUT or PROPFIND.
bstrUrl
[in]
Requested URL. This must be an absolute URL, such as "http://Myserver/Mypath/".
bAsync
[in],
optional] Indicator as to whether the call is asynchronous. The default is true. This parameter must be a Boolean (true or false) expression.
bstrUser
[in],
optional] Name of the user for authentication. If this parameter is NULL ("") or missing and the site requires authentication, the component displays a logon window.
bstrPassword
[in],
optional] Password for authentication. This parameter is ignored if the user parameter is NULL or missing.
C/C++ Return Value
Returns S_OK if successful, or an error code otherwise.
Remarks
The values of the request headers, request body, response headers, and response body must be cleared before calling this method.
If the bAsync parameter is set to True, attach an onreadystatechange callback so you can tell when the send call has completed.
C/C++ Example
HRESULT hr;
IXMLHttpRequest *pIXMLHttpRequest = NULL;
try
{
// create XMLHttpRequest object and initialize pIXMLHttpRequest
hr = pIXMLHttpRequest->open(_bstr_t(_T("PUT")), _bstr_t(_T("http://MyServer/Sample.xml")), _variant_t(VARIANT_FALSE), _variant_t(""), _variant_t(""));
if(SUCCEEDED(hr))
::MessageBox(NULL, _T("Success !"), _T(""), MB_OK);
}
catch(...)
{
DisplayErrorToUser();
}
// Release pIXMLHttpRequest when done with it.
See Also