Gajanan
Gajanan

Reputation: 21

how to call .net webservice in classic asp?

Hi i am new in webservice and i want to call service through Classic ASP

<%
   If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
   Dim xmlhttp
   Dim DataToSend
   DataToSend="val1="&Request.Form("text1")&"&val2="&Request.Form("text2")
   Dim postUrl
   If Request.Form.Item("Operation")="Sum" Then
    postUrl = "//localhost/Test_ASP_Service1/Service1.asmx/Sum"
  end if    
  Set xmlhttp = server.Createobject("Msxml2.ServerXMLHTTP.4.0")
  xmlhttp.Open "POST",postUrl,true
  xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
  xmlhttp.send DataToSend
  Response.Write DataToSend  & "<br>"
  Response.Write(xmlhttp.responseText)
Else
  Response.Write "Loading for first Time"  
  End If
 %>
<FORM method=POST name="form1" ID="Form1">
 Enter the two Values to perform Operation<BR>
  <select name="Operation">Select Operation<option value="Sum">Sum</option></select> 
  <INPUT type="text" name="text1" ID="Text1">
  <INPUT type="text" name="text2" ID="Text2">
 <INPUT type="submit" value="GO" name="submit1" ID="Submit1">
</form>

Upvotes: 1

Views: 3821

Answers (1)

dmarietta
dmarietta

Reputation: 1932

You probably want to take a look at the Microsoft SOAP Toolkit 3.0. Although there are notes on the Microsoft sites that you should not use this, it works perfectly fine. They just show the notes to emphasize that it is part of the older development stack they are not developing any further in favor of .NET. You should be able to find plenty of examples of code for using SOAP Toolkit online.

Otherwise, if you do not want to use that, then the other option is to write your own webservice client (wrapper) which exposes the consumed data via a COM interface which you can utilize in your classic ASP code. I have had to do that in the past for a client who insisted on not using the SOAP Toolkit simply because the Microsoft website has text on it saying it is "no longer supported".

While either method works perfectly well, you might need to resort to the second method if your webservice uses any complex types that the SOAP Toolkit is not able to parse correctly. If your service uses all basic types, then it is a quick and easy way to support that in your classic ASP code.

Upvotes: 1

Related Questions