PDA

View Full Version : Problem with Dim Statements


Gary Williams
12-04-2005, 10:03 AM
Hi All,

I have the following vbs script on my server. When I run this script, I get the error message below regarding line 2.

I have installed SOAP Toolkit 3.0 on the server so it does have MSXML available plus other SOAP/XML scripts work fine.

Any ideas?

Regards

Gary

==================

CLIENT.VBS SCRIPT

Sub Main()
Dim objHTTP As New MSXML.XMLHTTPRequest
Dim strEnvelope As String
Dim strReturn As String
Dim objReturn As New MSXML.DOMDocument
Dim dblTax As Double
Dim strQuery As String

'Create the SOAP Envelope
strEnvelope = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _
"<salestotal>100</salestotal>" & _
"</m:getsalestax>" & _
"</soap:body>" & _
"</soap:envelope>"

'Set up to post to our local server
objHTTP.open "post", "http://localhost/soap.asp", False

'Set a standard SOAP/ XML header for the content-type
objHTTP.setRequestHeader "Content-Type", "text/xml"

'Set a header for the method to be called
objHTTP.setRequestHeader "SOAPMethodName", _
"urn:myserver/soap:TaxCalculator#GetSalesTax"

'Make the SOAP call
objHTTP.send strEnvelope

'Get the return envelope
strReturn = objHTTP.responseText

'Load the return envelope into a DOM
objReturn.loadXML strReturn

'Query the return envelope
strQuery = _
"SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
dblTax = objReturn.selectSingleNode(strQuery).Text

Debug.Print dblTax
End Sub

========================

ERROR MESSAGE

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

D:\website\www\client.vbs(2, 13) Microsoft VBScript compilation error: Expected end of statement

========================

BarrMan
12-04-2005, 12:26 PM
strEnvelope = "Some value" & _

Gary Williams
12-04-2005, 02:08 PM
Hi Barrman,

Thanks for the suggestion, but the script still reports the same problem on line 2.

Regards

Gary

BarrMan
12-04-2005, 03:03 PM
<!--client.vbs Script-->

Gary Williams
12-04-2005, 11:04 PM
Hi Barrman,

I added the line "client.vbs Script" to the post just for clarity.

The problem is the second line "Dim objHTTP As New MSXML.XMLHTTPRequest", and all Dim statements I suspect.

Regards

Gary

Roelf
12-05-2005, 10:21 AM
in vbs files there are no strong datatypes. so the As part in the Dim statement has to be removed

hinch
12-05-2005, 11:48 AM
Dim objHTTP
new objHTTP = MSXML.XMLHTTPRequest


would be something like that can never remember :)

but you dim the var and then you instance the object after

Gary Williams
12-05-2005, 12:39 PM
Hi Roelf and Hinch,

I'll go and try these.

Thanks

Gary