WCF- REST-SOAP -Few Tricks and few Links-Part1

Posted: December 5, 2008 in Architecture Series
1. REST GET with StringArray as Input parameter to Get Method:-
Define same service with 2 endpoints one for webhttp for rest and one for soap.
let the service accept a string array.
Now when you browse the service it ll throw error ‘System.String[]’ is not convertible by ‘QueryStringConverter since rest method does not support the string array as input parameter.
   <endpoint address="secure" binding="basicHttpBinding" contract="SilverlightApplication1.Web.EmployeeService" />
       <endpoint address="" binding="webHttpBinding" behaviorConfiguration="webBehavior" contract="SilverlightApplication1.Web.EmployeeService"  />
The issue is although the soap works fine..once you define mutiple endpoint it does not work.The way to work around this is for soap you can pass the bindig name ehile instantiating the proxy.For REST the easiest alternative is to pass deleted string and parse it.Although this always pose a limitation,you have live it with.
Another quick around is to use this :-How to: Create a Service That Accepts Arbitrary Data using the WCF Web Programming Model
Do note that you can pass Array or custom objects to PUT and POST but not to get method.So if you have the following:-

public IEnumerable<Employee> SearchEmployeeByRandomFields(String strSearch, string[] retFields)
        { — search operation code —  }
you ll get  Request Error – The server encountered an error processing the request. See server logs for more details
2.Quick REST Learning Resources:-

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s