WebServices FAQS
1 2
What are Web service protocols?
  HTTP GET
HTTP POST
SOAP
Can you give example for SOAP Format?
 
< soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
< soap:Header>
...
...
< /soap:Header>
< soap:Body>
...
...
< soap:Fault>
...
...
< /soap:Fault>
...
< /soap:Body>
< /soap:Envelope>
what is the difference between Synchronous and ASynchronous web methods?
  A synchronous method call waits for the method to complete before continuing with program flow,
whereas an asynchronous method call will return immediately so that the program can perform other operations while the called method completes its work.
How can we overload a webmethod?
  WebMethods can't have the same name, We can achieve this by using MessageName property of the WebMethod.

[WebMethod (MessageName="HelloWorld")]
public string HelloWorld()
{
return "HelloWorld";
}

[WebMethod (MessageName="HelloWorldWithName")]
public string HelloWorld(string name)
{
return "HelloWorld " + name;
}
How do you handle session in webservices?
  ASP.NET Web Services allows you to access the underlying state management provided by ASP.NET. To enable ASP.NET session state, set WebMethod.EnableSession = True. On the client you must also set serviceName.CookieContainer to a new instance of System.Net.CookieContainer.

Client-Side Code
//On the client you must add the following code (for session state only): serviceName.CookieContainer = new System.Net.CookieContainer();

Server-Side Code
//Setting EnableSession to true allows state to be persisted per Session
[WebMethod(EnableSession=true)]
public String UpdateSessionHitCounter()
{
//update the session "HitCounter" here
return Session["HitCounter"].ToString(); }
What are WebMethod attribute properties?
  WebMethod attribute has the following properties
Description , TransactionOption, CacheDuration, BuffferResponse, EnableSession, MessageName
Example
[WebMethod(Description = "My WebMethod Description comes here")]

[WebMethod(EnableSession ="true")]

[WebMethod(MessageName = "SinInt")]

[WebMethod(TransactionOption = "Supported")]

[WebMethod(CacheDuration = "180")]

[WebMethod(BufferResponse = "true")]
How to change web service reference dynamically?
  By changing URL behaviour from static to dynamic. This will automatically create an entry in the sections of web.config file.
what is One-Way (Fire-and-Forget) Communication in webservice?
  Consider using the OneWay attribute if you do not require a response. Using the OneWay property of SoapDocumentMethod and SoapRpcMethod in the System.Web.Services.Protocols namespace frees the client immediately instead of forcing it to wait for a response.
[SoapDocumentMethod(OneWay=true)]
[WebMethod(Description="Returns control immediately")]
public void SomeMethod()
{…}

This is useful if the client needs to send a message, but does not expect anything as return values or output parameters. Methods marked as OneWay cannot have output parameters or return values.
what are the two Activation modes for .NET Remoting?
  Singleton
Singlecall
What are the Channels and Formatters?
  HTTP and TCP are Channels. Binary and SOAP are formatters
Binay over TCP is most efficient.
SOAP over HTTP is most interoperable.
1 2
Comments and Discussions
Please feel free To Leave Your Comment
,