> I got this code from the web service site (but of course they have no
> kind of implied warranty on it) that builds a URL with a querystring
[quoted text clipped - 6 lines]
> well (encoding it at &), causing the request to be refused. This
> is the code:
Comments below in the code.
> Imports System.Web.Services
> Imports System.Web.Services.Protocols
[quoted text clipped - 32 lines]
> Dim qString
> qString = ""
Use a StringBuilder instead.
> 'Return "Hi, this page is served by Brent White's own system
> and can be looked at " & Input1.SecondParam & " times."
> 'Return Input1.SerialNumber
> qString = qString & "SerialNumber=" &
> Server.UrlEncode(Input1.SerialNumber) & Chr(26)
That is not correct. The Chr(26) should be Chr(&H26), or simply "&".
Chr(26) is the end-of-file character used in ASCII text files. Certainly
not a character that goes into url-encoded data.
> 'Return Input1.Dev_SerialNumber
> qString = qString & "DeveloperSerialNumber=" &
> Input1.Dev_SerialNumber & "&"
You only html-encode the & character if the url goes into html code.
Change "&" to "&".
Unless the developer serial number is guaranteed to only contain
characters that does not need to be url-encoded, you should url-encode
it, just as with the serial number.
> qString = qString & "SJName=" & Input1.SJName & "&"
Url-encode.
> qString = qString & "Email=" & Input1.Email & "&"
Url-encode.
> qString = qString & "StreetAddress=" & Input1.BillStreet & "&"
Yes, here to.
> qString = qString & "StreetAddress2=" & Input1.BillStreet2 &
> "&"
Yep.
> qString = qString & "StreetAddress3=" & Input1.BillStreet3 &
> "&"
Everywhere.
> qString = qString & "StreetAddress4=" & Input1.BillStreet4 &
> "&"
It goes on.
> qString = qString & "City=" & Input1.BillCity & "&"
Yes, sir.
> qString = qString & "State=" & Input1.BillState & "&"
Here too.
> qString = qString & "Zip=" & Input1.BillZip & "&"
Yowsa.
> qString = qString & "Country=" & Input1.BillCountry & "&"
Yet another one.
> qString = qString & "Phone=" & Input1.BillPhone & "&"
Ya' know the drill.
> qString = qString & "Fax=" & Input1.BillFax & "&"
Keep on encoding.
> qString = qString & "ShipToStreetAddress=" & Input1.ShipStreet
> & "&"
And encoding.
> qString = qString & "ShipToStreetAddress2=" &
> Input1.ShipStreet2 & "&"
Et.c.
> qString = qString & "ShipToStreetAddress3=" &
> Input1.ShipStreet3 & "&"
-"-
> qString = qString & "ShipToStreetAddress4=" &
> Input1.ShipStreet4 & "&"
-"-
> qString = qString & "ShipToCity=" & Input1.ShipCity & "&"
-"-
> qString = qString & "ShipToState=" & Input1.ShipState & "&"
-"-
> qString = qString & "ShipToZip=" & Input1.ShipZip & "&"
-"-
> qString = qString & "ShipToCountry=" & Input1.ShipCountry &
> "&"
-"-
> qString = qString & "ShipToPhone=" & Input1.ShipPhone & "&"
-"-
> qString = qString & "ShipToFax=" & Input1.ShipFax & "&"
-"-
> qString = qString & "OrderNumber=" & Input1.OrderNumber & "&"
-"-
> qString = qString & "AccountNumber=" & Input1.AccountNumber &
> "&"
-"-
> qString = qString & "Month=" & Input1.MonthExpr & "&"
-"-
> qString = qString & "Year=" & Input1.YearExpr & "&"
-"-
> qString = qString & "CVV2=" & Input1.CVV2 & "&"
-"-
> qString = qString & "TransactionAmount=" &
> Input1.TransactionAmount & "&"
Only digits? Sure? Otherwise... yes you guessed it.
> qString = qString & "CustomerTax=" & Input1.SalesTax & "&"
Encode.
> qString = qString & "CustomerCode=" & Input1.CustomerCode &
> "&"
-"-
> qString = qString & "PurchaseOrderNumber=" & Input1.PONumber &
> "&"
-"-
> qString = qString & "ShippingAmount=" & Input1.ShippingAmount
> & "&"
Only digits? Otherwise...
> qString = qString & "SummaryCommodityCode=" &
> Input1.SummaryCommodityCode & "&"
Yep.
> qString = qString & "orderstring_lvl3=" &
> Input1.OrderString_lvl3
-"-
> 'rp.SJName = Input1.SJName
> 'rp.Email = Input1.Email
[quoted text clipped - 32 lines]
> 'Return Input1.OrderString_lvl3
> On Error Resume Next
Ouch. Use Try and Catch for proper error handling.
> whr.send(qString)
> whr.waitforresponse()
> On Error Resume Next
Ouch.
> data = data & whr.responsetext
>
> If Not IsNothing(whr) Then
That's a pointless check.
> whr = Nothing
There is no reason to clear references that aren't used any more.
> End If
> Return qString
[quoted text clipped - 65 lines]
> The "&" characters keep getting picked up as & (except in the
> first parameter, which shows it as #x1A;
You actually have an #x1A in the first parameter and an & in the
second parameter, other than that the separators looks fine.
> When the request gets passed to the service, it treats each field as
> blank.
>
> Why is this not working? It seems to run counter to every example
> I've seen on the internet.

Signature
Göran Andersson
_____
http://www.guffa.com