Deutsche Version English Version
The COM Object "ASPHTM" can read HTTP objects and store them locally on the server (for example ASP files), or open a connection to a FTP server and store the files there. This component is suitable for local storing from dynamic pages.
Download this componentThe COM Object is contained in a dynamic link library. This DLL must be registered only once on the server, and it can be used by the most script/programming languages in simplest way, as for example in Visual Basic, Visual C++, Visual J++, ASP/VB script, Windows Scripting Host.
The component was successfully tested under the following configuration: Windows NT Workstation/Server 4.0, SP 4-6, Windows 2000 Professional and Server, Internet Information Server 4.0 and 5.0, Microsoft Personal Web Server.
Boolean WriteToFile (String Inputfile, String FormData, String OutputFile); |
The HTTP file Inputfile (complete URL) is read and stored on the server under the name indicated in Outputfile. The parameter FormData can include some POST variables, which will be send on loading the input file (format see below). The return value indicates whether the call was successful. If FALSE is returned, then the error information is stored in ErrorCode and ErrorString. |
String
WriteToString (String Inputfile, String FormData); |
The HTTP file Inputfile (complete URL) is read and returned as string. The parameter FormData can include some POST variables, which will be send on loading the input file (format see below). The return value indicates whether the call was successful. |
String WriteToStringHTTPS (String Inputfile, String FormData); |
Works like WriteToString, but with the extension that HTTPS objects can be read. |
Variant WriteToSaveArray (String Inputfile, String FormData); |
The HTTP file input file (complete URL) is read and the result is returned in a byte array. To use it with ASP the type of return was selected as VARIANT (VT_ARRAY | VT_UI1). The byte array does not contain an closing 0-byte. If an error occurs, the array contains only a single 0-byte. The parameter FormData can include some POST variables, which will be send on loading the input file (format see below). The property ErrorCode indicates whether the call was successful. |
Boolean WriteToFTP (String Inputfile, String Outputfile, String FormData, Boolean Anonymous, String Username, String Password); |
The HTTP file Inputfile (complete URL) is read and written into the FTP file Outputfile. Here it is to be noted that the parameter Outputfile must contain a complete FTP path. The parameter Anonymous indicates whether the log-on to the FTP server is to take place anonymous. If Anonymous is TRUE then the parameters Username and Password are ignored. The parameter FormData can include some POST variables, which will be send on loading the input file (format see below). The return value of the method indicates whether the call was successful. If FALSE is returned, then the error information is stored in ErrorCode and ErrorString. |
Boolean
Execute (String Inputfile, String FormData); |
The HTTP file Inputfile (complete URL) is read, but the content will not be saved or returned. The parameter FormData can include some POST variables, which will be send on loading the input file (format see below). You can use this methode to call ASP files with no response. |
String GetHeader (String URL, Long HeaderType Long HeaderIndex); |
From the URL the
Header will be read. The HeaderType specifies the part of the header (constants
for HeaderIndex see below). The HeaderIndex specifies the index of the
header. Example: If you want to validate a link, you can call GetHeader("http://www.netcomplett.de/not-exist.htm") You will get the string "404" (File not found). |
String GetCustomHeader (String URL, String HeaderName Long HeaderIndex); |
From the URL the Header will be read. HeaderName specifies the part of the Header. The HeaderIndex specifies the index of the header (0-based). |
AddRequestHeaders (String Headers, short Flag); |
This method sets header data, which
is transferred with each following call to the server. The parameter flag
controls the method of operation of the header data: Flag = 0: Add the new headers and replace existing headers of the same name (default value) if necessary. (HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD) Flag = 1: Add the header data, but do not replace existing header data. (HTTP_ADDREQ_FLAG_ADD) Flag = 2: Adds header data only if they are new. (HTTP_ADDREQ_FLAG_ADD_IF_NEW) |
ResetAllRequestHeaders (); |
Set the header information back on the default values, the Flag is set back to 0. |
Boolean ChangeProxySettings (Integer ProxyType, String ProxyAddress, String ProxyBypass); |
Defines whether the connections to the Internet are to take place via a proxy server. ProxyType can be one of the following values: 0 (proxy settings are read from registry, identically to settings in the Internet Explorer 4.0), 1 (direct connection to the Internet), 2 (connection via a proxy server). If ProxyType is 0 or 1, then the last two parameters are ignored. In the case ProxyType = 2, ProxyAddress contains the complete name / the IP address of the proxy server, and ProxyBypass contains a list of addresses, for which no proxy server is used (separation by semicolon). If this method is not called, then the settings from the registry are used (ProxyType = 0). |
SetAgentName (String NewAgentName); |
This method sets the agent name (name of the browser), which indicates the component when reading all further HTTP objects. The default value is ASPHTM. |
ErrorCode (Long) | Represents the error code of the last method call (0 = no error). |
ErrorString (String) | Represents the error description of the last method call. |
In all methods the parameter FormData must be URL
encoded. Examle: If you want to send the following three parameters you have to
choose the following string for the parameter FormData:
name= "netcomplett", address = "Fiete Schulze", etc =
"K&L"
FormData:
"name=netcomplett&address=Fiete+Schulze&etc=K%26L"
Constant | Value | Constant | Value |
HTTP_QUERY_MIME_VERSION | 0 | HTTP_QUERY_ACCEPT | 24 |
HTTP_QUERY_CONTENT_TYPE | 1 | HTTP_QUERY_ACCEPT_CHARSET | 25 |
HTTP_QUERY_CONTENT_TRANSFER_ENCODING | 2 | HTTP_QUERY_ACCEPT_ENCODING | 26 |
HTTP_QUERY_CONTENT_ID | 3 | HTTP_QUERY_ACCEPT_LANGUAGE | 27 |
HTTP_QUERY_CONTENT_DESCRIPTION | 4 | HTTP_QUERY_AUTHORIZATION | 28 |
HTTP_QUERY_CONTENT_LENGTH | 5 | HTTP_QUERY_CONTENT_ENCODING | 29 |
HTTP_QUERY_CONTENT_LANGUAGE | 6 | HTTP_QUERY_FORWARDED | 30 |
HTTP_QUERY_ALLOW | 7 | HTTP_QUERY_FROM | 31 |
HTTP_QUERY_PUBLIC | 8 | HTTP_QUERY_IF_MODIFIED_SINCE | 32 |
HTTP_QUERY_DATE | 9 | HTTP_QUERY_LOCATION | 33 |
HTTP_QUERY_EXPIRES | 10 | HTTP_QUERY_ORIG_URI | 34 |
HTTP_QUERY_LAST_MODIFIED | 11 | HTTP_QUERY_REFERER | 35 |
HTTP_QUERY_MESSAGE_ID | 12 | HTTP_QUERY_RETRY_AFTER | 36 |
HTTP_QUERY_URI | 13 | HTTP_QUERY_SERVER | 37 |
HTTP_QUERY_DERIVED_FROM | 14 | HTTP_QUERY_TITLE | 38 |
HTTP_QUERY_COST | 15 | HTTP_QUERY_USER_AGENT | 39 |
HTTP_QUERY_LINK | 16 | HTTP_QUERY_WWW_AUTHENTICATE | 40 |
HTTP_QUERY_PRAGMA | 17 | HTTP_QUERY_PROXY_AUTHENTICATE | 41 |
HTTP_QUERY_VERSION | 18 | HTTP_QUERY_ACCEPT_RANGES | 42 |
HTTP_QUERY_STATUS_CODE | 19 | HTTP_QUERY_SET_COOKIE | 43 |
HTTP_QUERY_STATUS_TEXT | 20 | HTTP_QUERY_COOKIE | 44 |
HTTP_QUERY_RAW_HEADERS | 21 | HTTP_QUERY_REQUEST_METHOD | 45 |
HTTP_QUERY_RAW_HEADERS_CRLF | 22 | HTTP_QUERY_REFRESH | 46 |
HTTP_QUERY_CONNECTION | 23 | HTTP_QUERY_CONTENT_DISPOSITION | 47 |
HTTP 1.1 defined headers | |||
HTTP_QUERY_AGE | 48 | HTTP_QUERY_IF_RANGE | 58 |
HTTP_QUERY_CACHE_CONTROL | 49 | HTTP_QUERY_IF_UNMODIFIED_SINCE | 59 |
HTTP_QUERY_CONTENT_BASE | 50 | HTTP_QUERY_MAX_FORWARDS | 60 |
HTTP_QUERY_CONTENT_LOCATION | 51 | HTTP_QUERY_PROXY_AUTHORIZATION | 61 |
HTTP_QUERY_CONTENT_MD5 | 52 | HTTP_QUERY_RANGE | 62 |
HTTP_QUERY_CONTENT_RANGE | 53 | HTTP_QUERY_TRANSFER_ENCODING | 63 |
HTTP_QUERY_ETAG | 54 | HTTP_QUERY_UPGRADE | 64 |
HTTP_QUERY_HOST | 55 | HTTP_QUERY_VARY | 65 |
HTTP_QUERY_IF_MATCH | 56 | HTTP_QUERY_VIA | 66 |
HTTP_QUERY_IF_NONE_MATCH | 57 | HTTP_QUERY_WARNING | 67 |
If you want to use the component in ASP, you include the
file ncwebtoy.inc.
Example URL, that produces error | ErrorCode | ErrorString |
htt://www.abc.com | 12006 | The URL uses an unknown protocol. |
ftp://xxx.xxx.com | 12007 | The server name or the server address could not be processed. |
http:\\www.abc.com | 12018 | The type of the supplied access number does not correspond to the requested process. |
http://not-existing.com | 12029 | The server connection could not be established. |
Unauthorised FTP write access. | 12003 | Access denied. |
Call of WriteToFTP with false username/password. | 12014 | The password was illegal. |
In the following example source codes you see how to use the component in the programming languages Visual Basic, Visual J++, ASP/VB script and Windows Scripting Host. In all examples a HTML file is read and stored locally; subsequently, a file is stored on a FTP server.
Add "ncwebtoy.dll" to the project (menu/project/references), and use the COM Object as follows:
Dim Converter As ASPHTM Set Converter = New ASPHTM Converter.WriteToFile "http://www.netcomplett.de/index.asp", "", "c:\index.html" Converter.WriteToFTP "http://www.netcomplett.de/default.html", "ftp://www.netcomplett.de/test.html", "", FALSE, "ftpuser", "ftp_pw"
Use the menu option Project/Add COM wrapper and select the file "ncwebtoy.dll". Subsequently, the component can be used as follows:
ncwebtoy.ASPHTM Converter = new ncwebtoy.ASPHTM(); Converter.WriteToFile("http://pluto/testweb/asphtm.asp", "", "c:\\testqwe.html"); Converter.WriteToFTP("http://www.netcomplett.de/default.html", "ftp://www.netcomplett.de/test.html", "", FALSE, "ftpuser", "ftp_pw");
<% Set Converter = Server.CreateObject ("NCWebToy.ASPHTM") Converter.WriteToFile "http://www.netcomplett.de/index.asp", "", "c:\index.html" Converter.WriteToFTP "http://www.netcomplett.de/default.html", "ftp://www.netcomplett.de/test.html", "", FALSE, "ftpuser", "ftp_pw" %>
Set Converter = CreateObject ("NCWebToy.ASPHTM") Converter.WriteToFile "http://www.netcomplett.de/index.asp", "", "c:\index.html" Converter.WriteToFTP "http://www.netcomplett.de/default.html", "ftp://www.netcomplett.de/test.html", "", FALSE, "ftpuser", "ftp_pw"
For the installation of the component the following steps are necessary:
The component uses the following standard libraries of the operating system (here: Windows NT 4.0): Kernel32.dll, User32.dll, Gdi32.dll, Comdlg32.dll, Winspool.drv, Advapi32.dll, Shell32.dll, Comctl32.dll, Oledlg.dll, Ole32.dll, Oleaut32.dll and Wininet.dll.
With the Microsoft Internet Information Server 4.0 is
supplied the COM Object "IISSample.Asp2Htm" written in Java. This component
possesses also the possibility of storing dynamic HTTP pages locally on the
server. A
disadvantage of this component is that before each use of this COM Object first the Java
Virtual Machine must be started on the server. (The Java Virtual Machine analyses and
executes the byte code of the Java class file.)
For the execution of ASPHTM 1.3 no Virtual Machine is needed, because a DLL contains the
compiled component.
Further "IISSample.Asp2Htm" does not possess functionality to store files on a
FTP server.
Q1. During the use of the COM Object the following error message appears: "Object creation by ActiveX component not possible".
A1. The component must be registered in
the system, e.g. by execution of "regsvr32 c:\winnt\system32\ncwebtoy.dll", change the path if
necessary. Make sure
that the following success message appears: "DllRegisterServer in
ncwebtoy.dll succeeded.".
Q2. Which steps are necessary, in order to remove the component from the system completely ? (If you try to delete the file asptohtm.dll, then the access is denied.)
A2. The DLL can removed from the system
only if it is used by no current process. To uninstall the component it must be first
guaranteed that no program uses this DLL at the moment. If the component is used in ASP
script, then the web server (e.g. Internet Information Server or Personal Web Server) must
create an instance of this component. But the web server does not release this instance
immediately, after all HTTP connections to this web server are aborted. Thus it is
necessary to stop the web server in individual cases (e.g. terminating the IIS admin
service and the WWW publishing service). Now all instances of the component are released,
and the asptohtm.dll can be removed from the system.
This procedure can be applied whenever the component is to be replaced by a newer version
(update). Within this update process it is not necessary to register the new component in
the system again (by means of regsvr32), if the new DLL is in the same path as the old.
If the component is to be removed permanently from the system, then you must first
unregister the component (by means of regsvr32 u
c:\winnt\system32\ncwebtoy.dll). If this call fails, then you have to remove the
DLL by hand from the registry. Open the registry with regedit or regedt32
and delete the following four keys including sub keys:
\HKEY_CLASSES_ROOT\NCWebToy.ASPHTM
\HKEY_CLASSES_ROOT\NCWebToy.ASPHTM.1
\HKEY_CLASSES_ROOT\CLSID\{E4E7B3D3-061F-11D4-BE17-00105AD5EC68}
\HKEY_CLASSES_ROOT\TypeLib\{E4E7B3C1-061F-11D4-BE17-00105AD5EC68}
All four keys can be found easily by searching of the
character string "ASPTOHTM".
Q3. By using the component in ASP files with the Internet Information Server 4.0 occurs the following error message in rare cases: "Exception on the server." How can this behaviour be gone around ?
A3. Check in the Microsoft Management
Console whether the settings for the appropriate web are correct.
If you have questions or suggestions, then you can send it to support{ at }netcomplett.de.
The component: You receive thereby a full version for unrestricted use.
NETCOMPLETT MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTIES, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. THIS SOFTWARE IS PROVIDED GRATUITOUSLY AND, ACCORDINGLY, NETCOMPLETT SHALL NOT BE LIABLE UNDER ANY THEORY OR ANY DAMAGES SUFFERED BY YOU OR ANY USER OF THE SOFTWARE. NETCOMPLETT WILL NOT SUPPORT THIS SOFTWARE AND WILL NOT ISSUE UPDATES TO THIS SOFTWARE.
REGARDLESS OF WHETHER ANY REMEDY SET FORTH HEREIN FAILS OF ITS ESSENTIAL PURPOSE, IN NO EVENT WILL NETCOMPLETT BE LIABLE TO YOU FOR ANY SPECIAL, CONSEQUENTIAL, INDIRECT OR SIMILAR DAMAGES, INCLUDING ANY LOST PROFITS OR LOST DATA ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE EVEN IF NETCOMPLETT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.