I have a classic ASP page, inherited, that I need to call a web service that I created for another project in C# (Visusal Studio 2008).
My classic ASP page (a test page before I start working on the real page is the following):
</HEAD>
<BODY>
<SCRIPT LANGUAGE="VBScript">
<!--
<%
' this function taks an SQL statement and fills in the option values for a select box
' it also acceptes a selected value to use to check to select that value
' the SQL statment must have the option value = "as Value" and display = "as DisplayText
Function FillOptions(sSQL)
set rsFun = (localhost.DataScriptService().DSNLoadDropDown(sSQL))
%><option value="">--Select One--</option><%
If not rsFun.EOF Then
Do while not rsFun.EOF
If trim(SelectedValue) = trim(rsFun("Input")) Then
%><option value="<%=trim(rsFun("Input"))%>" selected><%=trim(rsFun("Input"))%></option><%
Else
%><option value="<%=trim(rsFun("Input"))%>"><%=trim(rsFun("Input"))%></option><%
End If
<SELECT name="SelectName" size="1">
<%
' formatted select statement Value = value in the value caluse and
' displayText = what is displayed in the select box
sSQL = "select ModalityName as Input from Modality"
' function call from function above
FillOptions sSQL
%>
</SELECT>
</td>
</tr>
</table>
</BODY>
</HTML>
I am not sure what is suppose to go into:
set rsFun = (localhost.DataScriptService().DSNLoadDropDown(sSQL))
I copied the code from a previous question that someone had answered for another experts exchange member.
I am assuming that the call to the service must go in here, but obviously I don't know what the correct syntax is suppose to be.
Any assistance would be greatly appreciated.
I went out and saw examples that deal with returning an XML file, but this service, which I have verified does indeed work, does not return an XML file. It returns a string.
To call a webservice in VBScript you have to use XML. The response will contain SOAP XML which needs to be parsed. Here is an example of how to do this, you will need to change the values according to your needs and setup.
I created a Web Method in a C# asmx (DSNLoadDropDown) that takes in a SQL statement, and returns the appropriate number of fields based on the input SQL and returns a string that can be parsed and processed accordingly. I have tested this in C#, sending in SQL, and returning strings that I have processed accordingly.
However, the problem is, that the form is classic ASP. So I have been working on a test classic ASP page to make a call and return data to it. I am using the following code:
option explicit
dim oXMLDoc
dim oXMLHTTP
dim strEnvelope
dim strSQL
dim oXMLNodes
function ProcessSend()
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
msgbox"Ready state is " & oXMLHTTP.readyState
Sub HandleStateChange
dim Root
dim NodeList
dim response
dim Elem
msgbox"Ready state inside HandleStateChange is " & oXMLHTTP.readyState
if(oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText
call oXMLDoc.loadXML(szResponse)
if(oXMLDoc.parseError.errorCode [] 0) then
msgbox"Ready state is " & oXMLHTTP.readyState
msgbox"errorCode " & oXMLDoc.parseError.errorCode
call msgbox("ERROR")
response = oXMLHTTP.responseText&" "&oXMLDoc.parseError.reason
call msgbox(oXMLDoc.parseError.reason)
else
msgbox"errorCode value in HandleStateChange else side " & oXMLDoc.parseError.errorCode
Set NodeList = oXMLDoc.getElementsByTagName("*")
For Each Elem In NodeList
document.write(Elem.tagName)
Next
end if
end if
End Sub
If I use the call oXMLHTTP.send(strEnvelope) where strEnvelope contains the SQL, I get the following error returned:
the root level is invalid
If I use call oXMLHTTP.send() I get the following:
the root level is missing
The current issue is to make a call from a classic ASP page to the web service created in C# 2008.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Dim oXMLDoc, oXMLHTTP
Sub btnApproveLeave_Click
Set oXMLHTTP = CreateObject("MSXML2.XMLHT
Set oXMLDoc = CreateObject("MSXML2.DOMDo
Msgbox("Calling WebService To Approve Leave")
oXMLHTTP.onreadystatechang
call oXMLHTTP.open("POST","http://10.253.14.136/LeaveRequestWebService/CodeWebService.asmx/ApproveLeave",Fa
call oXMLHTTP.setRequestHeader(
call oXMLHTTP.send()
End Sub
Sub HandleStateChange
if(oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText
call oXMLDoc.loadXML(szResponse
if(oXMLDoc.parseError.erro
call msgbox(oXMLDoc.parseError.
else
call msgbox(oXMLDoc.getElements
end if
end if
End Sub