none
WCF REST & Biztalk Server 2006 R2 RRS feed

  • Question

  • Hello,
    Sorry for posting this question again.
    I have a WCF RESTful service which got a method with 3 parameters and that could be invoked by HTTP PUT. Its URL takes 2 parameter and i have to pass  third parameter as payload to this PUT. As third parameter's text or data is going to be large in size.
    I kept my payload parameter as 1st in parameter list of method(according to rules) and i can easily make a call to this through my C# code. But my real problem is to make a call through Biztalk adapters. My question is how to do this?
    Ben replied me saying that you can use CustomBinding and then choose webHttpBinding but that still does not give me all options.
    I am also posting code which i wrote for testing, please let me know that how could i do same kind of task as i am doin gin my C# code.
    please respond as i am getting no help form any book and online contents.

    Please see code below:-

    My Service-

    [ServiceContract]
        public interface IService
        {
            [OperationContract]
            [WebInvoke(UriTemplate = "PostInfo/name/{name}/age/{age}", Method = "PUT")]
            Customer PostInfo(string data, string name, string age);
        }


        public class Service : IService
        {
           

           


            public Customer PostInfo(string data, string name, string age)
            {
                return new Customer { ID = age, Name = "Hello, " +name };
            }

           
        }


        [DataContract(Namespace = "")]
        public class Customer
        {
            [DataMember]
            public string ID { get; set; }
            [DataMember]
            public string Name { get; set; }
        }
       
        class Program
        {
            static void Main(string[] args)
            {
                Uri baseAddress = new Uri("http://127.0.0.1:8000");

                using (WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress))
                {
                    host.Open();
                    Console.WriteLine("Press any key to terminate");
                    Console.ReadLine();
                }
            }
        }



    My Client-


    string name = "Testing";
                string age = "20";
                string builder = "<person><name>ram</name><age>20</age></person>";
                Uri baseAddress = new Uri("http://127.0.0.1:8000/PostInfo");

               
                UriTemplate uriTemplate = new UriTemplate(
                   "name/{name}/age/{age}");

                Uri newBookmarkUri = uriTemplate.BindByPosition(baseAddress, "skonnard", "123");

                HttpClient httpClient = new HttpClient();
                HttpResponseMessage httpWebResponse = httpClient.Put(newBookmarkUri, HttpContentExtensions.CreateDataContract<string>(builder));
                if (httpWebResponse.StatusCode == HttpStatusCode.OK)
                {
                    string status = "OK";
                }


    thanks,
    Ram Kinkar Pandey


    Software Engineer
    Tuesday, August 25, 2009 11:19 AM

Answers

  • Could you just call the WCF REST service via a C# reference project?

    The main disadvantage of this is the configuration would not be dynamic in the DLL, and you would have to externalize the configuration. If you cannot get it working with a built-in adapter and do not want to build a custom adapter, a custom .NET reference is simplest.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Tuesday, August 25, 2009 3:58 PM
    Moderator

All replies

  • Could you just call the WCF REST service via a C# reference project?

    The main disadvantage of this is the configuration would not be dynamic in the DLL, and you would have to externalize the configuration. If you cannot get it working with a built-in adapter and do not want to build a custom adapter, a custom .NET reference is simplest.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Tuesday, August 25, 2009 3:58 PM
    Moderator
  • Yes Ben,
    Perhaps you are right, my architect is also suggesting this approach. But when some expert replied same then it seems that this is not a bad solution.
    As writing a Custom adapter need lots of skills and care. So calling it by a .NET reference seems fine for this.
    Thanks for yours response.
    Software Engineer
    Tuesday, August 25, 2009 4:09 PM
  • I think of the BizTalk REST support still a little immature. Only 1 binding does not give you a lot of out-of-the-box flexibility. Do you have any suggestions for features you could not find in the webHttp binding that you needed? I could pass along to the BizTalk product team.

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, August 26, 2009 3:23 PM
    Moderator
  • I have a suggestion as for right now I am trying to compare BizTalk to using WCF Rest Entity services for exposing a database. If BizTalk can not doe this I do not see why I should pursue it.
    Friday, February 25, 2011 5:17 PM