0

hello people i don't know if i am askin properly but i have a big probleme i am new in programming i hope u can help me. i created an asmx that execute a xmla query on analysis services so evrything is runing perfect when i try it in local but when i deployed on iis in a windows server 2008 r2 and i tested it generated me an error "A connection cannot be made. Ensure that the server is running" can you please guys help me with that i will appreciat it. "Sorry if my english is bad".

[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);
    }

1 Answers1

0

A possible reason: Lack of access to the IIS process to the SSAS server.

(1) Determine you IIS application pool identity

(2) Give permission to this user in SSAS

Additionally:

(1) How is your web service call authenticated (anonymous / windows authentication / etc) ?

(2) Look at the msmdsrv.log file in SSAS folder

See whether this related SO post helps:

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

Subbu
  • 2,130
  • 1
  • 19
  • 28