public static void Main(string[] args) { TestServiceClient objClient = new TestServiceClient(); Console.WriteLine(objClient.DoWork()); Console.Read(); }
//[ExpectedException] public void TestLocalServiceMethod() { TestServiceClient objService = new TestServiceClient("WSHttpBinding_ITestService"); string str = objService.DoWork(); //ArithmaticOperations obj = new ArithmaticOperations(); //int i = obj.Divide(2, 1); Console.WriteLine("TestLocalServiceMethod output :" + str); }
protected void BtnDoWorkClick(object sender, EventArgs e) { try { var client = new TestServiceClient(); client.Open(); client.DoWork(); client.Close(); } catch (Exception eException) { Debug.WriteLine(eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + (eException.InnerException != null && !string.IsNullOrEmpty(eException.InnerException.Message)? "InnerException.Message" + eException.InnerException.Message + Environment.NewLine : string.Empty) + "StackTrace:" + Environment.NewLine + eException.StackTrace); } }
public static void Main(string[] args) { try { TestServiceClient objClient = new TestServiceClient("WSHttpBinding_ITestService1"); Console.WriteLine(objClient.DoWork()); } catch (FaultException <Faults> Fex) { EventLog Log = new EventLog(); Log.Source = "TestConsoleApplication"; Log.WriteEntry(string.Format(@"{0} has raised exception of {1} type with {2} {3}", Log.Source, "Service", Fex.Detail, Fex.Message), EventLogEntryType.Error); } }
protected void myButton_Click(object sender, EventArgs e) { try { //throw new HttpException(402, "custom error"); TestServiceClient objClient = new TestServiceClient("WSHttpBinding_ITestService"); string str = objClient.DoWork(); } catch (FaultException <Faults> Fex) { EventLog Log = new EventLog(); Log.Source = "TestWebApplication"; Log.WriteEntry(string.Format(@"{0} has raised exception of {1} type with {2} {3}", Log.Source, "Service", Fex.Detail, Fex.Message), EventLogEntryType.Error); } finally { } }
public static void Main(string[] args) { //ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); //string str = client.GetData(23); //Console.Write(str); //MyService.Service1Client objSer = new MyService.Service1Client("MyWsHttpContract"); //Console.Write(objSer.GetData(100)); //string gg = Console.ReadLine(); //MyService.Service1Client objSer2 = new MyService.Service1Client("basicbinding"); //Console.Write(objSer.GetData(100)); RealServiceReference.TestServiceClient objNew = new TestServiceClient("WSHttpBinding_ITestService"); //AsyncCallback async = ProgressBar pr = new ProgressBar(); Console.WriteLine(objNew.DoWork()); //IAsyncResult result = objNew.BeginDoWork(null, null); //if (!result.AsyncWaitHandle.WaitOne(2000)) //{ // MyProgressBarDelegate objDel = new MyProgressBarDelegate(pr.MyProgressBar); // IAsyncResult result2 = objDel.BeginInvoke(null, null); // objDel.EndInvoke(result2); // string display = objNew.EndDoWork(result); // Console.WriteLine(display); // result.AsyncWaitHandle.Close(); //} TestWCF.TestServiceReference.TestServiceClient objClient = new TestServiceReference.TestServiceClient(); Console.WriteLine(objClient.DoWork()); string gg2 = Console.ReadLine(); }
private void InvokeService(int delay) { this.Trace.Write(string.Format("Calling service on thread {0}", Thread.CurrentThread.ManagedThreadId)); var proxy = new TestServiceClient(); try { var result = proxy.DoWork(delay); proxy.Close(); this.Trace.Write(string.Format("Completed calling service on thread {0} delay {1}", Thread.CurrentThread.ManagedThreadId, result)); this.labelDelay.Text = result.ToString(); } catch (Exception) { proxy.Abort(); throw; } }