Results 1 to 3 of 3

Thread: VB6 - Web Service Calls via WinHTTP POST

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Post VB6 - Web Service Calls via WinHTTP POST

    This is a simple example of using the WinHTTPRequest object to make calls to a simple REST-like web service that processes database queries.

    In order to make it a standalone demonstration, the attached archive includes both the client Project and a matching server Project. The server accepts HTTP requests from port 8080 and requires fixed credentials using Basic Authentication. It uses a small Jet 4.0 database as its data store (included).


    Requirements

    To build and run this demo you will need Windows 2000 SP3, Windows XP SP1, or a later version of Windows. You will also need the VB6 development system, of course.

    There are no special CPU, disk, or memory requirements.

    Even a network isn't needed, since the client is hard-coded to query "localhost."


    Real World

    In the real world you would not used fixed credentials. You would not use Basic Authentication over HTTP, opting for more secure authentication or at least forcing the use of HTTPS. Since the embedded web server used here is based on the Winsock control though we don't have the option of using HTTPS here.

    This is just a demo.

    It is also more likely that your "server" would be a more robust web server hosted remotely. It might be something like Node.JS, or ASP scripts, PHP, etc.

    You would also be more likely to use a more compact serialization format than the ADO XML used here. This is convenient in many ways, but you can do better.

    One enhancement would be to use ADO's ADTG binary format instead of its XML format, but that is a little tougher for debugging. XML is easier to eyeball.

    Another might be to use a more compact XML format of your own invention. More work at both the client and the server but you might radically reduce the response payload size.

    Or you might choose an even more compact format such as JSON.


    Building and Running the Demo

    If TCP port 8080 is already in use you may have to change it in the client Project since it is hard-coded there.

    Open the server Project (GossServer.vbp) and do a Make on it. Open the client Project (Client.vbp) and do a make on that.

    You can also open both in the VB6 IDE separately and run them from there.

    To run the server, which should come first, make sure to keep GossServer.exe, the GossServerVDir folder, and the two database files together so that GossServer can find the other items. You may have to deal with a firewall prompt, but it is fine to allow the firewall to "keep blocking" GossServer.

    Once the server is running change the port as needed and click on the Start button.

    Name:  GossServer Sshot.png
Views: 10667
Size:  31.6 KB

    Run the client, set your query criteria, and click the Go button.

    Name:  Client Sshot.png
Views: 10930
Size:  17.8 KB


    Changes

    There are lots of possible changes.

    You might use a more practical database with multiple tables, relations, views, etc. You might implement adds, deletes, and updates.

    The attached archive is big because of the preloaded database files included. There isn't a lot of data there but the .MDW file isn't very compressible.
    Attached Files Attached Files

  2. #2
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: VB6 - Web Service Calls via WinHTTP POST

    thanks a million
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  3. #3
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: VB6 - Web Service Calls via WinHTTP POST

    Long long time ago, I had a dream. I want to put my mdb file somewhere on website so that I can retrieve data at anywhere and anytime. But I don't know how to do. With dilettante's post, I am closer but still don't know how to do because I know nothing (JAVA/ASP/PHP...) except VB6.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width