Learn WCF (3)--Developing WCF client programs

Source: Internet
Author: User
Tags configuration settings

Previous learn WCF (2)--the development of WCF services introduced the development Service program, this development of a client program, there are mainly three scenarios:

Add a Web Reference

Using the SvcUtil.exe tool

Programming Scenarios

1. Add a Web Reference

This is basically consistent with the method of adding a reference Web service, and enter URL:HTTP://LOCALHOST:39113/WCFSERVICETEXT/WCFSTUDENTTEXT.SVC in the dialog box that adds the reference

To name WCF, click the Add Reference button to complete the following tasks:

(1) Download the WSDL file for Student Management service from the specified URL

(2) Generate proxy class Wcfstudenttext, it is the proxy of server Wcfstudenttext, realize the server contract Istuservicecontract.

(3) Configuration settings for generating responses

Now we can communicate with the Student Information Management Service with the proxy class Wcfstudenttext. Add a page to the site, put a GridView and ObjectDataSource

<div>
<asp:gridview id= "GridView1" runat= "server" backcolor= "white"
Borderc Olor= "#DEDFDE" borderstyle= "None" borderwidth= "1px" cellpadding= "4"
datasourceid= "ObjectDataSource1" Fore Color= "Black" gridlines= "Vertical"
<rowstyle backcolor= "#F7F7DE"/>
<footerst  YLE backcolor= "#CCCC99"/>
<pagerstyle backcolor= "#F7F7DE" forecolor= "Black" horizontalalign= "right" />
<selectedrowstyle backcolor= "#CE5D5A" font-bold= "True" forecolor= "white"/>
& Lt HeaderStyle backcolor= "#6B696B" font-bold= "True" forecolor= "white"/>
<alternatingrowstyle BackColor = "White"/>
</asp:gridview>

<asp:objectdatasource id= "ObjectDataSource1 runat=" serve R "Typename=" Stuwcfservice.wcfstudenttext "selectmethod=" getstudent "
</asp:objectdatasource>
;/div>

The advantage of Objectdatasourse is that you can invoke methods in the proxy class without writing a single line of code. What should be noted here is the typename,selectmethod of two important attributes, which must be consistent with the proxy class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.