예제 #1
0
파일: SoapM1.cs 프로젝트: FangYuFan/fastSQL
 public PortTypeClient Begin()
 {
     End();
     _client = GetClient();
     _client?.Open();
     CurrentSession = _client?.login(ApiUser, ApiKey);
     return(_client);
 }
예제 #2
0
        static void Main(string[] args)
        {
            // test data
            const string testProductId  = "895";
            const string testProductSku = "msj006c-Royal Blue-L";

            // change following to yours according to your setup
            const string apiUrl = "http://localhost/api/v2_soap";
            //const string apiUrl = "http://local.magento/api/v2_soap";
            const string soapApiUserName = "******";
            const string apiKey          = "test123";


            // create binding and api address and connect
            var binding = new BasicHttpBinding()
            {
                // increase response size to 1MB, default 64kB is not enough to handle Magento response
                MaxReceivedMessageSize = 1048576
            };

            var address = new EndpointAddress(apiUrl);
            var client  = new PortTypeClient(binding, address);

            // login api user
            var sessionId = client.login(soapApiUserName, apiKey);

            // fetch data from API
            Console.WriteLine();
            Console.WriteLine($" ===== Performing search by product ID = {testProductId} ===== ");
            var result1 = client.catalogProductInfo(sessionId, testProductId, null, new catalogProductRequestAttributes(),
                                                    null);

            DumpProductData(result1);

            Console.WriteLine();
            Console.WriteLine($" ===== Performing search by product SKU = {testProductSku} ===== ");
            var result2 = client.catalogProductInfo(sessionId, testProductSku, null, new catalogProductRequestAttributes(),
                                                    null);

            DumpProductData(result2);
        }