Tom
Tom

Reputation: 8701

WCF - passing parameters

I have WCF service method that accepts an int parameter and returns a result set based on that parameter. I am using linq and entity framework to retrieve the records. There is a new requirement to query the same table with another field.This field is a varchar field and would take string parameter as input. So what is the best way to implement this. Is it better to extend the same service method to incorporate the new parameter or do I make a separate service method. The other point to be noted is that I don't which parameter would the client be passing at any given point of time. Following is the existing service method logic

public IEnumerable<TBI.JV.Business.Objects.Asset> GetAssetsBasicBySedols(int[] sedols)
        {
            var priceDate = DateTime.UtcNow.Date.AddMonths(-8);
            var typeList = new string[]
                {
                    "UNIT TRUST",
                    "OEIC",
                    "INVESTMENT TRUST",
                    "INVESTMENT COMPANY",
                    "PENSION FUND",
                    "INSURANCE BOND",
                    "LISTED EQUITY",
                    "PREFERENCE SHARE",
                    "ZERO DIVIDEND PREF",
                    "GILT (CONVENTIONAL)",
                    "GILT (INDEX LINKED)",
                    "AIM",
                    "VCT",
                    "OFFSHORE FUND",
                    "ETP"
                };
            using (var dealingContext = new dbDealingContainer())
            {
                return (from fundprice in dealingContext.FundPrices
                        where (fundprice.FUND_STATUS == "ACTIVE" || fundprice.FUND_STATUS == "SUSPENDED") &&
                              (fundprice.INVNAME != null || fundprice.INVNAME != "") &&
                              !fundprice.INVNAME.StartsWith("IFSL Bestinvest") &&
                              fundprice.WaterlooTradable == true &&
                            //fundprice.PRICE_DATE > priceDate &&
                              fundprice.BID_MID_PRICE > 0 && typeList.Contains(fundprice.FUND_TYPE)
                              && ((sedols.Count() > 0 && sedols.Contains(fundprice.Id)) || sedols.Count() == 0)
                        select new TBI.JV.Business.Objects.Asset
                        {
                            AssetName = fundprice.INVNAME,
                            AssetId = fundprice.Id,
                            AssetType = fundprice.FUND_TYPE,
                            Epic = fundprice.INVESTMENT_CODENAME,
                            StarRating = fundprice.STARLEN,
                            Sedol = fundprice.SEDOL_NUMBER
                        }).ToList();
            }
        }

Upvotes: 1

Views: 86

Answers (1)

JoeBilly
JoeBilly

Reputation: 3107

In short, you need to add a service method with this new parameter.

In Service Oriented Architecture, modifying (and therefore deleting) is considered as a breaking change while adding is transparent for the clients.

When you change your service side, you have to ask yourself what will happen to the actual clients using your application. If the answer is "they will have to update their clients", this is generally not a good thing.

In another point of view, new functionalities means new concepts and should not change the existing concepts.

Also, even if you plan to replace an existing functionality, you shouldn't do it in one step. You should think about ascendant compatibility : ship the service with the new modified functionality, mark the old one as obsolete, inform your clients and ship the service in its final version later.

The whole concept behind this is called SOA Governance.

Upvotes: 3

Related Questions