DataContract -> control input and output
ServiceContract --> control the method
1. Create a interface (Service Contract) to define the methods available
2. Define Data contract if any
3. Create a host (.svc)to implement the interface
4. Client to consume
Friday, April 8, 2011
MSMQ
MessageQueue messageQueue = null;
if (MessageQueue.Exists(@".\Private$\MyTestingQueues"))
{
messageQueue = new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Testing Queue 1";
Message objMsg = new Message ();
objMsg.Label = "Test Label";
objMsg.Body = "Content 1";
//messageQueue.Send(objMsg);
//TEST
CondoEntity objEntity = new CondoEntity();
objEntity.ListingGUID = Guid.NewGuid();
objEntity.Name = "test";
messageQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(CondoEntity) });
messageQueue.Send(objEntity);
}
else
{
// Create the Queue
MessageQueue.Create(@".\Private$\MyTestingQueues");
messageQueue = new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Newly Created Queue";
}
messageQueue.Send("First ever Message is sent to MSMQ", "Title");
if (MessageQueue.Exists(@".\Private$\MyTestingQueues"))
{
messageQueue = new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Testing Queue 1";
Message objMsg = new Message ();
objMsg.Label = "Test Label";
objMsg.Body = "Content 1";
//messageQueue.Send(objMsg);
//TEST
CondoEntity objEntity = new CondoEntity();
objEntity.ListingGUID = Guid.NewGuid();
objEntity.Name = "test";
messageQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(CondoEntity) });
messageQueue.Send(objEntity);
}
else
{
// Create the Queue
MessageQueue.Create(@".\Private$\MyTestingQueues");
messageQueue = new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Newly Created Queue";
}
messageQueue.Send("First ever Message is sent to MSMQ", "Title");
Friday, April 1, 2011
Selection - Enum
enum ExpenseCategory
{
LocalTravel = 0,
Medical = 1,
Others = 2
}
Load these values with Name into dropdown selection
EnumGetNames(typeof(ExpenseCategory));
{
LocalTravel = 0,
Medical = 1,
Others = 2
}
Load these values with Name into dropdown selection
EnumGetNames(typeof(ExpenseCategory));
Tuesday, March 29, 2011
REST WCF
if your have the following function in WCF. You will need the following input.
[WebInvoke(UriTemplate = "testFunction", Method = "POST",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat =
WebMessageFormat.Json)]
public string testFunction(string test)
{
Expected Header
User-Agent: Fiddler
Host: localhost:5810
Content-Length: 15
Content-Type: application/json
INPUT:
{"test":"1234"}
OUTPUT:
{"testFunctionResult":"hi, 3\/29\/2011 10:46:56 PM 1234"}
You can make use of fiddler to send http post request. This illustrated the WCF REST function with JSON input and output.
[WebInvoke(UriTemplate = "testFunction", Method = "POST",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat =
WebMessageFormat.Json)]
public string testFunction(string test)
{
Expected Header
User-Agent: Fiddler
Host: localhost:5810
Content-Length: 15
Content-Type: application/json
INPUT:
{"test":"1234"}
OUTPUT:
{"testFunctionResult":"hi, 3\/29\/2011 10:46:56 PM 1234"}
You can make use of fiddler to send http post request. This illustrated the WCF REST function with JSON input and output.
Thursday, March 24, 2011
Subscribe to:
Posts (Atom)