[ITOO] WCF -- the Client calls the WCF Service, and the itooclient calls the wcf

Source: Internet
Author: User

[ITOO] WCF -- the Client calls the WCF Service, and the itooclient calls the wcf

The three steps have already taken two steps. After a WCF Service is released, it waits for the user to call it. It only provides one interface, exposing the address and contract, do not expose how the service is implemented. Next, let's talk about how the client calls the WCF Service.

In fact, it is very easy to call. First, let us identify the services we need, that is, configure the same endpoint information, add a service reference, and finally call the corresponding method.

As shown in the configuration file:

    <applicationSettings>        <WebDemoClient.Properties.Settings>            <setting name="WebDemoClient_WebHelloService_WebHello" serializeAs="String">                <value>http://192.168.24.94:82/WebHello.asmx</value>            </setting>            <setting name="WebDemoClient_WebAdd_WebHello" serializeAs="String">                <value>http://192.168.24.94:82/WebHello.asmx</value>            </setting>        </WebDemoClient.Properties.Settings>    </applicationSettings>

Then call the method:

Protected void Button1_Click (object sender, EventArgs e) {WebHelloService. WebHello web = newWebHelloService. WebHello (); this. TextBox1. Text = web. Hello (" ");}

The final running result is successful:




The client can call many services that we need to implement our functions at the same time, but when we need to do one thing at the same time many services or many methods in one service, in this case, transactions are involved. To ensure data consistency and atomicity, distributed transactions are supported in WCF. That is to say, transactions can exist between multiple services and clients across the boundaries of services, processes, and machines. WCF provides protocols that support distributed transactions and related features.

At the same time, WCF has many benefits. I also mentioned it in the first WCF introduction. In this way, the use of a complete WCF Service is finished. It also fully proves that our dream will be realized as long as we follow the correct path. We can call different existing interfaces to serve us and learn to use the power of others, standing on the shoulders of giants. Service-oriented era, interface-oriented programming.



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.