{"iq":[{"id":"1",
"q":" What is WCF? ",
"answer":"WCF is a platform for building service-oriented applications. WCF is used for developing, configuring and deploying distributed services. "
},
{"id":"2",
"q":". Why use WCF? What are the advantages of using WCF? ",
"answer":" We can easily build service-oriented applications using WCF. Compared with web services, WCF services provide reliability and security with simplicity. WCF supports .NET Remoting Various clients can interact with the same service using a different communication mechanism. This is achieved using service endpoints. A single WCF service can have multiple endpoints. "
},
{"id":"3",
"q":" What are the core components of a WCF Service?",
"answer":" A WCF service has at least the following core components:\na. Service Class: A service class implemented in any CLR-based language\nb. Hosting Environment: a managed process for running the service.\nc. Endpoint: for use by a client to communicate with the service. "
},
{"id":"4",
"q":" What is the difference between WCF and ASMX Web services? ",
"answer":"WCF:-\nServiceContract and OperationContract attributes are used for defining WCF service.\nSupports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSM\nHosted in IIS, WAS (Windows Activation Service), Self-hosting, Windows Service.\nSupports security, reliable messaging, transaction and AJAX and REST supports.\nSupports DataContract serializer by using System.Runtime.Serialization.\nSupports One-Way, Request-Response and Duplex service operations\nWCF are faster than Web Services.\nHash Table can be serialized.\nUnhandled Exceptions does not return to the client as SOAP faults. WCF supports better exception handling by using FaultContract.\nSupports XML, MTOM, Binary message encoding.\nSupports multi-threading by using ServiceBehaviour class.\nWebservice must save with .asmx\nASP.NET Web Service\nWebService and WebMethod attributes are used for defining web service.\nSupports only HTTP, HTTPS protocols.\nHosted only in IIS.\nSupport security but is less secure as compared to WCF.\nSupports XML serializer by using System.Xml.Serialization.\nSupports One-Way and Request-Response service operations.\nWeb Services are slower than WCF\nHash Table cannot be serialized. It can serializes only those collections which implement IEnumerable and ICollection.\nUnhandled Exceptions returns to the client as SOAP faults.\nSupports XML and MTOM (Message Transmission Optimization Mechanism) message encoding.\nDoesn’t support multi-threading.\nWcf service must save with .svc"
},
{"id":"5",
"q":"What are the Endpoints in WCF? Explain the ABCs of endpoints.",
"answer":"Endpoint is the ABCs of WCF service they are Address, Binding and Contract.\n Address: It defines \"WHERE\". The Address is the URL that identifies the location of the service.\n Binding: It defines \"HOW\". The Binding defines how the service can be accessed.\n Contract: It defines \"WHAT\". The Contract identifies what is exposed by the service. "
},
{"id":"6",
"q":"What is a WCF Binding? How many different types of bindings are available in WCF? ",
"answer":"Bindings in WCF actually define how to communicate with the service. The Binding specifies the communication protocol as well as the encoding method to be used. There are various built-in bindings available in WCF, each designed to fulfill some specific need. basicHttpBinding wsHttpBinding netNamedPipeBinding netTcpBinding netPeerTcpBinding netmsmqBinding "
},
{"id":"7",
"q":" Can we have multiple endpoints for different binding types in order to serve various types of clients?",
"answer":" Yes, we can have multiple endpoints for different binding types. For example, an endpoint with wsHttpBinding and another one with netTcpBinging. "
},
{"id":"8",
"q":"What are the hosting options for WCF Services? Explain. ",
"answer":"WCF supports 3 types of hosting mechanisams\n1. Self Hosting\n2. IIS Hosting\n3. WAS Hosting (Windows Process Activation Service)"
},
{"id":"9",
"q":"What is Selfhosting? ",
"answer":"Self hosting is a mechanism of hosting WCF service in ConsoleApplication, WindowsForms application or Windows Services"
},
{"id":"10",
"q":" What is IIS hosting? ",
"answer":"Hosting WCF service under IIS"
},
{"id":"11",
"q":"IIS hosting supports which protocol?",
"answer":"IIS hosting supports only Http"
},
{"id":"12",
"q":" What is WAS hosting?",
"answer":"WAS hosting enable IIS to work on multiple protocols.it supports HTTP, TCP, NamedPipes, MSMQ"
},
{"id":"13",
"q":" What are Contracts in WCF?",
"answer":"A Contract is basically an agreement between the two parties i.e.WCFService and Client Application.\no ServiceContract\no OperationContract\no DataContract\no MessageContract\no Fault Contract "
},
{"id":"14",
"q":" What is Servicecontract?",
"answer":" A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do.\n[ServiceContract]\ninterface IService1\n{\n[OperationContract] string Method1();\n}"
},
{"id":"15",
"q":" What is Operationcontract? ",
"answer":" An operation contract is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the op-eration, the directions of the operation (one-way, two-way, or both ways), and fault contract of the operation.\n[ServiceContract]\ninterface IService1\n{\n[OperationContract]\nstring Method1();\n} "
},
{"id":"16",
"q":" What is DataContract? ",
"answer":"A data contract defines the data type of the information that will be exchange be-tween the client and the service.\nA data contract can be used by an operation contract as a parameter or return type, or it can be used by a message contract to define elements.\n[DataContract]\nclass Employee\n{\n[DataMember]\npublic string Eno;\n[DataMember]\npublic string Empname;\n}\n[ServiceContract]\ninterface IEmpservice\n{\n[OperationContract] Employee DisplayEmployee(int eno);\n}"
},
{"id":"17",
"q":" What is Message Contract?",
"answer":"When an operation contract required to pass a message as a parameter or return value as a message,the type of this message will be defined as message contract.A message contract defines the elements of the message (like as Message Header, Message Body),as well as the message-related settings, such as the level of message security.Message contracts give you complete control over the content of the SOAP header,as well as the structure of the SOAP body.\n[ServiceContract]\n public interface IProductService\n {\n[OperationContract]\ndouble CalPrice(PriceCalculate request);\n}\n[MessageContract]\npublic class PriceCalculate\n{\n[MessageHeader]\npublic MyHeader SoapHeader { get; set; }\n[MessageBodyMember]\npublic PriceCal PriceCalculation { get; set; }\n}\n[DataContract]\npublic class MyHeader { [DataMember] public string UserID { get; set; }\n}\n\n[DataContract]\npublic class PriceCal {\n[DataMember] public DateTime PickupDateTime { get; set; }\n[DataMember] public DateTime ReturnDateTime { get; set; }\n[DataMember] public string PickupLocation { get; set; }\n[DataMember] public string ReturnLocation { get; set; }\n} "
},
{"id":"18",
"q":" What is Faultcontract?",
"answer":" A fault contract defines errors raised by the service, and how the service handles and propagates errors to its clients. An operation contract can have zero or more fault contracts associated with it.\n\n[ServiceContract]\npublic interface ISimpleCalculator\n{\n\n[OperationContract()]\n[FaultContract(typeof(CustomException))]\nint Add(int num1, int num2); } "
},
{"id":"19",
"q":" What Message Exchange Patterns are supported by WCF? ",
"answer":" Request/Response Communication\n One Way Communication\n Duplex Communication "
},
{"id":"20",
"q":" What is Request/Reply Communication? ",
"answer":"Request/Reply Communication means Fire the request and wait for Response This is the default Message Exchange Pattern.\nIn this pattern the client sends a request to the server and it waits forthe response until the server does not stop processing,for example if the client a sends a request to get the nameof all users then the service will proceed with it and the client must wait for aresponse when the service sends a result then the client is free. if we use the void keyword then it will also take more time.The one property to set the pattern of request/responseis IsOneWay=false and all the WCF bindings except MSMQ based binding supports the request/response. "
},
{"id":"21",
"q":" What is one way communication? ",
"answer":" One way communication means Fire the request and forget about response\nInterface IService1 {\n[OperationContract(IsOneWay = true)]\nvoid Dosomething(int milliseconds);\n} "
},
{"id":"22",
"q":" what is Duplex communication? ",
"answer":"The duplex pattern implements both of the OneWay and Request/Response message patterns. The client and the service both initiate this pattern. This pattern is more complex than other patterns because the additional communication is added. This mode is used when we want to send the notification to the client about his request being reached successfully or not. It doesn't support all bindings.\nAs shown in the diagram the client sends a request to the service and it processes the request and gives the response but if the user wants to do his other work then it canalso do that and the service provides the notification.For the setting of the Duplex pattern we need to use concurrent mode.\n[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant)]And for synchronizaion in client machine\n[CallbackBehavior(UseSynchronizationContext=false)] Or IsOneWay=true "
},
{"id":"23",
"q":" How to Handle Exceptions in WCF?",
"answer":"Fault Contract"
},{"id":"24",
"q":" What is Faultcontract? ",
"answer":"A Fault Contract is a way to handle an error/exception in WCF In C# we can handle the error using try and catch blocks at the client side.\nThe purpose of a Fault Contract is to handle an error by the service class and display in the client side.\nWhenever the client makes a call to a service class and an unexpected exception comes such as, SQL Server is not responding,or Divide by zero;\nin this case the service class throws an exception to the client using the Fault Contract.\nBy default when we throw an exception from a service, it will not reach the client.\nWCF provides the option to handle and convey the error message to the client from a service using a SOAP Fault Contract."
},
{"id":"25",
"q":" How to provide security in WCF? ",
"answer":"In WCF we can provide security in 3 ways\n1. Messagelevel security:-Message security uses the WS-Security specification to secure messages.\nThe message is encrypted using the certificate and can now safely travel over any port using plain http.\nIt provides end-to-end security.\n2. Transport level security:- Transport security is a protocol implemented security so it works only point to point.\nAs security is dependent on protocol, it has limited security support and is bounded to the protocol security limitations.\n3. Mixed level Security:- his we can call a mixture of both Message and Transport security implementation"
},{"id":"26",
"q":" Explain transactions in WCF?",
"answer":"A transaction is a logical unit of work consisting of multiple activities that must either succeed or fail together.\nFor example, you are trying to make an online purchase for a dress;your amount is debited from the bank, but your ordered dress was not delivered to you.\nSo what did you get from the preceding example?\nBank operations hosted in a separate service and the online purchase service (Ordering the goods)\nhosted as another separate service.\nFor the preceding example the online purchase service did not work well\nas expected due to the database query error, without knowing it the Bank operations were completed perfectly.\nFor this we really need transactions to ensure that either of the operations should succeed or fail.\nBefore we go to the WCF transactions, let us discuss what exactly are the basics behind the\ntransactions. The following are the types of the Transactions\n1. Atomic 2. Long Running\n\nPhases of WCF Transaction:\nThere are two phases in a WCF transaction as shown in the following figure.\nPrepare Phase - In this phase, the transaction manager checks whether all the entities are ready to commit for the transaction or not.\nCommit Phase - In this phase, the commitment of entities get started in reality."
},{"id":"27",
"q":" What is WCF throttling?",
"answer":"WCF throttling provides some properties that you can use to limit how many instances or sessions are created at the application level.\nPerformance of the WCF service can be improved by creating proper instance. The throttling of services is another key element for WCF performance tuning.\nWCF throttling provides the prosperities maxConcurrentCalls, maxConcurrentInstances, and maxConcurrentSessions,\nwhich can help us to limit the number of instances or or sessions are created at the application level.sessions,are created at the application level. "
},{"id":"28",
"q":" What is Proxy? ",
"answer":"Proxy is localcopy of wcfservice A service proxy or simply proxy in WCF enables application(s)to interact with a WCF Service by sending and receiving messages It's basically a class that encapsulates service details i.e. service path,service implementation technology, platform and communication protocol etc.\nIt contains all the methods of a service contract (signature only, not the implementation)"
},{"id":"29",
"q":" How can we create Proxy for the WCF Service? ",
"answer":"We can create proxy using the tool svcutil.exe after creating the service.\nWe can use the following command at command line.\nsvcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config"
},
{"id":"30",
"q":" What is WCF Concurrency and How many modes are of Concurrency in WCF? ",
"answer":"WCF Concurrency means “Several computations are executing simultaneously.\nWCF concurrency helps us configure how WCF service instances can serve multiple requests at the same time.\nYou will need WCF concurrency for the below prime reasons; there can be other reasons as well but these stand out as important reasons:\nWe can use the concurrency feature in the following three ways:\n Single:- A single request will be processed by a single thread on a server at any point of time.\nThe client proxy sends the request to the server, it process the request and takes another request.\n Multiple:- Multiple requests will be processed by multiple threads on the server at any point of time.\nThe client proxy sends multiple requests to the server.\nRequests are processed by the server by spawning multiple threads on the server object.\n Reentrant:- The reentrant concurrency mode is nearly like the single concurrency mode.\nIt is a single-threaded service instance that receives requests from the client proxy and it unlocks the thread\nonly after the reentrant service object calls the other service or can also call a WCF client through call back.\n\n[serviceBehavior(concerrencymode=concurrencymode.single)]\npublic class cafeshopservice impl :icafeshopservice\n{"
},{"id":"31",
"q":"What is Tracing in WCF? ",
"answer":"The tracing mechanism in the Windows Communication Foundation is based on the classes that reside in the System.Diagnostic namespace. The important classes are Trace, TraceSource and TraceListener."
},{"id":"32",
"q":"What is Instance Context Mode in WCF? ",
"answer":"An Instance Context mode defines how long a service instance remains on the server. "
},{"id":"33",
"q":"What is the KnownType Attribute in WCF?",
"answer":"The KnownTypeAttribute class allows you to specify,in advance, the types that should be included for consideration during deserialization.\nThe WCF service generally accepts and returns the base type\nIf you expect the service to accept and return an inherited type then we use the knowntype attribute.When passing parameters and return values between a client and a service,both endpoints share all of the data contracts of the data to be transmitted.\n[DataContract]\n[KnownType(typeof (Student))]\n[KnownType(typeof (Teacher))]\npublicabstractclass Person\n{\n[DataMember]\npublicint Code{get; set;}\n[DataMember]\npublicstring Name{get; set;}} "
},{"id":"34",
"q":" What are the various address format in WCF?",
"answer":"a)HTTP Address Format:--> http://localhost: b)TCP Address Format:--> net.tcp://localhost: c)MSMQ Address Format:--> net.msmq://localhost: "
},{"id":"35",
"q":" what is REST in WCF? ",
"answer":" Representational state transfer protocol"
},{"id":"36",
"q":" what is WSDL? ",
"answer":"WSDL is Webservice Description Language WSDl is an xml file which is used to describe Webservice "
},{"id":"37",
"q":" What is SOAP?",
"answer":"SOAP stands for Simple Object Access Protocol SOAP is an application communication protocol SOAP is a format for sending and receiving messages SOAP is platform independent SOAP is based on XML SOAP is a W3C recommendation"
},{"id":"38",
"q":"What is UDDI?",
"answer":"UDDI is an XML-based standard for describing, publishing, and finding web services.\nUDDI stands for Universal Description, Discovery, and Integration.\nUDDI is a specification for a distributed registry of web services.\nUDDI is a platform-independent, open framework."
},{"id":"39",
"q":" What is the difference between SOAP and Rest? ",
"answer":"SOAP\nSimple object access protocol\nSOAP is a protocol.\nSOAP can't use REST because it is a protocol.\nSOAP uses services interfaces to expose the business logic.\nSOAP defines standards to be strictly followed.\nSOAP requires more bandwidth and resource than REST.\nSOAP defines its own security.\nSOAP defines its own security.\nSOAP permits XML data format only.\nSOAP is less preferred than REST.\n\nREST\\nRepresentational state transfer protocol\nREST is an architectural style.\nREST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.\nREST uses URI to expose business logic.\nREST does not define too much standards like SOAP.\n\nREST requires less bandwidth and resource than SOAP.\nREST requires less bandwidth and resource than SOAP.\nRESTful web services inherits security measures from the underlying transport.nREST permits different data format such as Plain text, HTML, XML, JSON etc.\nREST more preferred than SOAP."
},{"id":"40",
"q":" What is SoapFault? ",
"answer":"A SOAP fault is an error in a SOAP (Simple Object Access Protocol) communication resulting from incorrect message format, header-processing problems, or incompatibility between applications"
},{"id":"41",
"q":" What is JSON? ",
"answer":"Java script object notation JSON is a syntax for storing and exchanging data."
}
]
}
"q":" What is WCF? ",
"answer":"WCF is a platform for building service-oriented applications. WCF is used for developing, configuring and deploying distributed services. "
},
{"id":"2",
"q":". Why use WCF? What are the advantages of using WCF? ",
"answer":" We can easily build service-oriented applications using WCF. Compared with web services, WCF services provide reliability and security with simplicity. WCF supports .NET Remoting Various clients can interact with the same service using a different communication mechanism. This is achieved using service endpoints. A single WCF service can have multiple endpoints. "
},
{"id":"3",
"q":" What are the core components of a WCF Service?",
"answer":" A WCF service has at least the following core components:\na. Service Class: A service class implemented in any CLR-based language\nb. Hosting Environment: a managed process for running the service.\nc. Endpoint: for use by a client to communicate with the service. "
},
{"id":"4",
"q":" What is the difference between WCF and ASMX Web services? ",
"answer":"WCF:-\nServiceContract and OperationContract attributes are used for defining WCF service.\nSupports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSM\nHosted in IIS, WAS (Windows Activation Service), Self-hosting, Windows Service.\nSupports security, reliable messaging, transaction and AJAX and REST supports.\nSupports DataContract serializer by using System.Runtime.Serialization.\nSupports One-Way, Request-Response and Duplex service operations\nWCF are faster than Web Services.\nHash Table can be serialized.\nUnhandled Exceptions does not return to the client as SOAP faults. WCF supports better exception handling by using FaultContract.\nSupports XML, MTOM, Binary message encoding.\nSupports multi-threading by using ServiceBehaviour class.\nWebservice must save with .asmx\nASP.NET Web Service\nWebService and WebMethod attributes are used for defining web service.\nSupports only HTTP, HTTPS protocols.\nHosted only in IIS.\nSupport security but is less secure as compared to WCF.\nSupports XML serializer by using System.Xml.Serialization.\nSupports One-Way and Request-Response service operations.\nWeb Services are slower than WCF\nHash Table cannot be serialized. It can serializes only those collections which implement IEnumerable and ICollection.\nUnhandled Exceptions returns to the client as SOAP faults.\nSupports XML and MTOM (Message Transmission Optimization Mechanism) message encoding.\nDoesn’t support multi-threading.\nWcf service must save with .svc"
},
{"id":"5",
"q":"What are the Endpoints in WCF? Explain the ABCs of endpoints.",
"answer":"Endpoint is the ABCs of WCF service they are Address, Binding and Contract.\n Address: It defines \"WHERE\". The Address is the URL that identifies the location of the service.\n Binding: It defines \"HOW\". The Binding defines how the service can be accessed.\n Contract: It defines \"WHAT\". The Contract identifies what is exposed by the service. "
},
{"id":"6",
"q":"What is a WCF Binding? How many different types of bindings are available in WCF? ",
"answer":"Bindings in WCF actually define how to communicate with the service. The Binding specifies the communication protocol as well as the encoding method to be used. There are various built-in bindings available in WCF, each designed to fulfill some specific need. basicHttpBinding wsHttpBinding netNamedPipeBinding netTcpBinding netPeerTcpBinding netmsmqBinding "
},
{"id":"7",
"q":" Can we have multiple endpoints for different binding types in order to serve various types of clients?",
"answer":" Yes, we can have multiple endpoints for different binding types. For example, an endpoint with wsHttpBinding and another one with netTcpBinging. "
},
{"id":"8",
"q":"What are the hosting options for WCF Services? Explain. ",
"answer":"WCF supports 3 types of hosting mechanisams\n1. Self Hosting\n2. IIS Hosting\n3. WAS Hosting (Windows Process Activation Service)"
},
{"id":"9",
"q":"What is Selfhosting? ",
"answer":"Self hosting is a mechanism of hosting WCF service in ConsoleApplication, WindowsForms application or Windows Services"
},
{"id":"10",
"q":" What is IIS hosting? ",
"answer":"Hosting WCF service under IIS"
},
{"id":"11",
"q":"IIS hosting supports which protocol?",
"answer":"IIS hosting supports only Http"
},
{"id":"12",
"q":" What is WAS hosting?",
"answer":"WAS hosting enable IIS to work on multiple protocols.it supports HTTP, TCP, NamedPipes, MSMQ"
},
{"id":"13",
"q":" What are Contracts in WCF?",
"answer":"A Contract is basically an agreement between the two parties i.e.WCFService and Client Application.\no ServiceContract\no OperationContract\no DataContract\no MessageContract\no Fault Contract "
},
{"id":"14",
"q":" What is Servicecontract?",
"answer":" A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do.\n[ServiceContract]\ninterface IService1\n{\n[OperationContract] string Method1();\n}"
},
{"id":"15",
"q":" What is Operationcontract? ",
"answer":" An operation contract is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the op-eration, the directions of the operation (one-way, two-way, or both ways), and fault contract of the operation.\n[ServiceContract]\ninterface IService1\n{\n[OperationContract]\nstring Method1();\n} "
},
{"id":"16",
"q":" What is DataContract? ",
"answer":"A data contract defines the data type of the information that will be exchange be-tween the client and the service.\nA data contract can be used by an operation contract as a parameter or return type, or it can be used by a message contract to define elements.\n[DataContract]\nclass Employee\n{\n[DataMember]\npublic string Eno;\n[DataMember]\npublic string Empname;\n}\n[ServiceContract]\ninterface IEmpservice\n{\n[OperationContract] Employee DisplayEmployee(int eno);\n}"
},
{"id":"17",
"q":" What is Message Contract?",
"answer":"When an operation contract required to pass a message as a parameter or return value as a message,the type of this message will be defined as message contract.A message contract defines the elements of the message (like as Message Header, Message Body),as well as the message-related settings, such as the level of message security.Message contracts give you complete control over the content of the SOAP header,as well as the structure of the SOAP body.\n[ServiceContract]\n public interface IProductService\n {\n[OperationContract]\ndouble CalPrice(PriceCalculate request);\n}\n[MessageContract]\npublic class PriceCalculate\n{\n[MessageHeader]\npublic MyHeader SoapHeader { get; set; }\n[MessageBodyMember]\npublic PriceCal PriceCalculation { get; set; }\n}\n[DataContract]\npublic class MyHeader { [DataMember] public string UserID { get; set; }\n}\n\n[DataContract]\npublic class PriceCal {\n[DataMember] public DateTime PickupDateTime { get; set; }\n[DataMember] public DateTime ReturnDateTime { get; set; }\n[DataMember] public string PickupLocation { get; set; }\n[DataMember] public string ReturnLocation { get; set; }\n} "
},
{"id":"18",
"q":" What is Faultcontract?",
"answer":" A fault contract defines errors raised by the service, and how the service handles and propagates errors to its clients. An operation contract can have zero or more fault contracts associated with it.\n\n[ServiceContract]\npublic interface ISimpleCalculator\n{\n\n[OperationContract()]\n[FaultContract(typeof(CustomException))]\nint Add(int num1, int num2); } "
},
{"id":"19",
"q":" What Message Exchange Patterns are supported by WCF? ",
"answer":" Request/Response Communication\n One Way Communication\n Duplex Communication "
},
{"id":"20",
"q":" What is Request/Reply Communication? ",
"answer":"Request/Reply Communication means Fire the request and wait for Response This is the default Message Exchange Pattern.\nIn this pattern the client sends a request to the server and it waits forthe response until the server does not stop processing,for example if the client a sends a request to get the nameof all users then the service will proceed with it and the client must wait for aresponse when the service sends a result then the client is free. if we use the void keyword then it will also take more time.The one property to set the pattern of request/responseis IsOneWay=false and all the WCF bindings except MSMQ based binding supports the request/response. "
},
{"id":"21",
"q":" What is one way communication? ",
"answer":" One way communication means Fire the request and forget about response\nInterface IService1 {\n[OperationContract(IsOneWay = true)]\nvoid Dosomething(int milliseconds);\n} "
},
{"id":"22",
"q":" what is Duplex communication? ",
"answer":"The duplex pattern implements both of the OneWay and Request/Response message patterns. The client and the service both initiate this pattern. This pattern is more complex than other patterns because the additional communication is added. This mode is used when we want to send the notification to the client about his request being reached successfully or not. It doesn't support all bindings.\nAs shown in the diagram the client sends a request to the service and it processes the request and gives the response but if the user wants to do his other work then it canalso do that and the service provides the notification.For the setting of the Duplex pattern we need to use concurrent mode.\n[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant)]And for synchronizaion in client machine\n[CallbackBehavior(UseSynchronizationContext=false)] Or IsOneWay=true "
},
{"id":"23",
"q":" How to Handle Exceptions in WCF?",
"answer":"Fault Contract"
},{"id":"24",
"q":" What is Faultcontract? ",
"answer":"A Fault Contract is a way to handle an error/exception in WCF In C# we can handle the error using try and catch blocks at the client side.\nThe purpose of a Fault Contract is to handle an error by the service class and display in the client side.\nWhenever the client makes a call to a service class and an unexpected exception comes such as, SQL Server is not responding,or Divide by zero;\nin this case the service class throws an exception to the client using the Fault Contract.\nBy default when we throw an exception from a service, it will not reach the client.\nWCF provides the option to handle and convey the error message to the client from a service using a SOAP Fault Contract."
},
{"id":"25",
"q":" How to provide security in WCF? ",
"answer":"In WCF we can provide security in 3 ways\n1. Messagelevel security:-Message security uses the WS-Security specification to secure messages.\nThe message is encrypted using the certificate and can now safely travel over any port using plain http.\nIt provides end-to-end security.\n2. Transport level security:- Transport security is a protocol implemented security so it works only point to point.\nAs security is dependent on protocol, it has limited security support and is bounded to the protocol security limitations.\n3. Mixed level Security:- his we can call a mixture of both Message and Transport security implementation"
},{"id":"26",
"q":" Explain transactions in WCF?",
"answer":"A transaction is a logical unit of work consisting of multiple activities that must either succeed or fail together.\nFor example, you are trying to make an online purchase for a dress;your amount is debited from the bank, but your ordered dress was not delivered to you.\nSo what did you get from the preceding example?\nBank operations hosted in a separate service and the online purchase service (Ordering the goods)\nhosted as another separate service.\nFor the preceding example the online purchase service did not work well\nas expected due to the database query error, without knowing it the Bank operations were completed perfectly.\nFor this we really need transactions to ensure that either of the operations should succeed or fail.\nBefore we go to the WCF transactions, let us discuss what exactly are the basics behind the\ntransactions. The following are the types of the Transactions\n1. Atomic 2. Long Running\n\nPhases of WCF Transaction:\nThere are two phases in a WCF transaction as shown in the following figure.\nPrepare Phase - In this phase, the transaction manager checks whether all the entities are ready to commit for the transaction or not.\nCommit Phase - In this phase, the commitment of entities get started in reality."
},{"id":"27",
"q":" What is WCF throttling?",
"answer":"WCF throttling provides some properties that you can use to limit how many instances or sessions are created at the application level.\nPerformance of the WCF service can be improved by creating proper instance. The throttling of services is another key element for WCF performance tuning.\nWCF throttling provides the prosperities maxConcurrentCalls, maxConcurrentInstances, and maxConcurrentSessions,\nwhich can help us to limit the number of instances or or sessions are created at the application level.sessions,are created at the application level. "
},{"id":"28",
"q":" What is Proxy? ",
"answer":"Proxy is localcopy of wcfservice A service proxy or simply proxy in WCF enables application(s)to interact with a WCF Service by sending and receiving messages It's basically a class that encapsulates service details i.e. service path,service implementation technology, platform and communication protocol etc.\nIt contains all the methods of a service contract (signature only, not the implementation)"
},{"id":"29",
"q":" How can we create Proxy for the WCF Service? ",
"answer":"We can create proxy using the tool svcutil.exe after creating the service.\nWe can use the following command at command line.\nsvcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config"
},
{"id":"30",
"q":" What is WCF Concurrency and How many modes are of Concurrency in WCF? ",
"answer":"WCF Concurrency means “Several computations are executing simultaneously.\nWCF concurrency helps us configure how WCF service instances can serve multiple requests at the same time.\nYou will need WCF concurrency for the below prime reasons; there can be other reasons as well but these stand out as important reasons:\nWe can use the concurrency feature in the following three ways:\n Single:- A single request will be processed by a single thread on a server at any point of time.\nThe client proxy sends the request to the server, it process the request and takes another request.\n Multiple:- Multiple requests will be processed by multiple threads on the server at any point of time.\nThe client proxy sends multiple requests to the server.\nRequests are processed by the server by spawning multiple threads on the server object.\n Reentrant:- The reentrant concurrency mode is nearly like the single concurrency mode.\nIt is a single-threaded service instance that receives requests from the client proxy and it unlocks the thread\nonly after the reentrant service object calls the other service or can also call a WCF client through call back.\n\n[serviceBehavior(concerrencymode=concurrencymode.single)]\npublic class cafeshopservice impl :icafeshopservice\n{"
},{"id":"31",
"q":"What is Tracing in WCF? ",
"answer":"The tracing mechanism in the Windows Communication Foundation is based on the classes that reside in the System.Diagnostic namespace. The important classes are Trace, TraceSource and TraceListener."
},{"id":"32",
"q":"What is Instance Context Mode in WCF? ",
"answer":"An Instance Context mode defines how long a service instance remains on the server. "
},{"id":"33",
"q":"What is the KnownType Attribute in WCF?",
"answer":"The KnownTypeAttribute class allows you to specify,in advance, the types that should be included for consideration during deserialization.\nThe WCF service generally accepts and returns the base type\nIf you expect the service to accept and return an inherited type then we use the knowntype attribute.When passing parameters and return values between a client and a service,both endpoints share all of the data contracts of the data to be transmitted.\n[DataContract]\n[KnownType(typeof (Student))]\n[KnownType(typeof (Teacher))]\npublicabstractclass Person\n{\n[DataMember]\npublicint Code{get; set;}\n[DataMember]\npublicstring Name{get; set;}} "
},{"id":"34",
"q":" What are the various address format in WCF?",
"answer":"a)HTTP Address Format:--> http://localhost: b)TCP Address Format:--> net.tcp://localhost: c)MSMQ Address Format:--> net.msmq://localhost: "
},{"id":"35",
"q":" what is REST in WCF? ",
"answer":" Representational state transfer protocol"
},{"id":"36",
"q":" what is WSDL? ",
"answer":"WSDL is Webservice Description Language WSDl is an xml file which is used to describe Webservice "
},{"id":"37",
"q":" What is SOAP?",
"answer":"SOAP stands for Simple Object Access Protocol SOAP is an application communication protocol SOAP is a format for sending and receiving messages SOAP is platform independent SOAP is based on XML SOAP is a W3C recommendation"
},{"id":"38",
"q":"What is UDDI?",
"answer":"UDDI is an XML-based standard for describing, publishing, and finding web services.\nUDDI stands for Universal Description, Discovery, and Integration.\nUDDI is a specification for a distributed registry of web services.\nUDDI is a platform-independent, open framework."
},{"id":"39",
"q":" What is the difference between SOAP and Rest? ",
"answer":"SOAP\nSimple object access protocol\nSOAP is a protocol.\nSOAP can't use REST because it is a protocol.\nSOAP uses services interfaces to expose the business logic.\nSOAP defines standards to be strictly followed.\nSOAP requires more bandwidth and resource than REST.\nSOAP defines its own security.\nSOAP defines its own security.\nSOAP permits XML data format only.\nSOAP is less preferred than REST.\n\nREST\\nRepresentational state transfer protocol\nREST is an architectural style.\nREST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.\nREST uses URI to expose business logic.\nREST does not define too much standards like SOAP.\n\nREST requires less bandwidth and resource than SOAP.\nREST requires less bandwidth and resource than SOAP.\nRESTful web services inherits security measures from the underlying transport.nREST permits different data format such as Plain text, HTML, XML, JSON etc.\nREST more preferred than SOAP."
},{"id":"40",
"q":" What is SoapFault? ",
"answer":"A SOAP fault is an error in a SOAP (Simple Object Access Protocol) communication resulting from incorrect message format, header-processing problems, or incompatibility between applications"
},{"id":"41",
"q":" What is JSON? ",
"answer":"Java script object notation JSON is a syntax for storing and exchanging data."
}
]
}
