ActiveXObject.Save()方法给出权限被拒绝错误

时间:2011-12-26 07:28:30

标签: c# asp.net .net

    function getfun(a)
    {
      var xmlObj = new ActiveXObject("Msxml2.DOMDocument");

            var sXml  = "<?xml version=\"1.0\" ?>" ;
                  sXml += "<soap:Envelope "
                  sXml += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " ;
                  sXml += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " ;
                  sXml += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" ;
                  sXml += "<soap:Body>" ;
                  sXml += "<Add xmlns=\"http://tempuri.org/\">" ;
                  sXml = sXml + "<a>" + a.value  + "</a>" ;

                  sXml += "</Add></soap:Body></soap:Envelope>"

   // Try to parse the XML string into DOM object 
            xmlObj.loadXML(sXml) ;

            var xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP") ;
            xmlHTTP.Open ( "Post", "http://localhost/MyWebVirtual/MyWebService.asmx", false) ;
            xmlHTTP.setRequestHeader("SOAPAction", "http://tempuri.org/Add") ;
            xmlHTTP.setRequestHeader("Content-Type", "text/xml; charset=utf-8" ) ;
            xmlHTTP.Send(xmlObj.xml) ;

            var xmlResponse = xmlHTTP.responseXML ;
            answer.innerText = xmlResponse.selectSingleNode("soap:Envelope/soap:Body/AddResponse/AddResult").text ;

            var xmlObj2 = new ActiveXObject("Microsoft.XMLDOM");
            xmlObj2.resolveExternals = true;
            xmlObj2.preserveWhiteSpace = true;
            xmlObj2.validateOnParse = false;
            xmlObj2.async = false;
            xmlObj2.loadXML(xmlResponse.selectSingleNode("soap:Envelope/soap:Body/AddResponse/AddResult").text);
            xmlObj2.save("C:\\Users1.xml");

 }

将xmlObj2保存到文件时出错。

1 个答案:

答案 0 :(得分:2)

您是否设置了文件夹或目录的权限。

文件夹或目录 - &gt;右键单击 - &gt;属性 - &GT;安全 - &gt;群组名称 - &gt;允许

请检查。

为所有用户组名称设置用户权限并再次检查。

希望这可能有所帮助。