Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 = "http://aim.oscautomation.com")]
[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 
        //InitializeComponent(); 
    }
 
    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
        
        [WebMethod]
        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
v3
Comments
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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello,
 
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!
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Comments
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 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
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