Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

VB.Net to VB 6 HTTP code conversion

I need to change some VB.Net examples to VB 6. Can anyone answer my questions below? Thanks. Winnie-the-Pough

The following is a sample VB Net HTTP GET request and response.

GET /DEMOWebServices2.8/Service.asmx/PlaceSingleOrder?UserID=string&PWD=string&Pair=string&Expiry=string&BuySell=string&Amount=string&Rate=string&OrderBasis=string HTTP/1.1
Host: api.efxnow.com

I THINK I COMPLETELY UNDERSTAND THE ABOVE. I KNOW HOW TO RE-ARRANGE THIS for VB 6 I.E.
Dim ID as string: ID="Pough"
WebBrowser1.Navigate "http://www.api.efxnow.com/DEMOWebServices2.8/Service.asmx/PlaceSingleOrder?METHOD=get?UserID=ID& etc

I presume that I have to provide place holders to receive each of the following, for example as:
Dim Success as Boolean

How do I recode the following in VB 6?

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8 <<< WHAT DO I DO WITH THIS???
Content-Length: length <<< WHAT DO I DO WITH THIS???

<?xml version="1.0" encoding="utf-8"?> <<< WHAT DO I DO WITH THIS???
<objPlaceOrderResponse xmlns="https://api.efxnow.com/webservices2.3">
<Success>boolean</Success>
<ErrorDescription>string</ErrorDescription>
<ErrorNumber>int</ErrorNumber>
<CustomerOrderReference>int</CustomerOrderReference>
<OrderConfirmation>string</OrderConfirmation>
</objPlaceOrderResponse>

HTTP POST

The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /DEMOWebServices2.8/Service.asmx/PlaceSingleOrder HTTP/1.1
Host: api.efxnow.com
Content-Type: application/x-www-form-urlencoded <<<< WHAT DO I DO WITH THIS???
Content-Length: length

UserID=string&PWD=string&Pair=string&Expiry=string&BuySell=string&Amount=string&Rate=string&OrderBasis=string

I presume this will do the trick.
WebBrowser1.Navigate http://www.api.efxnow.com/DEMOWebServices2.8/Service.asmx/PlaceSingleOrder?METHOD=post?UserID=string& etc

Once You give an answer to the above, I should be able to convert the below VB.Net to VB 6

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<objPlaceOrderResponse xmlns="https://api.efxnow.com/webservices2.3">
<Success>boolean</Success>
<ErrorDescription>string</ErrorDescription>
<ErrorNumber>int</ErrorNumber>
<CustomerOrderReference>int</CustomerOrderReference>
<OrderConfirmation>string</OrderConfirmation>
</objPlaceOrderResponse>

:WAVE:
[2861 byte] By [dmb-job] at [2007-11-11 8:07:20]
# 1 Re: VB.Net to VB 6 HTTP code conversion
How about using WinSock to make HTTP GET?
Here is one example.

Winsock: Making HTTP POST/GET Requests
http://www.vbforums.com/showthread.php?t=334645
Sync at 2007-11-11 17:25:54 >
# 2 Re: VB.Net to VB 6 HTTP code conversion
Michael Sync: Thanks. My problem is a bit deeper than you assume. I have been using VB 6 successfully with VB Inet & VB WebBrowser with no problem.

I tried to demonstrate that with the following:
WebBrowser1.Navigate http://www.api.efxnow.com/DEMOWebServices2.8/Service.asmx/PlaceSingleOrder?METHOD=get?UserID=ID& etc

I know nothing about VB.Net. I don't know if that is my problem or if I am just inexperienced with the syntax or use of the sample's Response.

My problem is that I did not understand what the following sample means, see below. I deduce from your example that this message just 'appears' as a response. But where do I find it. I asume I have to supply a text box to recieve this in? Is it a text box name "PostDump"? Or will it show up in individual dimentioned variables e.g.
Dim ErrorDescription as String ?? Or do I have to create an object ""objPlaceOrderResponse" so that these come back as properties of the object.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<objPlaceOrderResponse xmlns="https://api.efxnow.com/webservices2.3">
<Success>boolean</Success>
<ErrorDescription>string</ErrorDescription>
<ErrorNumber>int</ErrorNumber>
<CustomerOrderReference>int</CustomerOrderReference>
<OrderConfirmation>string</OrderConfirmation>
</objPlaceOrderResponse>

There are no stupid question, only inquisitive dummies.

Winnie-the-Pough
dmb-job at 2007-11-11 17:26:54 >
# 3 Re: VB.Net to VB 6 HTTP code conversion
I just realized that my experience with Web interfaces involved either
A.) extracting the responses by extracting the text from the screen via:
txtData = WebBrowser.Document.body.innerText
B.) extracting the text from via INET

So now I am faced with a ERROR responses or confirmations, etc. originating from the server that did not come as text on the web page.

So I need some help on how to receive responses from the server that do not appear as text on the screen.

Thanks.
:confused: :confused:

Good software like good food takes time to prepare.

Winnie-the-Pough
dmb-job at 2007-11-11 17:28:03 >
# 4 Re: VB.Net to VB 6 HTTP code conversion
See if this helps:
http://www.dev-archive.com/vb2themax/Article/19880
Phil Weber at 2007-11-11 17:28:57 >
# 5 Re: VB.Net to VB 6 HTTP code conversion
Thanks Phil, this gives me an understanding of how to proceed. I am going to attempt to use winsock.

Winnie-the-Pough
dmb-job at 2007-11-11 17:30:05 >
# 6 Re: VB.Net to VB 6 HTTP code conversion
Will INET return the equivalent messages as winsock?
I have used INET before and then parsed the response.
I feel confortable with INET.

Thanks.
Winnie-the-Pough
dmb-job at 2007-11-11 17:31:04 >
# 7 Re: VB.Net to VB 6 HTTP code conversion
Sure, I never said anything about Winsock. ;-) The article at the link I posted used MSXML.XMLHTTPRequest, not Winsock. The Internet Transfer Control should work fine as well.
Phil Weber at 2007-11-11 17:32:08 >