Web Service Questions
Web Service Questions
01. What is the transport protocol you use to call a Web service?
Ans : SOAP (Simple Object Access Protocol) is the preferred protocol.
04. Where on the Internet would you look for Web services?
Ans : http://www.uddi.org/
05. True or False: To test a Web service you must create a Windows application or Web
application to consume this service?
Ans : False, the web service comes with a test page and it provides HTTP-GET method to test.
06. Can you give an example of when it would be appropriate to use a web service as
opposed to non-serviced .NET component
Web service is one of main component in Service Oriented Architecture. You could use web services
when your clients and servers are running on different networks and also different platforms. This
provides a loosely coupled system. And also if the client is behind the firewall it would be easy to use
web service since it runs on port 80 (by default) instead of having some thing else in Service Oriented
Architecture applications. What is the standard you use to wrap up a call to a Web service
"SOAP."
07. What is the transport protocol you use to call a Web service SOAP.
HTTP with SOAP
08. What does WSDL stand for? "WSDL stands for Web Services Dsescription Langauge. There is
WSDL.exe that creates a .wsdl Files which defines how an XML Web service behaves and instructs
clients as to how to interact with the service.
eg: wsdl http://LocalHost/WebServiceName.asmx"
09. Where on the Internet would you look for Web Services?
http://www.uddi.org/
10. What does WSDL stand for?
Web Services Description Language
11. True or False: To test a Web service you must create a windows application or Web
application to consume this service?
False.
12. What are the various ways of accessing a web service ?
1.Asynchronous Call
Application can make a call to the Webservice and then continue todo watever oit wants to do.When
the service is ready it will notify the application.Application can use BEGIN and END method to make
asynchronous call to the webmethod.We can use either a WaitHandle or a Delegate object when
making asynchronous call.
The WaitHandle class share resources between several objects. It provides several methods which will
wait for the resources to become available
The easiest and most powerful way to to implement an asynchronous call is using a delegate object.
A delegate object wraps up a callback function. The idea is to pass a method in the invocation of the
web method. When the webmethod has finished it will call this callback function to process the result
2.Synchronous Call
Application has to wait until execution has completed.
13. What are VSDISCO files? VSDISCO files are DISCO files that support dynamic discovery of Web
services. If you place the following VSDISCO file in a directory on your Web server, for example, it
returns references to all ASMX and DISCO files in the host directory and any subdirectories not noted
in <EXCLUDE>elements:
<DYNAMICDISCOVERY
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
<EXCLUDE path="_vti_cnf" />
<EXCLUDE path="_vti_pvt" />
<EXCLUDE path="_vti_log" />
<EXCLUDE path="_vti_script" />
<EXCLUDE path="_vti_txt" />
</DYNAMICDISCOVERY>
14. How does dynamic discovery work? ASP.NET maps the file name extension VSDISCO to an
HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a
dynamically generated DISCO document. A client who requests a VSDISCO file gets back what
appears to be a static DISCO document.
Note that VSDISCO files are disabled in the release version of ASP.NET. You can reenable them by
uncommenting the line in the <HTTPHANDLERS>section of Machine.config that maps *.vsdisco to
System.Web.Services.Discovery.DiscoveryRequestHandler and granting the ASPNET user account
permission to read the IIS metabase. However, Microsoft is actively discouraging the use of VSDISCO
files because they could represent a threat to Web server security.
15. Is it possible to prevent a browser from caching an ASPX page?
Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's Cache
property, as demonstrated here:
<%@ Page Language="C#" %>
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In
this example, it prevents caching of a Web page that shows the current time.
16. What does AspCompat="true" mean and when should I use it?
AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set to
true in any ASPX file that creates apartment-threaded COM objects--that is, COM objects registered
ThreadingModel=Apartment. That includes all COM objects written with Visual Basic 6.0. AspCompat
should also be set to true (regardless of threading model) if the page creates COM objects that
access intrinsic ASP objects such as Request and Response. The following directive sets AspCompat to
true:
<%@ Page AspCompat="true" %>
Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available to the
COM components by placing unmanaged wrappers around the equivalent ASP.NET objects. Second, it
improves the performance of calls that the page places to apartment- threaded COM objects by
ensuring that the page (actually, the thread that processes the request for the page) and the COM
objects it creates share an apartment. AspCompat="true" forces ASP.NET request threads into single-
threaded apartments (STAs). If those threads create COM objects marked
ThreadingModel=Apartment, then the objects are created in the same STAs as the threads that
created them. Without AspCompat="true," request threads run in a multithreaded apartment (MTA)
and each call to an STA-based COM object incurs a performance hit when it's marshaled across
apartment boundaries.
Do not set AspCompat to true if your page uses no COM objects or if it uses COM objects that don't
access ASP intrinsic objects and that are registered ThreadingModel=Free or ThreadingModel=Both.
17. Can two different programming languages be mixed in a single ASMX file?
No.
18. What namespaces are imported by default in ASMX files?
The following namespaces are imported by default. Other namespaces must be imported manually.·
System, System.Collections,System.ComponentModel,System.Data,
System.Diagnostics,System.Web,System.Web.Services
How do I provide information to the Web Service when the information is required as a SOAP Header?
The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET's Add
Web Reference menu option. If you happen to download a WSDL file for a Web Service that requires a
SOAP header, .NET will create a SoapHeader class in the proxy source file. Using the previous
example:
public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public AuthToken AuthTokenValue;
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/",
IsNullable=false)]
public class AuthToken : SoapHeader { public string Token; }}
In this case, when you create an instance of the proxy in your main application file, you'll also create
an instance of the AuthToken class and assign the string:
Service1 objSvc = new Service1();
processingobjSvc.AuthTokenValue = new AuthToken();
objSvc.AuthTokenValue.Token = <ACTUAL token value>;
Web Servicestring strResult = objSvc.MyBillableWebMethod();
19. What is WSDL?
WSDL is the Web Service Description Language, and it is implemented as a specific XML vocabulary.
While it's very much more complex than what can be described here, there are two important aspects
to WSDL with which you should be aware. First, WSDL provides instructions to consumers of Web
Services to describe the layout and contents of the SOAP packets the Web Service intends to issue.
It's an interface description document, of sorts. And second, it isn't intended that you read and
interpret the WSDL. Rather, WSDL should be processed by machine, typically to generate proxy
source code (.NET) or create dynamic proxies on the fly (the SOAP Toolkit or Web Service Behavior).
20. What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
Windows service is a application that runs in the background. It is equivalent to a NT service.
The executable created is not a Windows application, and hence you can't just click and run it . it
needs to be installed as a service, VB.Net has a facility where we can add an installer to our program
and then use a utility to install the service. Where as this is not the case with standard exe
21. How can a win service developed in .NET be installed or used in Win98?Windows service
cannot be installed on Win9x machines even though the .NET framework runs on machine.