我在VBScript中使用Web服务时遇到了一些困难。每次我尝试运行它都会出现一些错误(缺少参数/内部服务器错误/状态500)。我不知道什么是错的。你能给我一些帮助吗?
这是我的VBScript代码:
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.open "POST","http://192.168.0.32:9090/webservice1.asmx/Conecta?
sID=1",False
oXMLHTTP.setRequestHeader"Content-Type","application/x-www-form-urlencoded"
oXMLHTTP.send()
msgBox oXMLHTTP.Status
msgbox oXMLHTTP.StatusText
msgbox oXMLHTTP.responseText
这是我的Web服务。很简单:
namespace WebApplication1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http:// tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string Conecta(string sID)
{
if (sID == "1")
{
return "ok";
}
return "Not ok";
}
}
}
对不起。我是这样的诺布。非常感谢任何帮助。
谢谢!!!
答案 0 :(得分:1)
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.open "POST","http://192.168.0.32:9090/webservice1.asmx/Conecta",False
oXMLHTTP.setRequestHeader"Content-Type","application/x-www-form-urlencoded"
oXMLHTTP.send "sID=1"
msgBox oXMLHTTP.Status
msgbox oXMLHTTP.StatusText
msgbox oXMLHTTP.responseText