15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

OC120 ❘ ChaPTer 51 enterprise services<br />

Client application<br />

Create a new console application named WCFClientApp . Because the service offers a MEX endpoint,<br />

you can add a service reference from Visual Studio by selecting Project ➪ Add Service Reference . . .<br />

(see Figure 51 - 15).<br />

If the service is COM+ hosted, you have to start the application before you can<br />

access the MEX data. If the service is hosted inside WAS, the application is started<br />

automatically.<br />

figure 51-15<br />

With the service reference a proxy class is created, the assemblies System.ServiceModel <strong>and</strong> System.<br />

Runtime.Serialization are referenced, <strong>and</strong> an application confi guration fi le referencing the service is<br />

added to the client application.<br />

Now you can use the generated entity classes <strong>and</strong> the proxy class OrderControlClient to send an order<br />

request to the serviced component:<br />

static void Main()<br />

{<br />

var order = new Order<br />

{<br />

CustomerId = "PICCO",<br />

OrderDate = DateTime.Today,<br />

ShipAddress = "Georg Pipps",<br />

ShipCity = "Salzburg",<br />

ShipCountry = "Austria"<br />

};<br />

var line1 = new OrderLine<br />

{<br />

ProductId = 16,<br />

UnitPrice = 17.45F,<br />

Quantity = 2<br />

};<br />

var line2 = new OrderLine<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!