.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> WCF >> Post New Question Subscribe to Interview Questions

What are the different ways to generate proxy in WCF?

Posted By :Nargani     Posted Date :July 18, 2014    Points :40   Category :WCF 
A service proxy or simply proxy in WCF enables application(s) to interact with 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. It contains all the methods of service contract (signature only, not the implementation). So, when the application interact the service through proxy, it gives the impression that it's communicating a local object.

We can create proxy for a service by using Visual Studio or SvcUtil.exe.

Generating proxy using Visual Studio is simple and straight forward.

->Right click References and choose "Add Service Reference".
->Provide base address of the service on "Add Service Reference" dialog box and click "Go" button. Service will be listed below.
->Provide namespace and click OK.

Visual studio will generate a proxy automatically.

We can generate proxy using svcutil.exe utility using command line. This utility requires few parameters like HTTP-GET address or the metadata exchange endpoint address and a proxy filename i.e. optional.

svcutil http://localhost/MyService/Service1.svc /out:MyServiceProxy.cs
If we are hosting the service at a different port (other than default for IIS which is 80), we need to provide port number in base address.

svcutil http://localhost:8080/MyService/Service1.svc /out:MyServiceProxy.cs


You can also find related Interview Question to What are the different ways to generate proxy in WCF?  below: 

What is Proxy and how to generate proxy for WCF Services?

  
The proxy is a CLR class that exposes a single CLR interface representing the service contract. The proxy provides the same operations as service's contract, but also has additional methods for managing the proxy life cycle and the connection to the service. The proxy completely encapsulates every aspect of the service: its location, its implementation technology and runtime platform, and the communication transport.

The proxy can be generated using Visual Studio by right clicking Reference and clicking on Add Service Reference. This brings up the Add Service Reference dialog box, where you need to supply the base address of the service (or a base address and a MEX URI) and the namespace to contain the proxy.

Proxy can also be generated by using SvcUtil.exe command-line utility. We need to provide SvcUtil with the HTTP-GET address or the metadata exchange endpoint address and, optionally, with a proxy filename. The default proxy filename is output.cs but you can also use the /out switch to indicate a different name.

SvcUtil http://localhost/MyService/MyService.svc /out:Proxy.cs

When we are hosting in IIS and selecting a port other than port 80 (such as port 88), we must provide that port number as part of the base address:

SvcUtil http://localhost:88/MyService/MyService.svc /out:Proxy.cs
(More...)

What is serialization in .NET? What are the ways to control serialization?

  
Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.
Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another.
XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.

There are two separate mechanisms provided by the .NET class library -
XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses

SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code. (More...)

Describe ways of cleaning up objects.

  
The run time will maintain a service called as garbage collector.
this service will take care of deallocating memory corresponding to
objects.it works as a thread with least priority.when application
demenads for memory the runtime will take care of setting the high
priority for the garbage collector,so that it will be called for execution
and memory will be released.the programmer can make a call
to garbage colector by using GC class in system name space. (More...)

What are the ways available in SQL Server to execute SQL statements?

  

SQL Server uses different ways to execute SQL statements which are listed below.

1)Single SQL statement processing
2)Batch processing
3)Stored procedure and trigger execution
4)Execution plan caching and reuse
5)Parallel query processing

(More...)

You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?

  
Select the correct answer.

1. Use the Sort method on the DataTable object.
2. Use the DataSet object's Sort method.
3. Use a DataView object for each sort.
4. Create a DataTable for each sort, using the DataTable object's Copy method, and then Sort the result


Correct Answer is :
3. Use a DataView object for each sort. (More...)

What are the different ways a method can be overloaded?

  
Different parameter data types, different number of parameters, different order of parameters can be used to overload a method (More...)

How many ways you can display text using Silverlight?

  
Silverlight supports displaying static pre formatted text that is comprised out of glyph elements and also dynamic text that uses TextBlock. With glyphs, one needs to position the characters individually while TextBlock supports simple layout. (More...)

In how many ways you can deploy Application in asp.net?

  
1)XCopy deployment
2)PreCompiled deployment
3)SetUp Program deployment (More...)

In how many ways you can deploy an Asp.Net Application?

  
1)XCopy deployment
2)PreCompiled deployment
3)SetUp Program deployment (More...)

What are the ways to deploy an assembly?

  
An MSI installer, a CAB archive, and XCOPY command. (More...)

What are the built in ways to backup a SharePoint install?

  
Using central administration and the stsadm command you can take backup (More...)

How do we generate random numbers?

  
Using Math.random() method we can generate random numbers between 0 to 9 (More...)

What are the ways to deploy an assembly?

  
We can do by any of the following methods
MSI installer
CAB archive
ZCOPY command (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend