放分100﹐紧急求助(xmlhttp调用send方法 参数错误?)

tsoukw 2004-11-22 11:02:43
我在一个htm文件中使用js调用xmlhttp的send方法请求一个webservice成功
而我使用sql server的sp_oamethod方法调用send方法却总是报”参数错误”或”程序代码执行例外状况”的错误。

Htm文件代码如下:

<html>
<head>
<script language="javascript">
function PostRequestData(URL,data){
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST",URL, false);
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
xmlhttp.SetRequestHeader ("SOAPAction","http://tempuri.org/Clear");

try {
xmlhttp.Send(data);
var result = xmlhttp.status;
}
catch(ex) {
return("0" + ex.description + "|" + ex.number);
}
if(result==200) {
return("1" + xmlhttp.responseText);
}
var xmlhttp = null;
}

function loadit(){
var url = 'http://172.17.6.28:168/EInvoice/CacheFile/ClearCache.asmx';
var data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Clear xmlns="http://tempuri.org/"> <key>888</key> </Clear> </soap:Body></soap:Envelope>';
var r=PostRequestData(url,data);
alert(r); //这里能正确返回
}
</script>
</head>
<body onload="loadit()">
hello
</body>
</html>


存储过程﹕
CREATE PROCEDURE dbo.Pro_Exec_Service
@params varchar(50) --cache名称
AS
BEGIN
DECLARE
@params2 varchar(500),
@AspxPath VARCHAR(400)
SET @AspxPath = 'http://172.17.6.28:168/EInvoice/CacheFile/ClearCache.asmx'
SET @params2 = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"></soap:Header><soap:Body><Clear xmlns="http://tempuri.org/"> <key>' + @params +'</key></Clear></soap:Body></soap:Envelope>'
--建立XmlHttp对象呼叫程序
DECLARE @object int --XmlHttp对象ID
DECLARE @hr int --执行时的结果ID
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP', @object OUT
IF @hr <> 0
BEGIN
return
END

EXEC @hr = sp_OAMethod @object, 'Open', NULL, 'post',@AspxPath,false --异步调用
IF @hr <> 0
BEGIN
return
END

EXEC @hr = sp_OAMethod @object, 'SetRequestHeader', NULL, 'Content-Type','text/xml; charset=utf-8' --
IF @hr <> 0
BEGIN
return
END

EXEC @hr = sp_OAMethod @object, 'SetRequestHeader', NULL, 'SOAPAction','http://tempuri.org/Clear' --
IF @hr <> 0
BEGIN
return
END

EXEC @hr = sp_OAMethod @object, 'send', NULL,@params2
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
print' src = ' + @src + ' desc=' + @desc
/*
这里会报” src = msxml3.dll desc=参数错误。”
可我如果是EXEC @hr = sp_OAMethod @object, 'send'
就可以顺利执行﹐为什么这里不可以带参数??
*/

return
END

EXEC @hr = sp_OADestroy @object
IF @hr <> 0
BEGIN
return
END

END
GO

Help Me???
...全文
489 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
nga96 2005-02-07
  • 打赏
  • 举报
回复
UP
噯卟釋手 2005-02-07
  • 打赏
  • 举报
回复
up
harryCom 2005-02-07
  • 打赏
  • 举报
回复
会不会要加上这个xmlhttp.SetRequestHeader ("Content-Length", data.length)
harryCom 2005-02-07
  • 打赏
  • 举报
回复
问一下,页面请求web service后何时执行存储过程,不需要服务器端代码吗?
takki 2005-02-07
  • 打赏
  • 举报
回复
up
yizhixiaozhu 2005-02-06
  • 打赏
  • 举报
回复
up
amendajing 2005-02-04
  • 打赏
  • 举报
回复
学习!
西客小贝壳 2005-02-04
  • 打赏
  • 举报
回复
up
gabriel1 2005-02-04
  • 打赏
  • 举报
回复
这是我的一段c#调用xmlhttp的程序段,你参考一下
XmlDocument doc = new XmlDocument();
try
{
doc.Load(@SourceFile.Text);
}
catch(Exception ex)
{
//throw new System.Exception("Can not load xml file.");
return;
}
//create xml http post object
XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();

//post url
string strURL = PostUrl.Text;

//open post url
xmlHttp.open("post",strURL,false,"","");

//send xml string to url
xmlHttp.send(doc.InnerXml);

//Get Back XML
string backxmlstring=xmlHttp.responseText.ToString();
nga96 2005-02-04
  • 打赏
  • 举报
回复
UP
haoco 2005-02-03
  • 打赏
  • 举报
回复
up
看看要就发发 2004-12-15
  • 打赏
  • 举报
回复
up
nga96 2004-12-11
  • 打赏
  • 举报
回复
是数据岛技术呀,不会
firefoxh 2004-11-25
  • 打赏
  • 举报
回复
觉得还是你的SQL脚本的问题
tongcheng 2004-11-25
  • 打赏
  • 举报
回复
看看
帮不了你。。。
jxzhang615 2004-11-23
  • 打赏
  • 举报
回复
帮顶!!
qianwt 2004-11-23
  • 打赏
  • 举报
回复
SQL SERVER的东西好多没用过。
tsoukw 2004-11-23
  • 打赏
  • 举报
回复


up
tsoukw 2004-11-22
  • 打赏
  • 举报
回复


no one??
5461339 2004-11-22
  • 打赏
  • 举报
回复
xml比较烦人,我也犯晕.
加载更多回复(3)

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