Business and Technology Consulting Organization in Mumbai

Electronic Transformation Globally Technology Solution IT Consultancy Service Provider

WCF Client Proxy,WCF Developer in Mumbai India

Windows Communication Foundation
Here i share a WCF implementation structure with a web application, the structure are devided into 3 solutions with 6 assemblies, this can be changed as per requirement. As you can see the structure above.
Here we look how to create proxy classes, and how it look like.
We can create proxy client by using the command

svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://etg1:8020/ETG.Base.Applications.WCF/WebClient
We have expert WCF developer in mumbai india, Please contact us to know more about our service.
Service sample
using System;
1:using System.Collections.Generic;
2:using System.Text;
3:using ServiceAgent;
4:using System.ServiceModel;
5:using System.ServiceModel.Channels;
6:using System.Security;
7:using BusinessEntity;
8:
9:namespace ProxyService.Module1
10:{
11: [System.Diagnostics.DebuggerStepThroughAttribute()]
12: [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
13: public partial class RoomAgent : System.ServiceModel.ClientBase<IRoomAgent>, IRoomAgent
14: {
15: public RoomAgent()
16: {
17: }
18:
19: public RoomAgent(string endpointConfigurationName)
20: :
21: base(endpointConfigurationName)
22: {
23: }
24:
25: public RoomAgent(string endpointConfigurationName, string remoteAddress)
26: :
27: base(endpointConfigurationName, remoteAddress)
28: {
29: }
30:
31: public RoomAgent(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
32: :
33: base(endpointConfigurationName, remoteAddress)
34: {
35: }
36:
37: public RoomAgent(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
38: :
39: base(binding, remoteAddress)
40: {
41: }
42:
43: public Room CreateRoom(Room room)
44: {
45: return base.Channel.CreateRoom(room);
46: }
47:
48: public Room GetRoom(int roomId)
49: {
50: return base.Channel.GetRoom(roomId);
51: }
52:
53:
54:
55: }
56:
57: [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
58: [System.ServiceModel.ServiceContractAttribute(ConfigurationName = "IRegistrationServiceAgent")]
59: public interface IRoomAgent
60: {
61: [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IRoomAgent/CreateRoom", ReplyAction = "http://tempuri.org/IRoomAgent/CreateRoomResponse")]
62: Room CreateRoom(Room room);
63:
64: [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IRoomAgent/GetRoom", ReplyAction = "http://tempuri.org/IRoomAgent/GetRoomResponse")]
65: Room GetRoom(int roomId);
66:
67: }
68:
69:
70:
71:
72: [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
73: public interface IRoomAgentChannel : IRoomAgent, System.ServiceModel.IClientChannel
74: {
75:
76: }
77:}
78:
Now see how to consume the proxy
Service sample
1:using System;
2:using System.Net.Mail;
3:using System.Net;
4:using System.IO;
5:using System.Web;
6:using BusinessEntity;
7:
8:using System.ServiceModel;
9:
10:namespace ProxyService.Module1
11:{
12: public class ServiceProxy
13: {
14: public ServiceProxy()
15: {
16:
17: }
18:
19: public Room GetRoom(int roomId)
20: {
21: Room _objRoom = null;
22: using (ChannelFactory<IRoomAgentChannel> objChannel = new ChannelFactory<IRoomAgentChannel>(ServiceInfo.MyHttpBinding, ServiceInfo.MyEndPointAddress))
23: {
24: IRoomAgentChannel objRoomChannel = null;
25: try
26: {
27: objRoomChannel = objChannel.CreateChannel();
28: _objRoom = objRoomChannel.GetRoom(roomId);
29: objRoomChannel.Close();
30: objChannel.Close();
31: }
32: catch (Exception ex)
33: {
34: throw new Exception("Error occured while Getting a room at Roomagent" + ex.ToString());
35: }
36: finally
37: {
38: _objRoom = null;
39: }
40: }
41: return _objRoom;
42: }
43: }
44:}
45:
Leave your comment.

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

HR Recruitment & Process Management System
Jewellery production process management software
Share
©2009 ETG Consultancy, All Rights Reserved Privacy Policy | Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML