Ejemplo n.º 1
0
        public async Task IComposite_PostAsync_T_Args(string apiVersion, CompositeResponse <string> expected, Composite request)
        {
            using var handler = MockHttpMessageHandler.SetupHandler(expected);
            var api    = handler.SetupApi <IComposite>();
            var result = await api.PostAsync <string>(request, CancellationToken.None, apiVersion);

            result.Should().BeEquivalentTo(expected);
            handler.ConfirmPath($"/services/data/{apiVersion}/composite");
        }
Ejemplo n.º 2
0
        public async Task IComposite_PostAsync(CompositeResponse <dynamic> expected, Composite request)
        {
            using var handler = MockHttpMessageHandler.SetupHandler(expected);
            var api    = handler.SetupApi <IComposite>();
            var result = await api.PostAsync(request);

            result.Should().BeEquivalentTo(expected);
            handler.ConfirmPath($"/services/data/{Api.Version}/composite");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generic send request
        /// </summary>
        /// <param name="request">Request to send</param>
        /// <returns>Response model</returns>
        public virtual WebServiceResponse SendRequest(WebServiceRequest request)
        {
            this.request = request;

            XmlDocument xmlRequest = RequestFactory.CreateRequest(request);

            this.xmlRequest = xmlRequest;

            XmlDocument xmlResponse = SendRequest(xmlRequest);

            this.xmlResponse = xmlResponse;

            WebServiceResponse response = ResponseFactory.CreateResponse(request.GetWebServiceResponseModel(), xmlResponse);

            if ((response is CompositeResponse) && (request is CompositeRequest))
            {
                CompositeResponse compositeResponse = (CompositeResponse)response;
                CompositeRequest  compositeRequest  = (CompositeRequest)request;

                if (compositeResponse.GetResponsesCount() > 0)
                {
                    List <WebServiceResponse> responses  = compositeResponse.GetResponses();
                    List <Operation>          operations = compositeRequest.GetOperations();

                    for (int i = 0; i < responses.Count; i++)
                    {
                        WebServiceResponse tempResponse = responses[i];
                        WebServiceRequest  temRequest   = operations[i].WebService;
                        tempResponse.WebServiceType = temRequest.WebServiceType;
                    }
                }
            }

            response.WebServiceType = request.WebServiceType;
            return(response);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            // CREATE COMPOSITE WS
            CompositeOperationRequest compositeOperation = new CompositeOperationRequest();

            compositeOperation.Login          = GetLogin();
            compositeOperation.WebServiceType = "CompositeBPartnerTest";

            // CREATE IMAGE WS
            CreateDataRequest createImage = new CreateDataRequest();

            createImage.WebServiceType = "CreateImageTest";

            String imageName = "img/idempiere-logo.png";

            DataRow data = new DataRow();

            data.AddField("Name", imageName);
            data.AddField("Description", "Test Create BPartner and Logo");

            byte[] fileBytes = File.ReadAllBytes(imageName);
            data.AddField("BinaryData", fileBytes);

            createImage.DataRow = data;

            // CREATE BP WS
            CreateDataRequest createBP = new CreateDataRequest();

            createBP.WebServiceType = "CreateBPartnerTest";

            DataRow dataBP = new DataRow();

            dataBP.AddField("Name", "Test BPartner");
            dataBP.AddField("Value", "Test_BPartner From C#" + Environment.TickCount);
            dataBP.AddField("TaxID", "123456");
            dataBP.AddField("Logo_ID", "@AD_Image.AD_Image_ID");
            createBP.DataRow = dataBP;

            compositeOperation.AddOperation(createImage);
            compositeOperation.AddOperation(createBP);

            WebServiceConnection client = GetClient();

            try {
                // GET RESPONSE
                CompositeResponse response = client.SendRequest(compositeOperation);

                client.WriteRequest(Console.Out);
                Console.WriteLine();
                Console.WriteLine();
                client.WriteResponse(Console.Out);
                Console.WriteLine();
                Console.WriteLine();

                if (response.Status == WebServiceResponseStatus.Error)
                {
                    Console.WriteLine(response.ErrorMessage);
                }
                else
                {
                    for (int i = 0; i < response.GetResponsesCount(); i++)
                    {
                        if (response.GetResponse(i).Status == WebServiceResponseStatus.Error)
                        {
                            Console.WriteLine(response.GetResponse(i).ErrorMessage);
                        }
                        else
                        {
                            Console.WriteLine(response.GetResponse(i).GetWebServiceResponseModel());
                            Console.WriteLine(response.GetResponse(i).WebServiceType);
                        }
                        Console.WriteLine();
                    }
                }

                Console.WriteLine("--------------------------");
                Console.WriteLine("Web Service: CompositeBPartnerTest");
                Console.WriteLine("Attempts: " + client.AttemptsRequest);
                Console.WriteLine("Time: " + client.TimeRequest);
                Console.WriteLine("--------------------------");
            } catch (Exception e) {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }
        public override void TestPerformed()
        {
            CompositeOperationRequest compositeOperation = new CompositeOperationRequest();

            compositeOperation.Login          = GetLogin();
            compositeOperation.WebServiceType = GetWebServiceType();

            CreateDataRequest createMovement = new CreateDataRequest();

            createMovement.WebServiceType = "CreateMovementTest";
            DataRow data = new DataRow();

            data.AddField("C_DocType_ID", "143");
            data.AddField("MovementDate", "2015-10-25 00:00:00");
            data.AddField("AD_Org_ID", "11");
            createMovement.DataRow = data;

            CreateDataRequest createMovementLine = new CreateDataRequest();

            createMovementLine.WebServiceType = "CreateMovementLineTest";
            DataRow dataLine = new DataRow();

            dataLine.AddField("M_Movement_ID", "@M_Movement.M_Movement_ID");
            dataLine.AddField("M_Product_ID", "138");
            dataLine.AddField("MovementQty", "1");
            dataLine.AddField("M_Locator_ID", "50001");
            dataLine.AddField("M_LocatorTo_ID", "50000");
            dataLine.AddField("AD_Org_ID", "11");
            createMovementLine.DataRow = dataLine;

            SetDocActionRequest docAction = new SetDocActionRequest();

            docAction.DocAction        = DocAction.Complete;
            docAction.WebServiceType   = "DocActionMovementTest";
            docAction.RecordIDVariable = "@M_Movement.M_Movement_ID";

            compositeOperation.AddOperation(createMovement);
            compositeOperation.AddOperation(createMovementLine);
            compositeOperation.AddOperation(docAction);

            WebServiceConnection client = GetClient();

            try {
                CompositeResponse response = client.SendRequest(compositeOperation);

                if (response.Status == WebServiceResponseStatus.Error)
                {
                    Console.WriteLine(response.ErrorMessage);
                }
                else
                {
                    for (int i = 0; i < response.GetResponsesCount(); i++)
                    {
                        if (response.GetResponse(i).Status == WebServiceResponseStatus.Error)
                        {
                            Console.WriteLine(response.GetResponse(i).ErrorMessage);
                        }
                        else
                        {
                            Console.WriteLine(response.GetResponse(i).GetWebServiceResponseModel());
                        }
                    }
                }
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
        public override void TestPerformed()
        {
            CompositeOperationRequest compositeOperation = new CompositeOperationRequest();

            compositeOperation.Login          = GetLogin();
            compositeOperation.WebServiceType = GetWebServiceType();

            CreateDataRequest createImage = new CreateDataRequest();

            createImage.WebServiceType = "CreateImageTest";

            String imageName = "img/idempiere-logo.png";

            DataRow data = new DataRow();

            data.AddField("Name", imageName);
            data.AddField("Description", "Test Create BPartner and Logo");

            byte[] fileBytes = File.ReadAllBytes(imageName);
            data.AddField("BinaryData", fileBytes);

            createImage.DataRow = data;

            CreateDataRequest createBP = new CreateDataRequest();

            createBP.WebServiceType = "CreateBPartnerTest";

            DataRow dataBP = new DataRow();

            dataBP.AddField("Name", "Test BPartner");
            dataBP.AddField("Value", "Test_BPartner From C#" + Environment.TickCount);
            dataBP.AddField("TaxID", "123456");
            dataBP.AddField("Logo_ID", "@AD_Image.AD_Image_ID");
            createBP.DataRow = dataBP;

            compositeOperation.AddOperation(createImage);
            compositeOperation.AddOperation(createBP);

            WebServiceConnection client = GetClient();

            try {
                CompositeResponse response = client.SendRequest(compositeOperation);

                if (response.Status == WebServiceResponseStatus.Error)
                {
                    Console.WriteLine(response.ErrorMessage);
                }
                else
                {
                    for (int i = 0; i < response.GetResponsesCount(); i++)
                    {
                        if (response.GetResponse(i).Status == WebServiceResponseStatus.Error)
                        {
                            Console.WriteLine(response.GetResponse(i).ErrorMessage);
                        }
                        else
                        {
                            Console.WriteLine(response.GetResponse(i).GetWebServiceResponseModel());
                            Console.WriteLine(response.GetResponse(i).WebServiceType);
                        }
                        Console.WriteLine();
                    }
                }
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }