c# - How do I make DRY code using generated WCF proxies from overlapping WSDLs -
i have bunch of wsdls our customer describing webservices have use in application.
there 1 webservice creating items, 1 querying them , 1 updating them. these wsdls have lot of overlap. items have create, query , update present in 3 wsdls in same way.
when use svcutil, can generate proxies 3 wsdls, every proxy defines items again. have same class, 3 times, in different namespace.
working forces me duplicate lot of code (e.g. mapping domein object on proxy class has done every proxy in same way).
the solution can think of manually edit proxies , take out overlap. however, think make difficult manage changes in web interfaces when regenerate proxies.
i wonder if possible somehow generate proxies in 1 go.
thanks in advance.
you might consider writing program parses customer wsdls , stores operations, etc in map (or multimap) of sort. iterate on map , remove duplicates , write result another, final wsdl , codegen on one. you'll have namespaces though.
something consider though: code needed more code you're duplicating?
another option define proxy class duplicated operations. have initialize adding operations namespace (create map of namespace strings map of operations, operation strings mapped code/object execute). each time want perform specific operation, pass in namespace string operate on.
imagine had op1 defined in namespaces ns1, ns2, , ns3 , op2 in ns1 , ns2. pseudo-code (strongly c++ biased) like:
class proxyoperations { addoperation(string opname, string namespace, operationbase op); // you'll have figure out operation parameters, // maybe wrap them in parameter context void dooperation(string opname, string namespace) { // lookup operation object , execute } typedef map<string, operationsbase> opermap; typedef map<string, opermap> namespacemap; namespacemap namespaceoperationmap_; }; { proxyoperations po; // populate po.addoperation("op1", "ns1", oper1objectns1); po.addoperation("op1", "ns2", oper1objectns2); po.addoperation("op1", "ns3", oper1objectns3); po.addoperation("op2", "ns1", oper2objectns1); po.addoperation("op2", "ns2", oper2objectns2); // use po.dooperation("op1", "ns2"); }
Comments
Post a Comment