DCSIMG
May 2008 - Posts - justguy's

May 2008 - Posts

Combining a WCF Service with a Web Service (or SharePoint Designer doesn't work with WCF)

Recently I've started working with WCF services for all the right reasons.
I noticed SharePoint Designer cannot consume WCF services. I'm guessing it has something to do with SOAP versions.

After a short investigation I came up with a hybrid: a service you can use as a WCF Service and a Web Service (.asmx and .svc).
I have suggested this solution to Microsoft Gold Support and got a "OK. We'll look into this."

How do we do it?

  1. Create/Find a WCF Service.
  2. Create a new Web Service.
  3. Copy the Web Wervice's we.config into the WCF's web.config (not app.config).
    Make sure you don't lose the WCF tag (under configuration):

    <system.serviceModel>
    ...
    </system.serviceModel>

  4. Copy the .asmx from the Web Service to the WCF project and modify it accordingly:

    <%@ WebService Language="C#" CodeBehind="Service1.cs" Class="WCFService1.Service1" %>

  5. If you don't already have one, create a .svc file for the WCF Service:
    
    

    <%@ServiceHost Service="WCFExample.Service1" %>

  6. The service class has to inherit WebService and implement the service interface:




    public class Service1 : System.Web.Services.WebService, IService1

  7. Add the [WebMethod] attribute (reference System.Web.Services) to the functions you want to expose using the Web Service.
  8. Host the entire thing in the IIS.
  9. Cross your fingers...
    To access the web serivce, use the .asmx, and for the WCF, use the .svc.

Good luck!
 Edit: Found this article in MSDN: How to: Migrate ASP.NET Web Service Code to the Windows Communication Foundation
 P.S. Sorry for the small fonts at the end of the post. I cannot install Live Write, and HTML <font> tags bug me.
Posted by justguy | with no comments

My first post (2nd try)

Hi,

 I've been told a blog is the thing. So here it is.

 My name is Adi Levinshtein, and I've been working in the IT industry for the past 4.5 years.
During the past 2.5 years I've been working with ASP.NET and specializing in Microsoft SharePoint.
Currently I'm a team leader and a consultant working for Bynet Software.

I'll try to keep things interesting, so nothing about my cat... :P

 Cheers!

Posted by justguy | 4 comment(s)