Click here to Skip to main content
11,496,146 members (463 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: C# WCF
I would like to know if it is possible to transfer data from a windows service to either a web service or a wcf service. I have read different article that lead me to think that this might could be done using SOAP. I have never attempted to make 2 applications communicate before so any help is appreciated. Thanks in Advance.

C# console app....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Net;
using System.Diagnostics;
using System.Configuration.Assemblies;

namespace Soap_Test
    class Program
        static void Main(string[] args)
            string name = "Dustin";
            Aim.NameRequest request = new Aim.NameRequest();
            Aim.ServiceSoapClient serv = new Aim.ServiceSoapClient();
            Aim.NameResponse test = serv.Name(request);
            return name(test);

Wcf Service

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
[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. 
// [System.Web.Script.Services.ScriptService]

public class Service : System.Web.Services.WebService
    public Service () {
        //Uncomment the following line if using designed components 
    public string HelloWorld() {
        return "Hello World";
        public string Name()  {      
            return "Name";

Still not completely understanding the whole request part of everything. Thank you so far for your help. Please let me know what I am missing.
Posted 19-Apr-13 5:20am
Edited 19-Apr-13 8:59am
ryanb31 at 19-Apr-13 12:12pm
Yes, you can connect a windows service to a webservice. In fact a console app, windows forms app, web app, just about anything can call a webservice.

You can add a reference to the wcf services from the windows service.
If you're using Visual Studio you can abstract from SOAP protocol, because everything is set for you.

Good luck!
once you have your service up you can create a project (it could be a web API) that calls it and then send it in REST

If you go for the webApi
add the service to your project, and in the controller inside the method do this:
 yourService.yourMethodRequest request = new yourService.yourMethodRequest();
            yourService.ServiceClient serv = new yourService.ServiceClient();
             yourService.yourMethodResponse test = serv.yourMethod(request);
            return View(test);

This will return it like json or XML to be call in REST

if you want to go for the WCF solution read this Reusing WCF Service Across Several Applications using Different Bindings[^]

Hope it helps
Dustin Prevatt at 19-Apr-13 13:47pm
Thank You for your reply! Please take a look at my code above. The yourMethodRequest part I am not quite understanding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100