放分100﹐紧急求助(xmlhttp调用send方法 参数错误?)
我在一个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???