WCF in .Net 3.5 support REST on server side using [WebGet]. But there are no SOAP/WSDL proxy auto-gen tool. In fact, REST messages will come off wire through WebClient and we can use DataContractSerializer to bind back to a CLR object.
namespace GMO
{
[DataContract()]
public class Stock
{
[DataMember]
public double Price { get; set; }
[DataMember]
public string Symbol { get; set; }
public override string ToString()
{
return Price.ToString();
}
}
using Data;
[ServiceContract]
public interface IPostTrade
{
[OperationContract]
[WebGet()]
List<object> GetInstrumentList(string tradeID);
[OperationContract]
[WebGet()]
bool HasSettled(string TradeID,string InstID);
[OperationContract]
[WebGet()]
List<Stock> GetStockHoldings(string BlotterID);
}
}
DataContractSerializer ser = new DataContractSerializer(typeof(List<GMO.Data.Stock>));
WebClient c= new WebClient();
Stream r = c.OpenRead(@"http://localhost:49176/PostTrade.svc/GetStockHoldings?blooterID=0");
List<GMO.Data.Stock> list=(List<GMO.Data.Stock>)ser.ReadObject(r);
listBox1.ItemsSource = list;
1 comment:
Nice Blog. It will help us in WCF
--
Khabir
Aprosoft,Bangladesh
Post a Comment