Показать сообщение отдельно
Старый 27.02.2017, 13:01   #9  
AlexeyS is offline
AlexeyS
Участник
 
404 / 339 (12) ++++++
Регистрация: 15.06.2004
Адрес: москва
оставлю тут, вдруг кому пригодится:

Business connector кэширует данные, если было изменение класса, то можно почистить кэш,
Код:
axp = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();
axp.Logon(null, null, null, null);
axp.CallStaticClassMethod("SysFlushAOD", "doFlush");
обращение к сервису из аксапты, получение JSON и конвертация в XML
Код:
boolean getInfo()
{
    boolean                         ret;
    str                             url = "http://url.url";
    CLRObject                       clrCredential   = null;
    System.Net.NetworkCredential    credential      = null;
    CLRObject                       clro            = null;
    System.Net.HttpWebRequest       httpRequest     = null;
    System.Net.HttpWebResponse      httpResponse    = null;
    System.IO.Stream                stream          = null;
    System.IO.StreamReader          streamReader    = null;
    System.Xml.Linq.XNode           xnode           = null;
    System.Exception                clrException;
    str                             s;
    ;

    try
    {
        new InteropPermission(InteropKind::ClrInterop).assert();

        clrCredential = new System.Net.NetworkCredential();
        credential = clrCredential;
        credential.set_UserName("user_name");
        credential.set_Password("user_pwd");

        clro         = System.Net.WebRequest::Create(url);
        httpRequest  = clro;

        httpRequest.set_Credentials(credential);

        httpResponse = httpRequest.GetResponse();
        stream = httpResponse.GetResponseStream();
        streamReader = new System.IO.StreamReader(stream);

        s = streamReader.ReadToEnd();

        if (s == "null" || s == "false")
        {
            info("No info");
            ret = false;
        }
        else
        {
            xnode = Newtonsoft.Json.JsonConvert::DeserializeXNode(s, "Root");
            s = xNode.ToString();
            xmlDoc = new XMLDocument();
            xmlDoc.loadXml(s);

            CodeAccessPermission::revertAssert();
            ret = true;
        }
    }
    catch(Exception::CLRError)
    {
        clrException = CLRInterop::getLastException();

        if (clrException)
        {
            clrException = clrException.get_InnerException();
            if (clrException)
            {
                error(clrException.get_Message());
            }
        }

        ret = false;
    }
 
    return ret;
}
За это сообщение автора поблагодарили: Vadik (1), trud (2), Logger (10), Ace of Database (3).