简体   繁体   中英

Call a WCF Service from client side

I am going to create a WCF service(IIS host) and it will be called from client side javascript code.

When I call a WCF from client side, is the WCF a WCF library or WCF application type?

For example: I have the javascript below.

function AddFunds() {
    var postObject = {
        myID: myObject.myIDNumber,
        LocationID: myObject.LocationID,
        fundsToAdd: CurrencyFormatted($("#txtAddFunds").val())
};
    $.post('/OrServices/myService.svc/AddFunds',
        JSON.stringify(postObject)
        ).success(AddFundsResult);
}

In the beginning, I have to create WCF Service "myService.svc", but I am not sure if it is a library or application or doesn't matter.

this answer describes the difference:

A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup.

If you start with a service library (recommended) you can then choose any host you wish (a windows service, IIS/ASP.NET, or even a console application) and you'd just reference your library from your new host. Choosing a Service Application limits your host to just IIS/ASP.NET (though this might be ok for your purposes, but will limit the protocols you can use).

Edit: Changes in IIS since I wrote this allow for a wider variety of protocols on ASP.NET activated services, so choosing a service application is much less limiting than before.

if your only going to host in IIS then I would recommend to just use a Service Application. As a lot of the work is done for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM