WCF Fool Tutorial

Source: Internet
Author: User

The first step is to create a new WCF service application

The second step is to define the interface:

Modify the interface class to define the method interface default file name: IService1.cs

The third step is to implement the interface:

Implement the interface method in the Svc file, default file name: Service1.svc

Fourth step, Web. config (very important):

Basically there are problems here. To upload a simple configuration file directly, see the following code:

  

<?xml version="1.0"encoding="Utf-8"?><configuration> <system.web> <compilation debug="true"targetframework="4.0"/> </system.web> <system.serviceModel> <!--****************** to be hand-fitted start ******************--> &L t;services> <!--Add service-<service name="Wcfdemo.service1"behaviorconfiguration="Calculatorservicebehavior"> <!--name must be the same as the service initialized by the host instance in code behaviorconfiguration behavior configuration-"http://localhost:8000/"/> </baseAddresses> "Wcfdemo.iservice1"Wcfdemo.iservice1 for contract Interface binding="Wshttpbinding"Wshttpbinding is called over HTTP--<endpoint address=""binding="Wshttpbinding"contract="Wcfdemo.iservice1"></endpoint> </service> </services> <!--****************** to be hand-finished ******************--&    Gt <!--define Calculatorservicebehavior behavior--<behaviors> <serviceBehaviors> <!--************ to match a corresponding name ****************--> <behavior name="Calculatorservicebehavior"> <!--to avoid leaking metadata information, set the following values before deployment tofalseand delete the above metadata end point--<servicemetadata httpgetenabled="true"/> <!--to receive the fault exception details for debugging, set the following values totrue。 Before deployment, set tofalseTo avoid leaking exception information--<servicedebug includeexceptiondetailinfaults="false"/> </behavior> </serviceBehaviors> </behaviors> <servicehostingenvironment Multi Plesitebindingsenabled="true"/> </system.serviceModel> <system.webServer> <modules runallmanagedmodulesforallrequests="true"/> <defaultDocument> <files> <!--Be sure to and WCF service namespaces-class is the same-- <add value="service1.svc"/> </files> </defaultDocument> </system.webServer> </configuration>
Web. config

Fifth step, build the website

  

If you visit your

WCF Fool Tutorial

Related Article

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.