11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

CHAPTER 4 ■ INSTALLING AND CREATING WCF SERVICES 123ramrameshreddy.blog.comThis configuration file contains a system.serviceModel section, in bold, that provides thenecessary binding and contract information for the sample. The service element identifies thespecific .NET type that is exposed through this service endpoint. The endpoint element identifiesthe specific contract that is bound to the service type listed. Since the example is using IISactivation, the wsHttpBinding is the binding used, which supports request-reply in addition toreliable, secure, and transactional message exchange.Then, right-click again the web project, and add a .NET 3.0/WCF service. Modify the dialogbox entries by specifying TradeService.svc as the name of the file and setting C# as thelanguage.Open the newly created TradeService.svc file, and replace the contents with this singleline:Note that the Service parameter is now set to a type that resides in the assembly generatedfrom the exchange service project.First, do a solution build (Build ➤ Build Solution). Now, right-click the web project, andchoose View in Browser (you must have directory browsing enabled as in Figure 4-7). OnceInternet Explorer opens and you see the directory listing, click the TradeService.svc file. Atthis point, the ASP.NET runtime will begin the compilation process, generating the requiredassemblies to service your request. After a few seconds (depending upon your machine configuration),you should see the standard help screen similar to what is shown in Figure 4-2.You’ve now created a simple TradeService that leverages a best practice of separating theservice implementation into its own assembly and referencing it from a web project. If youlook at the accompanying solution, a simple client console project calls the service for a fewsecurities.If you enter the following into a browser (ensure the ASP.NET development server is runningand the port for your site matches), you’ll see the differences in the generated metadatafor the namespace and name of the service:http://localhost:8888/ExchangeWeb/TradeService.svc?wsdlOperationContract AttributeThe OperationContract attribute, as with the ServiceContract attribute, provides for evengreater control over the WSDL generation. Generally you’ll accept most of the defaults, but forcertain features, such as duplex messaging, you’ll need to use options indicating the operationis one-way. Additionally, for session management, you’ll be leveraging some of the options foroverall service session management.Table 4-6 describes the properties in the OperationContract attribute type.ramrameshreddyramrameshreddy

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

Saved successfully!

Ooh no, something went wrong!