예제 #1
0
        public void TestHelloWorld()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUri);
            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var call = new process.WebSvcAsync.Operations.CallAsyncOp(webMethod);
            call.OnComplete += call_OnComplete;

            var thread = new Thread(() => {
                call.Start();
            });
            thread.Name = "TestHelloWorld Thread";
            thread.Start();
            thread.Join();

            var contentLengthResult = _testHelloWorldResult.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_LENGTH];
            var contentTypeResult = _testHelloWorldResult.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE];

            Assert.AreEqual("211", contentLengthResult);
            Assert.AreEqual("text/xml; charset=utf-8", contentTypeResult);
            Assert.AreEqual(_testHelloWorldResult.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(_testHelloWorldResult.Response.Status, "200 OK");
        }
예제 #2
0
        public void TestHelloWorld()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUri);

            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]       = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var call = new process.WebSvcAsync.Operations.CallAsyncOp(webMethod);

            call.OnComplete += call_OnComplete;

            var thread = new Thread(() => {
                call.Start();
            });

            thread.Name = "TestHelloWorld Thread";
            thread.Start();
            thread.Join();

            var contentLengthResult = _testHelloWorldResult.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_LENGTH];
            var contentTypeResult   = _testHelloWorldResult.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE];

            Assert.AreEqual("211", contentLengthResult);
            Assert.AreEqual("text/xml; charset=utf-8", contentTypeResult);
            Assert.AreEqual(_testHelloWorldResult.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(_testHelloWorldResult.Response.Status, "200 OK");
        }
예제 #3
0
        void tsBtnGo_Click(object sender, EventArgs e)
        {
            SetInProgress();

            uc_wm_response1.Clear();

            string errorMessage = uc_wm_request1.ValidateForm();

            if (errorMessage != null)
            {
                uc_log1.LogErrorMessage(errorMessage);
                uc_log1.LogInfoMessage("request finish");

                SetReady("request end");
                return;
            }

            drexModel.WebSvcMethod webSvcMethod = uc_wm_request1.RetrieveForm();

            //add to the list of previous uris the uri has already been validated by ValidateForm
            if (State.Instance.Mode == ProjectMode.MultipleWsdl)
            {
                State.Instance.ConfigPrevUrls.Add(_webSvcSrcUri, webSvcMethod.Name, webSvcMethod.ServiceURI);
            }

            CallWebSvcCallAsync(webSvcMethod);
        }
예제 #4
0
        public void PopulateForm(string webSvcSrcUri, drexModel.WebSvcMethod webSvcMethod)
        {
            _webSvcSrcUri = webSvcSrcUri;
            uc_wm_request1.PopulateForm(webSvcSrcUri, webSvcMethod);

            uc_wm_response1.PopulateForm(webSvcMethod.Response.Body, "200 OK", webSvcMethod.Response.Headers[drexModel.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]);
            uc_wm_request1.OnXmlFormatError += uc_wm_request1_OnXmlFormatError;
        }
예제 #5
0
        public CallAsyncOp(model.WebSvcMethod webSvcMethod, CancelToken cancelToken, int timeoutPeriod, model.IProxy proxy, ILog log)
            : base(webSvcMethod.Name, timeoutPeriod, proxy, log)
        {
            _webSvcMethod = webSvcMethod;
            _cancelToken = cancelToken;

            _cancelObject = new process.WebSvcAsync.CancelObject(webSvcMethod.Name, cancelToken);
            _cancelObject.OnCancel += _cancelObject_OnCancel;
        }
예제 #6
0
        public CallAsyncOp(model.WebSvcMethod webSvcMethod, CancelToken cancelToken, int timeoutPeriod, model.IProxy proxy, ILog log)
            : base(webSvcMethod.Name, timeoutPeriod, proxy, log)
        {
            _webSvcMethod = webSvcMethod;
            _cancelToken  = cancelToken;

            _cancelObject           = new process.WebSvcAsync.CancelObject(webSvcMethod.Name, cancelToken);
            _cancelObject.OnCancel += _cancelObject_OnCancel;
        }
