DotNet Linux Learning Record-Jexus homestay simple WCF Service

Source: Internet
Author: User
Tags dotnet

{0}

{0}

usingSystem.ServiceModel;namespaceibll{/// <summary>    ///Service Contract Interface/// </summary>[ServiceContract] Public InterfaceIwcfdemoservice {/// <summary>        ///an operation contract (equivalent to WebMethod in WebService)/// </summary>        /// <param name= "a" ></param>        /// <param name= "B" ></param>        /// <returns></returns>[OperationContract]intADD (intAintb); }}

{1}

using IBLL; namespace bll{    ///<summary>//      Services contract    Business class  /// </summary>     Public class Wcfdemoservice:iwcfdemoservice    {        publicint Add (intint  b)        {              return A + b;}}    }

{2}

1. Create a new empty WebApplication project Wcfapp

2. Create a new class file named WcfTestService.cs

3. Rename the WcfTestService.cs to Wcftestservice.svc

4. Empty the contents of Wcftestservice.svc, write content (the service value is the same as the Name property value of the service node in Web. config)

<%@ ServiceHost service="BLL. Wcfdemoservice" %>

5. Modify the contents of the Wcfapp Web. config file

Note: The value of the name attribute in the Serivce node must implement the class name of the business class for the service contract

<?XML version= "1.0" encoding= "Utf-8"?><Configuration>  <system.web>    <compilationDebug= "true"targetframework= "4.5"/>    <HttpRuntimetargetframework= "4.5"/>    <customErrorsMode= "Off"/>  </system.web>    <!--WCF Configuration Start -  <System.ServiceModel>    <Services>      <!--Note: The service name must match the configuration name of the service implementation.  -      <Servicename= "BLL." Wcfdemoservice "behaviorconfiguration= "BLL." Wcfdemoservice " >        <!--Add the following endpoints.  -        <!--Note: The service must have an HTTP base address to add this endpoint.  -        <EndpointContract= "IBLL." Iwcfdemoservice "binding= "mexHttpBinding"Address= "Mex" />      </Service>    </Services>    <Behaviors>      <servicebehaviors>        <Behaviorname= "BLL." Wcfdemoservice " >          <!--Add the following elements to the service behavior configuration.  -          <Servicemetadatahttpgetenabled= "true" />        </Behavior>      </servicebehaviors>    </Behaviors>  </System.ServiceModel>  <!--WCF Configuration End -  </Configuration>

DotNet Linux Learning record-Jexus homestay simple WCF service

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.