I’m currently working on some web services network (ASP.NET 3.5 web services).
My business layer is similar for all services – it means I have same structs with same fields in each service.
But when I pass these structs between the services, every time I need to make a transformation from global type to local type, for example:
If I have a method that returns instance of struct.
[WebMethod]
public MyObject MyMethod () {
return new MyObject();
}
When I call it from client service I write something like this:
OuterService proxy = new OuterService();
global::MyObject obj = proxy.MyMethod();
Where OuterService is an instance of class generated by wsdl.exe.
And then, to pass it to next service I need to tranform it from global type to local type field by field and property by property.
So, my question is:
Is there any elegant solution to pass these objects without transformation on each level?
I thought about creating universal business layer for all web services (which for instance may be declared as web-service too), but to do it I need to change too many things and I think there must be easier solution for this, provided by framework.
Just use “Add Service Reference”. By default, it shares types that are in assemblies referenced by your project. Just add a reference to the assembly containing the types, use “Add Service Reference” or “Update Service Reference”, and you should be all set.