CHAPTER 20 WEB SERVICES Once (Managed web hosting) the packages
CHAPTER 20 WEB SERVICES Once the packages are installed, it s time to begin. For starters, you need to generate a C# proxy for the Web Service. You can do this by using the Web Services Description Language tool (wsdl.exe), included within the SDK. Reference the WSDL-enabled boxing server script shown in Listing 20-8: wsdl /l:CS /protocol:SOAP http://localhost/book/20/boxing.php?wsdl The result is a file named boxing.cs. Feel free to open it up and examine the file s contents; just be sure not to change anything. Next, you ll compile this proxy as a DLL library. This is necessary because the DLL will be referenced by the C# application so that the Web Service s methods can be called. You compile a DLL like you would any other C# program, using the C# compiler tool (csc.exe): csc /t:library /r:System.Web.Services.dll /r:System.Xml.dll boxing.cs The /r flags tell the compiler to reference these libraries during the compilation process. The result is a file named boxing.dll. In turn, you ll reference this DLL when you compile the C# SOAP client, discussed next. Note Generating and compiling the proxy via the command line is indeed a tedious process. Bear in mind that the process is automated within Visual Studio .NET, greatly reducing development overhead. Finally, create the C# application. Although you could conceivably create a full-blown GUI application using a text editor, to stay on track, we ll forego doing so here. Instead, create a simple console application, as shown in Listing 20-13. Listing 20-13. The C# SOAP Client using System; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Serialization; namespace ConsoleApplication { class boxing { [STAThread] static void Main(string[] args) { BoxingService bx = new BoxingService(); Console.WriteLine(bx.getRandQuote()); } } }
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.