예제 #7
0
 public void PopulateForm(string webSvcSrcUri, drexModel.WebSvcMethod webSvcMethod)
 {
     _webSvcMethod = webSvcMethod;
     tec_Request.Text = webSvcMethod.Request.Body;
     pg_headers.SelectedObject = new RequestPropertyGrid(webSvcSrcUri,
         webSvcMethod.Name,
         webSvcMethod.Request.Headers[drexModel.WebSvcMessage.HEADER_NAME_CONTENT_TYPE],
         webSvcMethod.Request.Headers[drexModel.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION],
         webSvcMethod.ServiceURI);
 }
예제 #8
0
 public void PopulateForm(string webSvcSrcUri, drexModel.WebSvcMethod webSvcMethod)
 {
     _webSvcMethod             = webSvcMethod;
     tec_Request.Text          = webSvcMethod.Request.Body;
     pg_headers.SelectedObject = new RequestPropertyGrid(webSvcSrcUri,
                                                         webSvcMethod.Name,
                                                         webSvcMethod.Request.Headers[drexModel.WebSvcMessage.HEADER_NAME_CONTENT_TYPE],
                                                         webSvcMethod.Request.Headers[drexModel.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION],
                                                         webSvcMethod.ServiceURI);
 }
예제 #9
0
        public void TestHelloWorldStatus201()
        {
            var webMethod = new model.WebSvcMethod("HelloWorldStatus201", TestDataReader.Instance.ServiceUri);

            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]       = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorldStatus201";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorld201Request"];

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod);

            webMethod.Response = call.Work();

            Assert.AreEqual("201 Created", webMethod.Response.Status);
        }
예제 #10
0
        public void TestHelloWorldMex()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUriMex);
            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpServiceMex/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod);
            webMethod.Response = call.Work();

            var contentLengthResult = webMethod.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_LENGTH];
            var contentTypeResult = webMethod.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE];

            Assert.AreEqual("211", contentLengthResult);
            Assert.AreEqual("text/xml; charset=utf-8", contentTypeResult);
            Assert.AreEqual(webMethod.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(webMethod.Response.Status, "200 OK");
        }
예제 #11
0
        void CallWebSvcCallAsync(drexModel.WebSvcMethod webSvcMethod)
        {
            utils.Logger.Instance.Log.Info("Start " + webSvcMethod.Name);

            _cancelToken = new drexProcess.WebSvcAsync.CancelToken();

            Thread thread = new Thread(() => {
                var call             = new drexProcess.WebSvcAsync.Operations.CallAsyncOp(webSvcMethod, _cancelToken, State.Instance.ConfigTimeout.Timeout, State.Instance.ConfigProxy, utils.Logger.Instance.Log);
                call.OnComplete     += call_OnComplete;
                call.OnWebException += call_OnWebException;
                call.OnException    += call_OnException;
                call.OnCancel       += call_OnCancel;
                call.OnTimeout      += call_OnTimeout;
                call.Start();
            });

            //the windows forms control must be updated by a thread with single threaded appartment property
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
예제 #12
0
        public void TestHelloWorldMex()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUriMex);

            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]       = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpServiceMex/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod);

            webMethod.Response = call.Work();

            var contentLengthResult = webMethod.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_LENGTH];
            var contentTypeResult   = webMethod.Response.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE];

            Assert.AreEqual("211", contentLengthResult);
            Assert.AreEqual("text/xml; charset=utf-8", contentTypeResult);
            Assert.AreEqual(webMethod.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(webMethod.Response.Status, "200 OK");
        }
예제 #13
0
        public void TestHelloWorldProxy()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUriProxy);

            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var proxy = new model.Proxy();

            proxy.ProxyType = model.Proxy.EProxyType.Enabled;
            proxy.Host      = @"127.0.0.1";
            proxy.Port      = 8888;

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod, RETRIEVE_TIMEOUT, proxy, _log);

            webMethod.Response = call.Work();

            Assert.AreEqual(webMethod.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(webMethod.Response.Status, "200 OK");
        }
예제 #14
0
        public void TestHelloWorldStatus201()
        {
            var webMethod = new model.WebSvcMethod("HelloWorldStatus201", TestDataReader.Instance.ServiceUri);
            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorldStatus201";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorld201Request"];

            var call = new process.WebSvcAsync.Operations.CallAsyncOp(webMethod);
            call.OnComplete += call_OnCompleteStatus201;

            var thread = new Thread(() =>
            {
                call.Start();
            });
            thread.Name = "TestHelloWorldStatus201 Thread";
            thread.Start();
            thread.Join();

            Assert.AreEqual("201 Created", _testHelloWorldStatus201Result.Response.Status);
        }
