Handling Metadata with Indigo - Exporting metadata for proxy generation
(Page 2 of 4 )
In this part of the lab, you will export the service metadata to a set of files that can later be distributed and used to generate a proxy, offline. The files exported will be WSDL documents.
Launch the Visual Studio 2005 Command Prompt. Run the following command to instruct SvcUtil to export the service metadata and its associated schemas for the
HelloIndigoService:
svcutil
/d:<YourLearningWCFPath>\Labs\Chapter1\IISHostedService /t:metadata http:
//localhost/IISHostedService/service.svcThis will generate two
.wsdl files and two
.xsd files in the solution directory.
Figure 1-27. Browsing to the service help page with metadata browsing enabledUse these files to generate the application configuration and proxy required for clients to consume the service. In the same command window, execute the following command:
svcutil
/d:<YourLearningWCFPath>\Labs\Chapter1\IISHostedService\Client /o:
serviceproxy.cs /config:app.config <YourLearningWCFPath>\Labs\Chapter1\
IISHostedService\*.wsdl <YourLearningWCFPath>\Labs\Chapter1\IISHostedService\*.
xsd
The result of this command will be serviceproxy.cs and app.config files generated for the client application.
Add the two files just generated to the client project. The proxy and configuration will be used to invoke the service hosted in IIS. Go to theClientproject and refresh the file list in Solution Explorer. You should see the two new files appear; include them in the project.
Invoke the service using the generated proxy. Open Program.cs in the code window and modify theMain()entry point adding code to create a proxy and invoke theHelloIndigo()operation. The resulting additions are shown in bold in Example1-15.
Compile and run theClientproject. The output should be similar to that in earlier labs.

Figure 1-28. Browsing to the dynamically generated WSDL document
Example 1-15. Invoking a service hosted in IIS through its proxy
static void Main(string[] args)
{
HelloIndigoServiceClient proxy = new HelloIndigoServiceClient()
string s = proxy.HelloIndigo();
Console.WriteLine(s);
Console.WriteLine("Press <ENTER> to terminate Client.");
Console.ReadLine();
}
Next: Web Site Templates >>
More BrainDump Articles
More By O'Reilly Media
|
This article is excerpted from chapter one of the book Learning WCF A Hands-on Guide, written by Michele Leroux Bustamante (O'Reilly, 2007; ISBN: 0596101627). Check it out today at your favorite bookstore. Buy this book now.
|
|