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

tsoukw 2004-11-22 11:04:09
我在一个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???

...全文
140 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2004-11-23
  • 打赏
  • 举报
回复
Msxml2.ServerXMLHTTP
tsoukw 2004-11-23
  • 打赏
  • 举报
回复


up
是是非非 2004-11-23
  • 打赏
  • 举报
回复
根本就不懂,帮你顶顶,顺便学习
jueban9818 2004-11-23
  • 打赏
  • 举报
回复
根本就不懂,帮你顶顶,顺便学习。
tsoukw 2004-11-23
  • 打赏
  • 举报
回复
to
ssm1226(雨中人)

if use Msxml2.ServerXMLHTTP
there is an error occured like this

Request format is unrecognized

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


help
zllzmcDCR 2004-11-22
  • 打赏
  • 举报
回复
不是太懂,帮你顶顶,顺便学习。

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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