Wednesday, June 3, 2015

Consuming MySuite WebService in Ax 2012 R3 (Part 2)


Expanding the project.



Now, you have to restart Ax 2012 R3, this is an important step, if you ignore this then you will suffer.

 Finally the source code is the following



static void MySuiteCFDI(str Requestor,str Transaction, str Country,str Entity, str User,str UserName, str Data1, str Data2, str Data3)
{
    XMLDocument         xmlDoc;
    XMLWriter           writer;
    XMLNode             nodoxml;
    str                 nodo;
    str                 xml;
    XmlNamespaceManager nsmgr;
    str                 valor;
    str                 cadena[];
    str                 ret = '';

    ClrObject                       clientType;

    str strRutaXML; str strNomXML; str Transaction; str UUID = "";



    MySuiteCFDI.MySuiteReference.FactWSFrontSoapClient      c;
    MySuiteCFDI.MySuiteReference.TransactionTag             tag;
    MySuiteCFDI.MySuiteReference.FactResponseData           respuesta;
    MySuiteCFDI.MySuiteReference.FactResponse               respError;




    clientType = CLRInterop::getType("MySuiteCFDI.MySuiteReference.FactWSFrontSoapClient");




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

            c = AifUtil::createServiceClient(clientType);

                     tag=c.RequestTransaction(Requestor,Transaction,Country,Entity,User,UserName,Data1,Data2,Data3);

            respuesta = tag.get_ResponseData();
            respError = tag.get_Response();

            strErrorInfo = respError.get_Data();

            if(strErrorInfo == '')
            {
                doSomething (respuesta);
            }
            else
            {
                Throw error(strErrorInfo);
            }
            CodeAccessPermission::revertAssert();
}