我需要从经典的asp页面调用我的.NET(C#)web服务。我想通过创建一个调用asp页面的控制台应用程序来测试它。 这是我的ASP页:从控制台应用程序调用经典的asp页面
Dim strUserID
Dim strUserName
Dim strUserEmail
strUserID = Request.Form("UserID")
strUserName = Request.Form("UserName")
strUserEmail = Request.Form("UserEMail")
SET objSoapClient = Server.CreateObject("MSSOAP.SoapClient")
objSoapClient.ClientProperty("ServerHTTPRequest") = True
Call objSoapClient.mssoapinit("http://localhost:/MyWebService/Service1/" & _
"MyWebService.asmx?WSDL", "MyWebService")
strReturnValue = objSoapClient.SendData(strUserID, strUserName, strUserEmail)
response.Write("Returned from service with return value: " & strReturnValue)
现在我的控制台应用程序必须调用.asp页。 如何构建URL? 如果asp页面位于以下文件夹中:C:\ Folder1 \ OldPage.asp,我该如何构建URL?
这是我到目前为止有:
static void Main(string[] args)
{
WebClient client = new WebClient();
Uri aspPagingServiceUri = new Uri("http://localhost/Folder1/OldPage.asp?UserID=g39s24&UserName=Gloria [email protected]");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(aspPagingServiceUri);
httpWebRequest.Method = "GET";
var response = httpWebRequest.GetResponse();
HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
Stream resStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
string strResponse = reader.ReadToEnd();
Console.WriteLine(strResponse);
reader.Close();
}
我得到的错误:“远程服务器返回错误:(503)服务器不可用。 '当它到达GetResponse
函数。
我相信我的问题是与URL的创建。
谢谢。
UPDATE 我试图连接到Web服务器上的ASP文件。我收到(500)错误:“远程服务器返回错误:(500)内部服务器错误。” 该文件夹是:C:\的Inetpub/wwwroot文件/应用程序/服务/ ServiceNew.asp 这是我的控制台应用程序:
static void Main(string[] args)
{
try
{
WebClient client = new WebClient();
Uri aspPagingServiceUri = new Uri("http://myserverName/Apps/Services/ServiceNew.asp?UserID=g39r345&UserName=John Smith&[email protected]&Subject=Test&MSG=Testing&ContactList=Sam Smith;");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(aspPagingServiceUri);
httpWebRequest.Method = "GET";
var response = httpWebRequest.GetResponse();
HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
Stream resStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
string strResponse = reader.ReadToEnd();
Console.WriteLine(strResponse);
reader.Close();
}
catch (WebException wex)
{
Console.WriteLine("Web Exception: " + wex.Message);
}
catch (Exception ex)
{
Console.WriteLine("General Exception: " + ex.Message);
}
}
错误发生var response = httpWebRequest.GetResponse();
我是否正确地创建网址是什么?
我只是跟随文件路径。
我正在调用一个经典的ASP文件来运行。我不知道它是否有特殊的库,要添加的组件。 –
道歉 - 我会删除。 – Paul