WebServices And Windows Services
eg: wsdl http://LocalHost/WebServiceName.asmx“
What does WSDL stand for? Web Services Description Language
True or False: To test a Web service you must create a windows application or Web application to consume this service? False.
What are the various ways of accessing a web service ?
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.
Application has to wait until execution has completed.
<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>
<%@ Page Language="C#" %>
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
<%@ Page AspCompat="true" %>
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();
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
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.
This method is similar to the method that you can use to attach a debugger to a process and then debug a process.
- To determine the process ID (PID) of the process that hosts the service that you want to debug, use one of the following methods.
- Method 1: Use the Task Manager
- Right-click the taskbar, and then click Task Manager. The Windows Task Manager dialog box appears.
- Click the Processes tab of the Windows Task Manager dialog box.
- Under Image Name, click the image name of the process that hosts the service that you want to debug. Note the process ID of this process as specified by the value of the corresponding PID field.
- Method 2: Use the Task List Utility (tlist.exe)
- Click Start, and then click Run. The Run dialog box appears.
- In the Open box, type cmd, and then click OK.
- At the command prompt, change the directory path to reflect the location of the tlist.exe file on your computer.Note The tlist.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows
- At the command prompt, type tlist to list the image names and the process IDs of all processes that are currently running on your computer.
Note Make a note of the process ID of the process that hosts the service that you want to debug.
- Method 1: Use the Task Manager
- At a command prompt, change the directory path to reflect the location of the windbg.exe file on your computer.Note If a command prompt is not open, follow steps a and b of Method 1. The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows.
- At the command prompt, type windbg –p ProcessID to attach the WinDbg debugger to the process that hosts the service that you want to debug.
Use the image name of the process that hosts the service that you want to debug
You can use this method only if there is exactly one running instance of the process that hosts the service that you want to run. To do this, follow these steps:
- Click Start, and then click Run. The Run dialog box appears.
- In the Open box, type cmd, and then click OK to open a command prompt.
- At the command prompt, change the directory path to reflect the location of the windbg.exe file on your computer.Note The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows.
- At the command prompt, type windbg –pn ImageName to attach the WinDbg debugger to the process that hosts the service that you want to debug.
- Start Windows Explorer.
- Locate the windbg.exe file on your computer.Note The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows
- Run the windbg.exe file to start the WinDbg debugger.
- On the File menu, click Attach to a Process to display the Attach to Process dialog box.
- Click to select the node that corresponds to the process that hosts the service that you want to debug, and then click OK.
- In the dialog box that appears, click Yes to save base workspace information. Notice that you can now debug the disassembled code of your service.
You can use this method to debug services if you want to troubleshoot service-startup-related problems.
- Method 1: Use the Global Flags Editor (gflags.exe)
- Start Windows Explorer.
- Locate the gflags.exe file on your computer.Note The gflags.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows.
- Run the gflags.exe file to start the Global Flags Editor.
- In the Image File Name text box, type the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.
- Under Destination, click to select the Image File Options option.
- Under Image Debugger Options, click to select the Debugger check box.
- In the Debugger text box, type the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe
h. Click Apply, and then click OK to quit the Global Flags Editor.
- Method 2: Use Registry Editor
- Click Start, and then click Run. The Run dialog box appears.
- In the Open box, type regedit, and then click OK to start Registry Editor.
- Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options - Point to New, and then click Key. In the left pane of Registry Editor, notice that New Key #1 (the name of a new registry subkey) is selected for editing.
- Type ImageName to replace New Key #1, and then press ENTER.Note ImageName is a placeholder for the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.
- Right-click the registry subkey that you created in step e.
- Point to New, and then click String Value. In the right pane of Registry Editor, notice that New Value #1, the name of a new registry entry, is selected for editing.
- Replace New Value #1 with Debugger, and then press ENTER.
- Right-click the Debugger registry entry that you created in step h, and then click Modify. The Edit String dialog box appears.
- In the Value data text box, type DebuggerPath, and then click OK.
Note DebuggerPath is a placeholder for the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe
- Method 1: Use the Services console
- Click Start, and then point to Programs.
- On the Programs menu, point to Administrative Tools, and then click Services. The Services console appears.
- In the right pane of the Services console, right-click ServiceName, and then click Properties.Note ServiceName is a placeholder for the name of the service that you want to debug.
- On the Log On tab, click to select the Allow service to interact with desktop check box under Local System account, and then click OK.
- Method 2: Use Registry Editor
- In Registry Editor, locate, and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName
Note Replace ServiceName with the name of the service that you want to debug. For example, if you want to debug a service named MyService, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService - Under the Name field in the right pane of Registry Editor, right-click Type, and then click Modify. The Edit DWORD Value dialog box appears.
- Change the text in the Value data text box to the result of the binary OR operation with the binary value of the current text and the binary value, 0x00000100, as the two operands. The binary value, 0x00000100, corresponds to the SERVICE_INTERACTIVE_PROCESS constant that is defined in the WinNT.h header file on your computer. This constant specifies that a service is interactive in nature.
- In Registry Editor, locate, and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName
- In Registry Editor, locate, and then right-click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
- Point to New, and then click DWORD Value. In the right pane of Registry Editor, notice that New Value #1 (the name of a new registry entry) is selected for editing.
- Type ServicesPipeTimeout to replace New Value #1, and then press ENTER.
- Right-click the ServicesPipeTimeout registry entry that you created in step c, and then click Modify. The Edit DWORD Value dialog box appears.
- In the Value data text box, type TimeoutPeriod, and then click OKNote TimeoutPeriod is a placeholder for the value of the time-out period (in milliseconds) that you want to set for the service. For example, if you want to set the time-out period to 24 hours (86400000 milliseconds), type 86400000.
- Restart the computer. You must restart the computer for Service Control Manager to apply this change.
- Click Start, and then point to Programs.
- On the Programs menu, point to Administrative Tools, and then click Services. The Services console appears.
- In the right pane of the Services console, right-click ServiceName, and then click Start.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3631&lngWId=10
Read more:
- C# and ASP.NET Questions (All in one)
- MVC Interview Questions
- C# and ASP.NET Interview Questions and Answers
- Web Services and Windows Services Interview Questions
Other Series
My other series of articles:
For more technical articles you can reach out to CodeTeddy.
12 comments