Service Model
-
Hi, what is the best model for using services in a silverlight application? I usualy add a wcf service to my ASP.net app and add a service refrence to my silverlight application, but anytime I change my service I should update the service refrence in silverlight app. Is there any better and more proffessional way?
Best wishes
-
Hi, what is the best model for using services in a silverlight application? I usualy add a wcf service to my ASP.net app and add a service refrence to my silverlight application, but anytime I change my service I should update the service refrence in silverlight app. Is there any better and more proffessional way?
Best wishes
mehrdadc48 wrote:
Is there any better and more proffessional way
I'm gonna be interested in reponses to this one, I see no other alternative to updating the service reference whenever you change the service. I do take exception to having my method called unprofessional :mad:
Never underestimate the power of human stupidity RAH
-
mehrdadc48 wrote:
Is there any better and more proffessional way
I'm gonna be interested in reponses to this one, I see no other alternative to updating the service reference whenever you change the service. I do take exception to having my method called unprofessional :mad:
Never underestimate the power of human stupidity RAH
If you can reference an assembly with your service interface and any types you might use. Then you can use the ChannelFactory
ChannelFactory factory = new ChannelFactory()
IService myService = factory.CreateChannel();
myService.Foo();the drawback is you don't have any auto generated code so if you need asynchronous calls then you'll have to write that yourself. If you need the auto generated code, then I suppose you could use svcutil in the post build event of your service project. eg.
svcutil "http://localhost:1892/IMyService.svc" /out:OutputDir\MyService.cs
This however requires that you have an ISS running with a site that has your service's output directory as it's Content directory. Also you proporbly have some kind of source control so you might want to add some lines before the above line so that MyService.cs is checked out before svcutil overwrites it. That's the only two way I know of to avoiding having to update the service reference.
-
If you can reference an assembly with your service interface and any types you might use. Then you can use the ChannelFactory
ChannelFactory factory = new ChannelFactory()
IService myService = factory.CreateChannel();
myService.Foo();the drawback is you don't have any auto generated code so if you need asynchronous calls then you'll have to write that yourself. If you need the auto generated code, then I suppose you could use svcutil in the post build event of your service project. eg.
svcutil "http://localhost:1892/IMyService.svc" /out:OutputDir\MyService.cs
This however requires that you have an ISS running with a site that has your service's output directory as it's Content directory. Also you proporbly have some kind of source control so you might want to add some lines before the above line so that MyService.cs is checked out before svcutil overwrites it. That's the only two way I know of to avoiding having to update the service reference.
All this b/c the OP does not like the auto generated code. Not a chance, I have no problem using the auto code, I know what it does, I understand how it works and I have absolutely no interest in circumventing the MS methodology. The only time I can justify chucking this type of auto generated code is if the code is flaky or it needs to be extended for some reason, so far this has not been the case!
Never underestimate the power of human stupidity RAH
-
All this b/c the OP does not like the auto generated code. Not a chance, I have no problem using the auto code, I know what it does, I understand how it works and I have absolutely no interest in circumventing the MS methodology. The only time I can justify chucking this type of auto generated code is if the code is flaky or it needs to be extended for some reason, so far this has not been the case!
Never underestimate the power of human stupidity RAH
Mycroft Holmes wrote:
I have absolutely no interest in circumventing the MS methodology
I don't see how either of those two methods is circumventing the MS methodology. When you press Update Service Reference it's svcutil that is being used. Using the ChannelFactory is what I personally use when I control both the server and the client. My primary reasons for this is; I don't have to update anything(Service reference) and I'm not limited to using DTO's. While converting a project from using the auto generated proxy to using the ChannelFactory may very well be a waste of time. I do still beleave my other suggestion (using the svcutil) is easy to do and would work.