Referencing a C# web service project directly in C# solution -
i trying improve speed of c# job, let's call 'widgetprocessor'. in 1 run, widgetprocessor process 5,000 widgets , take 12 hours complete (about 8 seconds/widget).
widgetprocessor makes references 3 different web services , calls them multiple times each widget processed. there various performance/design improvements can made 'widgetprocessor' program, want test if multiple web service calls on network cause job run slow.
i have source code each of 3 web services (and have access of resources web services use), , i'm wondering if there way use web service interfaces in widgetprocessor referencing web service projects (instead of calling web service on network). web services implemented in c#.
i reference service implementation classes directly, main problem i'm running web services have collectively 100 data contracts , public facing names different implementation classes.
[datacontract(name = "widgetinfo")] public class widgetdatacontract { // datamembers } thus, referencing implementations directly means i'd making many code changes in widgetprocessor. rather, i'd use service interfaces, code changes can stay @ minimum.
basically, want service in widgetprocessor solution looks , acts web service, doesn't perform operations on network.
is possible?
you can add adapter classes subclass implementation name specified in datacontract:
public class widgetinfo : widgetdatacontract { } if finding overhead of service call overly expensive, may see benefit of going different binding or serialization format. wcf can approach in-process speed when tuned properly.
edit: if intent on not modifying code, have couple options, think solutions in search of problem:
- mono.cecil or roslyn automatically map between classes pre- or post-build
- for types, use
typeforwardedtoattribute, property access problematic. may dependent upon placingsvcutilgenerated classes in assembly. - use castle build dynamic proxies , map access based off of attributes
Comments
Post a Comment