views:

407

answers:

2

can't I expose my methods as webmethods in a winform and have other clients call them as webservice? Basicall I am trying to get my winform app to host a webservice without asp.net or iis.

I am trying to get a ^%&^& blackberry to communicate with my winform app....tried for hours looking for some other way of getting the two to talk without http webservice.

I was looking at UDP but && BB does not provide any documentation for Visual Studio development other than webservice.

A: 

Sort of. You can host a SOAP service using WCF, but I'm not sure if that's a great architecture.

Steven Sudit
You can host _any_ WCF service, not just one based on SOAP. And can you say what the problem is with the architecture?
John Saunders
Sure, WCF doesn't restrict you to SOAP. The original question did specify web services, which implied SOAP, so that's what I addressed.As for my architectural misgivings, I think they come down to having a GUI app exposing a web service, in the server role. Perhaps it's just my limited experience, but GUI's are typically clients. In other words, I would see the GUI as a way to configure the web server that the BB connects to, rather than being that server. This has advantages in terms of managing firewalls and such.
Steven Sudit
"Web Services" doesn't really imply anything nowadays. A service returning JSON is still called a web service.
John Saunders
That's true, but SOAP is the default for the ASMX webmethods mentioned in the original question, so that's what I went with in my answer. My architectural misgivings apply equally to JSON; I guess I just don't like clients playing server. Client machines tend to be hidden behind such things as firewalls with NAT, so they're not always easy to reach from outside. In fact, this is one of the issues that CoPilot had to deal with, and their solution was to have the clients connect to a middleman that proxies for them. Thanks for bringing up the JSON issue, though.
Steven Sudit
+1  A: 

One thing many people have a problem with is they forget that they need to add a firewall rule or foreword a port to allow outside connection to the endpoint when trying to communicate from a hand-held device that is using the carrier's internet connection (rather than wifi). it could be completely missed since the blackberry is sitting right next to you and you don't think of it as an outside caller.

if that's not the case try a WCF hosted app

You can expose your service using a WCF endpoint.

from http://msdn.microsoft.com/en-us/library/ms731758.aspx

   // Host the service within this EXE console application.
    public static void Main()
    {
      // Create a ServiceHost for the CalculatorService type and use
      // the base address from config.
      ServiceHost hostDefault = new ServiceHost(typeof(CalculatorService));

      int manualFlowControlLimit =  hostDefault.ManualFlowControlLimit;


      basicHttpBinding portsharingBinding = new basicHttpBinding();
      hostDefault.AddServiceEndpoint(typeof( CalculatorService ),portsharingBinding,"http://localhost/MyService" );

      using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
      {
         // Open the ServiceHost to start listening for messages.
       serviceHost.Open();
       // The service can now be accessed.
       Console.WriteLine("The service is ready.");
       Console.WriteLine("Press <ENTER> to terminate service.");
       Console.ReadLine();

       // Close the ServiceHost.
       serviceHost.Close();
      }
    }
Keivan
Do I call this like a regular webservice (say from the blackberry device) or any other app?
Saif Khan
yes, exactly. you should be able to.
Keivan
have you tried calling WCF service from a BB? I tried what you said, it works fine, calling the service from a windows app. When adding the reference in the Blackberry App I get [Error] - Web reference generation failed. There is an error in XML document (1, 2).
Saif Khan
Keivan