Converting Web Service to WCF - c#

I recently wrote a wrapper (C#) for an ApplinX web service - this is a product that is part of the Software AG Adabas offering. The web service interface is really primitive and I wrote the wrapper to make it easier to use.
The wrapper is in use on web applications (C# + Asp.Net) but I want to a Windows client to access it using WCF. Would it be better to write the WCF services from scratch or simply wrap the existing wrapper in WCF?

Is the wrapper in a seperate class library? If not, you can move the wrapper into a class ibrary and allow both the ASP.NET app and the windows client app to consume it. This would eliminate any adition wrappers and abstraction layers. It would also allow the windows client to directly consume the service without having to go through the ASP.NET application.
If you wrap the current wrapper in as a WCF service, then from the windows client, you will be making a service call to your ASP.NET app, which will turn around and make another call to the service it is consuming. The above recommendation will eliviate that. If however there is some business logic you need to encapsulate and only want to be on the server, then I would create a WCF service on the ASP.NET application and wrap the calls to your wrapper service in that. The Windows client can then consume the WCF service.

Related

Saving Variables Across Calls in WCF as a Windows Service

I created a WCF Service Library, which I host via a Windows Service.
Is it possible to save information across API calls?
I know that if I host the WCF Service Library in IIS with ASP.Net compatibility turned on and making a few modifications to the WCF library that I can use
HttpContext.
HttpContext.Current.Session["name"] = <value>;
WCF started as a Windows Service does not have ASP.Net support to the best of my knowledge, as the library is not hosted by IIS. Is there a way for a WCF library launched via a Windows Service to save information across calls for a specific caller?

Is a WCF Web Service an API?

I am working on a Visual Studio Application that references a WCF web service, and after some reading online I am pretty confused.
I have read that WCF is a framework for building a web service, but it is not an API. Is this true?
I was under the impression that Web Services are APIs; I always thought that APIs were Software as a Service (SaaS). Doesn't that mean that APIs and Web Services are pretty much the same thing? Or do I have the wrong idea?
Could this be a misconception of my understandings of SOAP and REST?
Basically I want to know whether a WCF built web service counts as an API, and why/why not?
WCF is an API that can be used to create APIS within your application.
Web Services usually involves creating an API within your application. There are valid APIs that are not Web Services, like the Win32 API.
Its possible to build a WCF web service with one web method for an application that would not be considered an API specifically since it does not contain a set of routines, protocols, or tools for building applications.
Review http://en.wikipedia.org/wiki/Application_programming_interface for what an API is.
According to wikipedia, yes, yes it is:
APIs often come in the form of a library that includes specifications
for routines, data structures, object classes, and variables. In other
cases, notably SOAP and REST services, an API is simply a
specification of remote calls exposed to the API consumers.
An API (Application Program Interface) is a way to interact with components of a system. It defines the operations that can be used to get data out or push it in.
WCF (Windows Communication Foundation) itself is a framework for building web services and other applications that need a communication channel to share data with other services/applications, it is actually a lot larger on what it can do. You can read more about it on MSDN. It is an API as it gives you objects that allow you to tell it interact with its' components.
REST and SOAP are just architecture styles that can be used to serve data via a service, it is defining how you should interact with the data rather than the components themselves.

Can PHP interact with WCF web servives

My company currently have web services written in WCF in C#, I have been asked to adjust my interface to interact with the web services, the interface is written in PHP/HTML. It will be running VIA IIS as well as the services.
Is this possible or do I need to tell me boss we need to go back to the drawing board
WCF Services can be accessed by any other application that is built on any platform and using any programming language.Web services are interoperable.
You can either expose a REST endpoint:
http://msdn.microsoft.com/en-us/magazine/dd315413.aspx
Or just put a ASP.Net Web API in front of your WCF service to act as a middle man:
http://www.asp.net/web-api
In php there are a number of ways of talking to a RESTful service, here is one library that can help:
http://phphttpclient.com/

How to expose a service layer to UI components

We have an application in which we have created a service layer with most of the business logic and utility services (logging, exceptions, caching etc). We have to come with a way to expose this service as an API to the UI components. Here are some of our requirements:
We would like to create multiple
components based on the service.
We would like third party developers
to use our service to create their
own components or utilize our data.
For scalability we would like to have
a multiple instances installed on
different boxes. Similarly there
could be more than an instance of the
same UI component.
One way to expose the service layer is to host it under a REST based WCF layer.
The other way is to host the service in model layer of an ASP.Net MVC project. The UI components will be hosted in MVC projects of their own. The Javascript in the views of UI components will directly call the controllers of service project.
WCF is supposed to be very heavyweight option. On the other hand I am not too convinced with the MVC approach as I feel that this is not purpose it is meant for.
Could you please recommend me a way in Microsoft world to expose our service layer.
WCF seems to be the way to go here. Although WCF started out (in my oppinion) as a beast, it got tamed over the years with better HTTP and JSON support and less custom configuration (although still allowing you to modefy basicly every little aspect of your service).
Exposing your current service layer as a REST Service is a breeze and allows your customers/yourself to easily consume it on any device that supports HTTP.
See: http://codebetter.com/glennblock/2010/11/01/wcf-web-apis-http-your-way/
Models are not services. Models are POCOs that hold data.
You can expose your service through a WCF Service, and let your ASP.NET MVC app consume it. If you're always sure that the service will run on the same box as the client app, you can use named pipes for transport -- then the overhead of WCF is minimal, compared to the advantages.
WCF seems to be the direction that Microsoft is headed for this and for good reason. WCF services are the best option here because you mentioned third-party development support. Because these web services are defined by a WSDL, they are cross platform and can be consumed by non .NET applications.
It perfectly seperates your service layer to be consumed by ANY components.

iPhone communication with Windows C# App

I am create an iPhone app that needs to talk to a Windows C# app. The app will run as either a Service or Form Application.
What would be the best way to accomplish this? Ideally exposing a service-type architecture would be best as I don't need a stateful connection (stateless is fine in this case).
Can a WCF service hosted by my app using a form of TCP binding be consumed by my iPhone? Or can an app host using httpBinding without the aid of IIS or some other web server?
To run WCF on iPhone you need MonoTouch. Currently, which isn't completely implemented.
I don't think it's a good idea.
Web Service are a better idea in my opinion. You can spawn a web service listener from your console/gui/service Windows C# application.
Here's what I ended up doing:
In my .NET windows service, I created WCF service bound using a WebHttpBinding endpoint. Doing so exposed my WCF services as JSON.
From the iPhone, using Objective-C, I used the ASIHTTPRequest and json-framework libraries to talk to and parse the JSON web service exposed by my .net app.
Expose your C# application functionality as a ReSTful web service. More information on exposing WCF service is available here
And there are project templates available for creating REST WCF service. Download the WCF REST starter kit.You can expose your service in XML/JSON format.
Then from your iPhone app, you may consume the web service exposed.

Categories

Resources