예제 #15
0
        public void TestHelloWorldStatus201()
        {
            var webMethod = new model.WebSvcMethod("HelloWorldStatus201", TestDataReader.Instance.ServiceUri);

            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]       = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorldStatus201";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorld201Request"];

            var call = new process.WebSvcAsync.Operations.CallAsyncOp(webMethod);

            call.OnComplete += call_OnCompleteStatus201;

            var thread = new Thread(() =>
            {
                call.Start();
            });

            thread.Name = "TestHelloWorldStatus201 Thread";
            thread.Start();
            thread.Join();

            Assert.AreEqual("201 Created", _testHelloWorldStatus201Result.Response.Status);
        }
예제 #16
0
        public model.WebSvcMethodContainer GenerateSampleData()
        {
            Dictionary<string, model.WebSvcMethod> results = new Dictionary<string, model.WebSvcMethod>();

            List<string> methodList = GetMethodList();

            foreach (string method in methodList) {
                ServiceDescriptionCollection descCol = new ServiceDescriptionCollection();
                foreach (ServiceDescription sd in _descriptions) {
                    descCol.Add(sd);
                }

                XmlSchemas schemaCol;
                if (_schemas.Count > 0) {
                    schemaCol = new XmlSchemas();
                    foreach (XmlSchema sc in _schemas) {
                        schemaCol.Add(sc);
                    }
                }
                else {
                    schemaCol = descCol[0].Types.Schemas;
                }

                string req;
                string resp;

                SampleGeneratorWebSvc sg = new SampleGeneratorWebSvc(descCol, schemaCol);
                sg.GenerateMessages(method, null, "Soap", out req, out resp);

                int indexOfReqMsg = req.IndexOf(@"<soap:Envelope");
                string reqHeaderMsg = req.Substring(0, indexOfReqMsg);
                string sampleReqMsg = req.Substring(indexOfReqMsg);

                int indexOfRespMsg = resp.IndexOf(@"<soap:Envelope");
                string respHeaderMsg = resp.Substring(0, indexOfRespMsg);
                string sampleRespMsg = resp.Substring(indexOfRespMsg);

                string[] reqHeaderLines = reqHeaderMsg.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string soapAction = GetHeader(reqHeaderLines, "SOAPAction:");
                string reqContentType = GetHeader(reqHeaderLines, "Content-Type:");

                string[] respHeaderLines = respHeaderMsg.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string respContentType = GetHeader(respHeaderLines, "Content-Type:");

                model.WebSvcMessageRequest messageRequest = new model.WebSvcMessageRequest();
                messageRequest.Body = sampleReqMsg;
                messageRequest.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = reqContentType;
                messageRequest.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = soapAction;

                model.WebSvcMessageResponse messageResponse = new model.WebSvcMessageResponse();
                messageResponse.Body = sampleRespMsg;
                messageResponse.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = respContentType;

                model.WebSvcMethod webMethod = new model.WebSvcMethod(method, _serviceURI) {
                    Request = messageRequest,
                    Response = messageResponse
                };

                results[method] = webMethod;
            }

            return new model.WebSvcMethodContainer(results);
        }
예제 #17
0
 public CallSyncOp(model.WebSvcMethod webSvcMethod)
     : base(webSvcMethod.Name, DEFAULT_TIMEOUT)
 {
     _webSvcMethod = webSvcMethod;
 }
예제 #18
0
 public CallSyncOp(model.WebSvcMethod webSvcMethod, int timeoutPeriod, model.Proxy proxy, ILog log)
     : base(webSvcMethod.Name, timeoutPeriod, proxy, log)
 {
     _webSvcMethod = webSvcMethod;
 }
예제 #19
0
 public CallSyncOp(model.WebSvcMethod webSvcMethod)
     : base(webSvcMethod.Name, DEFAULT_TIMEOUT)
 {
     _webSvcMethod = webSvcMethod;
 }
예제 #20
0
 public CallSyncOp(model.WebSvcMethod webSvcMethod, int timeoutPeriod, model.Proxy proxy, ILog log)
     : base(webSvcMethod.Name, timeoutPeriod, proxy, log)
 {
     _webSvcMethod = webSvcMethod;
 }
