New web services features in Acumatica

Hello everybody,

today I want to share with you one way of importing data from Acumatica. 

After many versions of binding to strings Acumatica made really big change in their web service decisions. They made their services more compile time oriented. 

Adding new web service reference should be done only in the following way:

1. In  the menu select Project -> Add Service reference

2. In the Pop up type something like "https://localhost/WebServiceAPITest/entity/Default/5.30.001?wsdl" without quotes.   

3. Click Go

4. Here you can feel some freedom, and give namespace which you prefer for your web services.

5. Click Ok.


Here I want to post way how to get all Stock items with inbound fields:

public class Authentication
        private static DefaultSoapClient Login()
            string userName, password, companyName, branch, locale;
            userName = ConfigurationManager.AppSettings["username"];
            password = ConfigurationManager.AppSettings["password"];
            companyName = ConfigurationManager.AppSettings["companyName"];
            branch = ConfigurationManager.AppSettings["branch"];
            locale = ConfigurationManager.AppSettings["locale"] == ""
                ? null
                : ConfigurationManager.AppSettings["locale"];
            var defaultBinding = ConfigurationManager.AppSettings["defaultBindigName"];
            var soapClient = new DefaultSoapClient(defaultBinding);
            soapClient.Login(userName, password, companyName, branch, locale);
            ServicePointManager.ServerCertificateValidationCallback +=
                new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
            return soapClient;
        //an Acumatica ERP website in an SSL conversation
        private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain,
            SslPolicyErrors policyErrors)
            //For simplicity, this callback always returns true
            //In a real integration application, you must check
            //an SSL certificate here
            return true;
        public static List<StockItem> GetAllStockItems()
            var result = new List<StockItem>();
            using (DefaultSoapClient soapClient = Login())
                var si = new StockItem();
                var stockItems = soapClient.GetList(si, true);
                foreach (StockItem stockItem in stockItems)
            return result;

One more option, you should add to your app.config somehting like this:
                <binding name="DefaultSoap" allowCookies="true" maxReceivedMessageSize="653600">
                    <security mode="Transport" />
                <binding name="DefaultSoap1" />
                <binding name="DefaultSoap12">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpsTransport />
            <endpoint address="https://localhost/entity/Default/5.30.001"
                binding="basicHttpBinding" bindingConfiguration="DefaultSoap"
                contract="Mohawk.DefaultSoap" name="DefaultSoap" />
            <endpoint address="https://localhost/entity/Default/5.30.001"
                binding="customBinding" bindingConfiguration="DefaultSoap12"                 contract="Mohawk.DefaultSoap" name="DefaultSoap12" />         </client>     </system.serviceModel>

Then you can get all stock items with the following method:
var si = Authentication.GetAllStockItems();

and do something with them.

No Comments

Add a Comment