调用ASP.NET服务的ASP页面出了问题 [英] Something wrong with asp page calling asp.net service

查看:67
本文介绍了调用ASP.NET服务的ASP页面出了问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我对经典的ASP页面有问题,要求一个ASP.NET Web服务

没有异常触发但没有结果出现

我正在从过程"服务中调用方法

接受称为path
的字符串参数
却什么也没返回
我的ASP页面代码是:

Hello

i have a problem with classic asp page requests an asp.net web service

no exception triggered but no result appeared

I''m calling a method from the service "Process"

accepts string parameter called path

and returns nothing
my asp page code is:

<html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
  Dim xmlhttp
  Dim DataToSend
  DataToSend="path="&Request.Form("text1")
  Dim postUrl
  postUrl = "http://..Server../service.asmx/Process"
  Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
  xmlhttp.Open "POST",postUrl,false
  xmlhttp.setRequestHeader "Content-Type", _
      "application/x-www-form-urlencoded"
  xmlhttp.send DataToSend
  Response.Write(xmlhttp.responseText)
End If
%>
<FORM method=POST name="form1">
Enter Values to be Added<br>
<INPUT type="text" value="String value to be send" name="text1">
<br><br>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html>
</br></br></br>



我也在asp.net页面上尝试过代码



also i tried the code with an asp.net page

<br />
MyService ss = new MyService();<br />
ss.Process(TextBox1.Text);<br />



并且可以正常工作

请有人帮忙解决一下问题吗?



and that worked correctly

please someone help what''s wrong with it ?

推荐答案

xmlhttp.send DataToSend
Response.Write(xmlhttp.responseText)



我不是老式ASP的专家,但是在我看来,这很可疑.我希望该调用是异步的,因此您尝试在收到响应之前写出响应.更好的选择是使用jQuery为您调用该网站.我在此处 [ [



I''m not an expert in old-school ASP, but that looks suspect to me. I would expect the call to be asynchronous, so you are attempting to write out the response before you''ve received it. A better bet would be to use jQuery to call the site for you. I have an article here[^] that demonstrates how to do this in jQuery.


这篇关于调用ASP.NET服务的ASP页面出了问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