예제 #21
0
        public model.WebSvcMethodContainer GenerateSampleData()
        {
            Dictionary <string, model.WebSvcMethod> results = new Dictionary <string, model.WebSvcMethod>();

            List <string> methodList = GetMethodList();

            foreach (string method in methodList)
            {
                ServiceDescriptionCollection descCol = new ServiceDescriptionCollection();
                foreach (ServiceDescription sd in _descriptions)
                {
                    descCol.Add(sd);
                }

                XmlSchemas schemaCol;
                if (_schemas.Count > 0)
                {
                    schemaCol = new XmlSchemas();
                    foreach (XmlSchema sc in _schemas)
                    {
                        schemaCol.Add(sc);
                    }
                }
                else
                {
                    schemaCol = descCol[0].Types.Schemas;
                }

                string req;
                string resp;

                SampleGeneratorWebSvc sg = new SampleGeneratorWebSvc(descCol, schemaCol);
                sg.GenerateMessages(method, null, "Soap", out req, out resp);

                int    indexOfReqMsg = req.IndexOf(@"<soap:Envelope");
                string reqHeaderMsg  = req.Substring(0, indexOfReqMsg);
                string sampleReqMsg  = req.Substring(indexOfReqMsg);

                int    indexOfRespMsg = resp.IndexOf(@"<soap:Envelope");
                string respHeaderMsg  = resp.Substring(0, indexOfRespMsg);
                string sampleRespMsg  = resp.Substring(indexOfRespMsg);

                string[] reqHeaderLines = reqHeaderMsg.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string   soapAction     = GetHeader(reqHeaderLines, "SOAPAction:");
                string   reqContentType = GetHeader(reqHeaderLines, "Content-Type:");

                string[] respHeaderLines = respHeaderMsg.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                string   respContentType = GetHeader(respHeaderLines, "Content-Type:");

                model.WebSvcMessageRequest messageRequest = new model.WebSvcMessageRequest();
                messageRequest.Body = sampleReqMsg;
                messageRequest.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE]       = reqContentType;
                messageRequest.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = soapAction;

                model.WebSvcMessageResponse messageResponse = new model.WebSvcMessageResponse();
                messageResponse.Body = sampleRespMsg;
                messageResponse.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = respContentType;

                model.WebSvcMethod webMethod = new model.WebSvcMethod(method, _serviceURI)
                {
                    Request  = messageRequest,
                    Response = messageResponse
                };


                results[method] = webMethod;
            }

            return(new model.WebSvcMethodContainer(results));
        }
예제 #22
0
        public void TestHelloWorldProxy()
        {
            var webMethod = new model.WebSvcMethod("HelloWorld", TestDataReader.Instance.ServiceUriProxy);
            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorld";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorldRequest"];

            var proxy = new model.Proxy();
            proxy.ProxyType = model.Proxy.EProxyType.Enabled;
            proxy.Host = @"127.0.0.1";
            proxy.Port = 8888;

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod, RETRIEVE_TIMEOUT, proxy, _log);
            webMethod.Response = call.Work();

            Assert.AreEqual(webMethod.Response.BodyUnformatted, TestDataReader.Instance.RequestResponseMessages["HelloWorldResponse"]);
            Assert.AreEqual(webMethod.Response.Status, "200 OK");
        }
예제 #23
0
        public void TestHelloWorldStatus201()
        {
            var webMethod = new model.WebSvcMethod("HelloWorldStatus201", TestDataReader.Instance.ServiceUri);
            webMethod.Request = new model.WebSvcMessageRequest();
            webMethod.Request.Headers[model.WebSvcMessage.HEADER_NAME_CONTENT_TYPE] = "text/xml; charset=utf-8";
            webMethod.Request.Headers[model.WebSvcMessageRequest.HEADER_NAME_SOAP_ACTION] = "http://tempuri.org/ICallSyncOpService/HelloWorldStatus201";
            webMethod.Request.Body = TestDataReader.Instance.RequestResponseMessages["HelloWorld201Request"];

            var call = new process.WebSvcSync.Operations.CallSyncOp(webMethod);
            webMethod.Response = call.Work();

            Assert.AreEqual("201 Created", webMethod.Response.Status);
        }