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"); }
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(); }
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); }