private Mage_Api_Model_Server_Wsi_HandlerPortTypeClient CreateMagentoServiceClient(string baseMagentoUrl) { var endPoint = new List <string> { baseMagentoUrl, SoapApiUrl }.BuildUrl(); var magentoSoapService = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient(_customBinding, new EndpointAddress(endPoint)); magentoSoapService.Endpoint.Behaviors.Add(new CustomBehavior()); return(magentoSoapService); }
/// <summary> /// Get a Magento session ID /// </summary> /// <param name="client">Magento WS-I client</param> /// <returns>Magento session ID</returns> private static string GetSessionID(Mage_Api_Model_Server_Wsi_HandlerPortTypeClient client) { // Check for credential authentication if (client.ClientCredentials != null && !String.IsNullOrEmpty(ConfigurationManager.AppSettings["domain:Username"]) && !String.IsNullOrEmpty(ConfigurationManager.AppSettings["domain:Password"])) { client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["domain:Username"]; client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["domain:Password"]; } return(client.login( ConfigurationManager.AppSettings["service:Username"], ConfigurationManager.AppSettings["service:Password"])); }
static void Main(string[] args) { Mage_Api_Model_Server_Wsi_HandlerPortTypeClient client = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient(); //log in Magento API to get the session_id loginResponse session = client.loginAsync("userAPI", "keyAPI").Result; string sessionId = session.result; Console.WriteLine("Session ID: " + sessionId); //Let's get the info from Order "100000010" var response = client.salesOrderInfoAsync(sessionId, "100000010").Result; salesOrderEntity order = response.result; Console.WriteLine("Status in Order: " + order.status); }
// // GET: /Customer/ public ActionResult Index(int?page, string surname) { var pageNum = (page ?? 1); var pageSize = Int32.Parse(ConfigurationManager.AppSettings["pageSize"]); var filters = !String.IsNullOrEmpty(surname) ? new[] { new[] { new complexFilter { key = "lastname", value = new associativeEntity { key = "eq", value = surname } } } } : null; using (var client = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient()) { var sessionId = GetSessionID(client); var list = client.mezaitCustomerAddressList(sessionId, filters, pageNum, pageSize); var count = client.mezaitCustomerAddressCount(sessionId, filters); client.endSession(sessionId); var customers = new StaticPagedList <mezaitCustomerAddress>( list, pageNum, pageSize, count); ViewBag.Count = count; ViewBag.Surname = surname; return(View(customers)); } }
public MagentoServiceLowLevelSoap_v_from_1_7_to_1_9_CE(string apiUser, string apiKey, string baseMagentoUrl, string store) { this.ApiUser = apiUser; this.ApiKey = apiKey; this.Store = store; this.BaseMagentoUrl = baseMagentoUrl; _customBinding = CustomBinding(baseMagentoUrl); this._magentoSoapService = this.CreateMagentoServiceClient(baseMagentoUrl); this.Magento1xxxHelper = new Magento1xxxHelper(this); this.PullSessionId = async() => { var privateClient = this.CreateMagentoServiceClient(this.BaseMagentoUrl); var loginResponse = await privateClient.loginAsync(this.ApiUser, this.ApiKey).ConfigureAwait(false); return(Tuple.Create(loginResponse.result, DateTime.UtcNow)); }; this.getSessionIdSemaphore = new SemaphoreSlim(1, 1); }
public MagentoServiceLowLevelSoap_v_1_14_1_0_EE(string apiUser, string apiKey, string baseMagentoUrl, string store, int sessionIdLifeTime, bool logMessages, int getProductsMaxThreads) { this.ApiUser = apiUser; this.ApiKey = apiKey; this.Store = store; this.BaseMagentoUrl = baseMagentoUrl; this._clientFactory = new MagentoServiceSoapClientFactory(baseMagentoUrl, logMessages); this._magentoSoapService = this._clientFactory.GetClient(); this.Magento1xxxHelper = new Magento1xxxHelper(this); this.PullSessionId = async() => { var privateClient = this._clientFactory.GetClient(); var loginResponse = await privateClient.loginAsync(this.ApiUser, this.ApiKey).ConfigureAwait(false); return(Tuple.Create(loginResponse.result, DateTime.UtcNow)); }; this.getSessionIdSemaphore = new SemaphoreSlim(1, 1); this._getProductsMaxThreads = getProductsMaxThreads; this.SessionIdLifeTime = sessionIdLifeTime; this.LogRawMessages = logMessages; }
protected Mage_Api_Model_Server_Wsi_HandlerPortTypeClient RecreateMagentoServiceClientIfItNeed(Mage_Api_Model_Server_Wsi_HandlerPortTypeClient privateClient) { if (privateClient.State != CommunicationState.Opened && privateClient.State != CommunicationState.Created && privateClient.State != CommunicationState.Opening) { privateClient = this.CreateMagentoServiceClient(this.BaseMagentoUrl); } return(privateClient); }
public Mage_Api_Model_Server_Wsi_HandlerPortTypeClient RefreshClient(Mage_Api_Model_Server_Wsi_HandlerPortTypeClient client, bool keepAlive = true) { return(keepAlive ? this._clientFactoryDefault.RefreshClient(client) : this._clientFactoryWithoutKeepAlive.RefreshClient(client)); }