Sunday, 12 January 2014

Create a One-Way web service

In this article we are going to see the how to create a one way web service in the so for long running process we can invoke the service and do the next process instead of waiting for the response from the service. set [SoapDocumentMethod(OneWay=true)]

web service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Runtime.Remoting.Messaging;
using System.Web.Services.Protocols;
using System.IO;
using System.Threading;

namespace MathService
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    public class MathService : System.Web.Services.WebService

        public int Add(params int[] values)
            return values.Sum();

        public void WriteLog(string message)


namespace InvokeWebService
    class Program
        static void Main(string[] args)
            Maths.MathService websrv = new Maths.MathService();
            Console.WriteLine("Connecting service . . . ");           
            int addvalue = websrv.Add(new int[] { 3,2,6,7});
            Console.WriteLine(" Add Operation result : " + addvalue);

            int subvalue = websrv.Sub(4, 2);
            Console.WriteLine(" Sub Operation result :" + subvalue);

            websrv.WriteLog("This is called as async, by Rajesh. G");


This is called as async, by Rajesh. G

A log file is created in the server side with the information send by the user.

No comments:

Post a Comment