Initializes a request and specifies the method, URL, and authentication information for the request.
JScript Syntax
oServerXMLHTTPRequest.open(bstrMethod, bstrUrl, bAsync, bstrUser,
bstrPassword);
Parameters
- bstrMethod
-
The HTTP method used to open the connection, such as PUT or PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the method name must be entered in all upper-case letters.
- bstrUrl
-
The requested URL. This can be either an absolute URL, such as "http://Myserver/Mypath/Myfile.asp", or a relative URL, such as "../MyPath/MyFile.asp".
- bAsync(optional)
-
Boolean. Indicator as to whether the call is asynchronous. The default is False (the call does not return immediately).
- bstrUser(optional)
-
The name of the user for authentication.
- bstrPassword(optional)
-
The password for authentication. This parameter is ignored if the user parameter is Null or missing.
Example
The following JScript example creates an XMLHTTP object, and then uses the open method to get a copy of books.xml at the IIS Web server running locally. The code then selects the author and title information for the <book id="bk101"> element to display as output.
<%@language=JScript%>
<%
var srvXmlHttp
srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0");
srvXmlHttp.open ("GET", "http://localhost/books.xml", false);
srvXmlHttp.send();
var catalog = srvXmlHttp.responseXML;
var author = catalog.selectSingleNode("//book[@id='bk101']/author");
var title = catalog.selectSingleNode("//book[@id='bk101']/title");
%>
<html>
<body>
<pre><code>
<%Response.Write("<p>BOOK SEARCH RESULTS:</p>");%>
<%Response.Write("Author: " + author.text + "<br>");%>
<%Response.Write("Title: " + title.text + "<br>");%>
</code></pre>
</body>
</html>
Visual Basic Syntax
oServerXMLHTTPRequest.open(bstrMethod, bstrUrl, bAsync, bstrUser,
bstrPassword)
Parameters
- bstrMethod
-
The HTTP method used to open the connection, such as PUT or PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the method name must be entered in all upper-case letters.
- bstrUrl
-
The requested URL. This can be either an absolute URL, such as "http://Myserver/Mypath/Myfile.asp", or a relative URL, such as "../MyPath/MyFile.asp".
- bAsync(optional)
-
Boolean. Indicator as to whether the call is asynchronous. The default is False (the call does not return immediately).
- bstrUser(optional)
-
The 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(optional)
-
The password for authentication. This parameter is ignored if the user parameter is Null or missing.
Example
The following Visual Basic example creates an XMLHTTP object, and then uses the open method to get a copy of books.xml at the IIS Web server running locally. The code then selects the author and title information for the <book id="bk101"> element to display as output.
Dim xmlHttp As New ServerXMLHTTP30
Dim catalog As IXMLDOMNode
Dim author As IXMLDOMNode
Dim title As IXMLDOMNode
Dim sOutput As String
xmlHttp.open "GET", "http://localhost/books.xml", False
xmlHttp.send
Set catalog = xmlHttp.responseXML
Set author = catalog.selectSingleNode("//book[@id='bk101']/author")
Set title = catalog.selectSingleNode("//book[@id='bk101']/title")
sOutput = "BOOK SEARCH RESULTS" & vbCrLf & _
"Author:" & vbTab & author.Text & vbCrLf & _
" Title:" & vbTab & title.Text & vbCrLf
MsgBox sOutput
C/C++ Syntax
HRESULT open(BSTR bstrMethod, BSTR bstrUrl, VARIANT bAsync,
VARIANT bstrUser, VARIANT bstrPassword);
Parameters
- bstrMethod[in]
-
The HTTP method used to open the connection, such as PUT or PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the method name must be entered in all upper-case letters.
- bstrUrl[in]
-
The requested URL. This can be either an absolute URL, such as "http://Myserver/Mypath/Myfile.asp", or a relative URL, such as "../MyPath/MyFile.asp".
- bAsync[in, optional]
-
Boolean. Indicator as to whether the call is asynchronous. The default is False (the call does not return immediately).
- bstrUser[in, optional]
-
The 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]
-
The password for authentication. This parameter is ignored if the user parameter is Null or missing.
Return Values
- S_OK
-
The value returned if successful.
Remarks
After calling this method you must call the send method to send the request and data (if any) to the server. Each send method must have a corresponding open method.
Versioning
Implemented in: MSXML 3.0 and later
See Also