【问题标题】:connect to ssas via a web service asmx通过 Web 服务 asmx 连接到 ssas
【发布时间】:2023-03-15 03:38:01
【问题描述】:

大家好,我不知道我是否正确询问,但我有一个大问题,我是编程新手,希望你能帮助我。 我创建了一个 asmx,它在分析服务上执行 xmla 查询,所以当我在本地尝试它时,evrything 运行完美,但是当我在 windows server 2008 r2 中的 iis 上部署时,我测试它生成了一个错误“无法建立连接。确保服务器正在运行”,请大家帮帮我,我会很感激的。 “对不起,如果我的英语不好”。

[SoapRpcMethod()]
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public String StartJob(String JobId)
    {
        string res = "";
        string chronomark = (DateTime.Now).ToString("yyy-MM-dd_HHmmss");
        String logFile = System.Configuration.ConfigurationManager.AppSettings["log"] + (JobId != null ? JobId : "null") + chronomark + ".log";

        try
        {
            FileStream fs = new FileStream(logFile, FileMode.CreateNew);
            StreamWriter swr = new StreamWriter(fs);
            try
            {
                try
                {
                    if (JobId == null) throw new Exception("NO JOB ID GIVEN");
                    Regex rgx = new Regex("^[0-9A-Z-]{32}$");
                    if (!rgx.IsMatch(JobId)) throw new Exception("BAD JOB ID");
                    MatchCollection mcol = rgx.Matches(JobId);
                    if (mcol.Count != 1) throw new Exception("BAD JOB ID Collection");
                    String sJobID = mcol[0].Value;
                    FileInfo fi = new FileInfo(System.Configuration.ConfigurationManager.AppSettings["storage"] + sJobID + ".cube");
                    if (!fi.Exists)
                        throw new Exception("NO REGISTRED JOB ID");
                    FileStream fstr;
                    try
                    {
                        fstr = fi.OpenRead();
                    }
                    catch (Exception ex)
                    {
                        swr.WriteLine(ex.ToString());
                        swr.WriteLine(ex.StackTrace);
                        throw new Exception("NO JOB ID REGISTRED");
                    }
                    StreamReader sr = new StreamReader(fstr);
                    String sTargetServer = sr.ReadLine();
                    StringBuilder sbrXMLA = new StringBuilder();
                    sbrXMLA.Append(sr.ReadToEnd());
                    sr.Close();
                    fstr.Close();
                    swr.WriteLine(sbrXMLA.ToString());
                    swr.WriteLine(sTargetServer);
                    res = sendXMLARequest(sbrXMLA.ToString(), sTargetServer, swr);
                    return res;
                }
                catch (Exception se)
                {
                    swr.WriteLine(se.ToString());
                    swr.WriteLine(se.StackTrace);
                    res = "ERROR   :" + se.Message.ToString(); 
                    return res;  
                }
            }
            finally
            {
                swr.Flush();
                fs.Close();
            }
        }
        catch(Exception exp)
        {
            res = "ERROR : " + exp.Message;
            return res; 
        }
    }
    [WebMethod]
    private String sendXMLARequest(String sXMLARequest, String sTargetServer, StreamWriter logger)
    {
        XmlDocument doc = new XmlDocument();

        doc.LoadXml(sXMLARequest);
        String Json = JsonConvert.SerializeXmlNode(doc);
        Server server = new Server();
        server.Connect(@"Provider=OLAP;Data Source=" + sTargetServer);
        server.Execute(sXMLARequest);
        string con = server.Connected.ToString();
        XmlaResultCollection rsCollection = server.Execute(sXMLARequest);
        String s = null;
        foreach (XmlaResult res in rsCollection)
        {
            s += res.Value.ToString();
            foreach (XmlaMessage message in res.Messages)
            {
                logger.WriteLine(message.ToString());
                if (message is XmlaError)
                   Json = s + "ERROR : " + message.Description;
                else
                   Json = s + "WARNIN   : " + message.Description;
            }
        }
        server.Disconnect();
        JavaScriptSerializer js = new JavaScriptSerializer();
        return js.Serialize(Json);
    }

【问题讨论】:

    标签: c# ssas asmx


    【解决方案1】:

    可能的原因:无法访问 SSAS 服务器的 IIS 进程。

    (1) 确定您的 IIS 应用程序池标识

    (2) 在 SSAS 中授予该用户权限

    另外:

    (1) 您的 Web 服务调用是如何进行身份验证的(匿名/Windows 身份验证/等)?

    (2)查看SSAS文件夹中的msmdsrv.log文件

    看看这个相关的 SO 帖子是否有帮助:

    Either the user, 'IIS APPPOOL\App Name', does not have access to the 'SSAS Cube Name' database, or the database does not exist

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2017-05-27
      • 1970-01-01
      • 2016-05-24
      相关资源
      最近更新 更多