none
WCF with existing ServiceContract RRS feed

  • Question

  • I have an existing design of a service interface in the form of C# classes marked with the ServiceContract and DataContract attributes.

    The DataContracts define the messages that the service operation will take.

    How do I get the WCF Adapter to in effect host my service contract?  I.e., I want the implementation of my contract to be a biztalk orchestration.

    I'm coming at this from a .net developer perspective, so I'm less familiar with Biztalk.
    Wednesday, January 23, 2008 8:28 PM

All replies

  • From what you say, I understand that you wish to publish your orchestration as a web service / consume a web service in an orchestration. For both purposes, you can use one of the WCF adapters as described here http://msdn2.microsoft.com/hi-in/library/bb259952(en-us).aspx . I hope this helps.

    Thanks,

    Manas.

    Wednesday, January 23, 2008 9:26 PM
  •  Manas Garg - MSFT wrote:

    From what you say, I understand that you wish to publish your orchestration as a web service / consume a web service in an orchestration. For both purposes, you can use one of the WCF adapters as described here http://msdn2.microsoft.com/hi-in/library/bb259952(en-us).aspx . I hope this helps.

    Thanks,

    Manas.



    Perhaps I wasn't being clear enough.  Lets say I have a .net dll with the following class compiled into it:

    [DataContract]
    public class SvcRequest
    {
      [DataMember]
      public int Value1 { get; set; }
    }

    [ServiceContract]
    public class MySvc
    {
      [OperationContract]
      int DoOperation(SvcRequest request);
    }


    Now lets say I want to implement DoOperation as a Biztalk Orchestration.  What that means is I want to use the WCF adapter at the start of my orchestration, but I already know the contracts and messages I want to use because I have them defined in my c# dll.  How do I do this?


    Wednesday, January 23, 2008 9:46 PM
  • You can host your service and point to your service URL using WCF adapter.

     

    Thursday, January 24, 2008 8:51 AM
  •  Tapas Nayak wrote:
    You can host your service and point to your service URL using WCF adapter.

     



    I want Biztalk to be the service provider of an existing contract.  Not the consumer.
    Thursday, January 24, 2008 2:50 PM
  • If I understand you correctly, you want BizTalk to host your service.

     

    Your service implementation exists inisde a .Net assembly and you want BizTalk to be the hosting layer that clients use to access your .Net component, correct?

     

    One major point to add here...

    You can't tell a WCF Receive Adapter to use a Custom ServiceContract. By Default it has 5 different ServiceContracts it exposes and which one it chooses is dependent on the bindings selected. These are the contracts that WCF Rcv exposes, and its design is a loosely coupled design that allows you to receive any data in as long as the custom contract sending in the information is not set to IsOneWay = true, which is only allowed for MSMQ bindings.

     

    Now, saying this what you're attempting to accomplish can be done however.

     

    (Coming from a .NET dev view...)

    If you have an existing Service Contract, Operation Contract, and DataContract, and you want BizTalk to honor that contract, you have a few options.

     

    Let's start generically how to do this, and then I talk about the Orchestration way.

     

    1) Create a BizTalk schema that reflects your DataContract. Use the XSD.exe tool to create a Xml Schema document from the C# class representing your class marked up with the DataContract.

     

    OR

     

    2) Create a BizTalk schema using the SVCUtil.exe tool to create an xml schema document.

     

    Either way, you'll need a schema, deploy the schema into BizTalk server.

     

    Create a receive location using one of the WCF Adapters of your choice, and a particular pipeline.

     

    Use the BizTalk WCF Services publishing wizard and use the Expose Schema as a Service option, select the Receive location and name the service and operation according to what you've previously designed. Assign the Deployed Schema to the message for the operation you've named. Choose MetaData option if you want, and IIS VDir name. This creates a IIS VDir and a ASP.NET WCF Service named,  [ServiceName].svc that implements the [ServiceContract] and [Operation] you've specified. (SideNote: You actually have even more control by modifying the various files generated within the "temp" folder of the IIS VDir that's created if the wizard successfully completes.) http://msdn2.microsoft.com/en-us/library/bb246047.aspx

     

    Lastly, you'll need to tell BizTalk how it should invoke your C# implementation.  You can do so using an Orchestration, Map, or Pipeline.

     

    So create an orchestration, or a custom pipeline component, or Map that invokes the specific .Net code you want to actually implement the code.

     

    You're Finished...

     

    Now with an orchestration, if you want to create an orchestration that matches your existing Service, Operation and DataContracts, that is inside of a C# assembly, this is a little more involved. Because there are multiple facets that go into creating a matching Contract.

     

    You'll need to match a corresponding Request/Response Public "Logical" Port name with the name of the service, you'll need to match the Operation name with the name and action of your Operation Contract. You'll need the match the Request and Response types and names with that of your C# contract. Lastly you'll need to match the name of the Orchestration with your Service Contract. I don't remember how all the values should match off the top of my head, however you will run into some limitations and naming conflicts if you're not careful.  After you've matched all the names to the appropiate C# contracts and marked up settings, you'll need to use the WCF Publishing wizard to expose the Orch as a WCF Service, keeping in mind that this wizard doesn't allow you to control the naming, it's hard coded to what you've designed within the Orchestration.  This is why I prefaced this topic with the Generic way to do it first. You have complete control!

     

     

     

    HTH

    Dwight
    Sunday, January 27, 2008 10:16 AM