preserving same type information
-
Hi! I am having an interesting problem while compiling code across different projects in the same VS.NET solution. Here is the scenario: 1. I have a project (called DataTypes) which defines common classes that I want to use throughout. 2. There is a webservice (WSA) which has a method which accepts two objects: MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2) 3. This webservice also calls another webservice (WSB) from MethodA. The method in WSB has the following signature: MethodB(DataTypes.Type1 objType1, DataTypes.Type2 objType2). In the WSA project there is a web reference to WSB (lets call it refB). So this looks like: MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2){ objType1.somefield=new_value; refB.MethodB(objType1, objType2); } When the client invokes WSA it passes the objects. MethodA modifies one of the parameters and passes these to WSB. 4. This code gives me a compilation error. The error message is "Cannot convert DataTypes.Type1 to refb.Type1". Understandably, the type information in the generated proxy for WSB refers to its interpretation of what Type1 is. Even though its the same as that in WSA. Any suggestions on how I can solve this problem? Thanks!
-
Hi! I am having an interesting problem while compiling code across different projects in the same VS.NET solution. Here is the scenario: 1. I have a project (called DataTypes) which defines common classes that I want to use throughout. 2. There is a webservice (WSA) which has a method which accepts two objects: MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2) 3. This webservice also calls another webservice (WSB) from MethodA. The method in WSB has the following signature: MethodB(DataTypes.Type1 objType1, DataTypes.Type2 objType2). In the WSA project there is a web reference to WSB (lets call it refB). So this looks like: MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2){ objType1.somefield=new_value; refB.MethodB(objType1, objType2); } When the client invokes WSA it passes the objects. MethodA modifies one of the parameters and passes these to WSB. 4. This code gives me a compilation error. The error message is "Cannot convert DataTypes.Type1 to refb.Type1". Understandably, the type information in the generated proxy for WSB refers to its interpretation of what Type1 is. Even though its the same as that in WSA. Any suggestions on how I can solve this problem? Thanks!
Hi, I remember reading somewhere that when you pass an object to a webservice, it gets autoconverted to a proxy object, which _is not_ of the same type as the one being passed. That is the problem, imho. It is recommended to pass DTOs (data transfer objects) between layer boundaries (which is, when you call a method in a web service, you pass the layer boundary). Regards, Serge (Logic Software, Easy Projects .NET site)
-
Hi, I remember reading somewhere that when you pass an object to a webservice, it gets autoconverted to a proxy object, which _is not_ of the same type as the one being passed. That is the problem, imho. It is recommended to pass DTOs (data transfer objects) between layer boundaries (which is, when you call a method in a web service, you pass the layer boundary). Regards, Serge (Logic Software, Easy Projects .NET site)