c# - How to handle parameter changes in webservice versions -


i'm relatively new webservices , c# not programing (lots of experience in legacy systems).

i've got closed loop system - write webservice , consuming application - on pda.

web service published , pda app, use "add new web reference" feature in vs.

i can use code like:

appname.com.mydomain.webservicename s = new appnamecom.mydomain.webservicename(); s.somemethod(param1, param2); 

all well...until discover need update 1 of webmethods take 3 parameters when used take 2.

if change webservice , publish, existing pda's fail on call until new version of pda software. hundreds in field, can't update them @ once nor want require them update @ same time.

solution 1:

add version number webservice method somemethod has somemethodv2(1,2,3) update pda software use s.somemethodv2

solution 2: copy existing "webservicename" webservicenamev2, has somemethod(1,2,3) change pda software reference appname.com.mydomain.webservicenamev2 @ point when know no pda's using v1 anymore, shut down webservice.

both of these solutions have pro's & con's i'm not convinced there two; there more elegant ways handle situation ? perhaps not using "add new web reference"

i'm using .net 2.0 pda, .net 3.5 webservice; c# both. i've not looked yet don't think can use wcf .net 2.0 on pda.

andrew

i think hybrid approach gives best of both worlds:

before:

public interface imyservice {     someresponse somemethod(object param1, object param2); }  public class myservice : imyservice {     public someresponse somemethod(object param1, object param2)     {         // stuff     } } 

after:

public interface imyservice {     someresponse somemethod(object param1, object param2); }  public interface imyservice2 {     someresponse somemethod(object param1, object param2, object param3); }  public class myservice : imyservice, imyservice2 {     public someresponse somemethod(object param1, object param2)     {         return somemethod(param1, param2, null);     }      public someresponse somemethod(object param1, object param2, object param3)     {         // stuff     } } 

your existing endpoint remains unchanged, because still using same contract (interface), new endpoint go-forward/updated pdas points new contract, , don't have copy/duplicate service implementation -- implement multiple contracts.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -