Yes you can do that. We call it a data marshaller, but in this example I'll call it a consolidator.
You will notice that the WSDL generated class is a partial, we create a (web reference name).cs file and have something like:
Below are files you create, not WSDL generated files
WebReference1.cs
public partial class WebReferenceName1 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
// take the methodname and append Local to the end
public Consolidated.ReturnType MethodName1Local(params)
{
// redirect the return value of the call to the consolidation method and return the new value
return Consolidation.Convert(this.MethodName1(params);
}
}
then the second web service
WebReference2.cs
public partial class WebReferenceName2 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
// take the methodname and append Local to the end
public Consolidated.ReturnType MethodName2Local(params)
{
// redirect the return value of the call to the consolidation method and return the new value
return Consolidation.Convert(this.MethodName2(params);
}
}
and now the class that converts from the two types
Consolidator.cs
public class Consolidation
{
// Input from Web Reference #1
public static Consolidated.ReturnType Convert(WebReferenceName1.ReturnType valuetoConvert)
{
// Convert from valuetoConvert to Consolidated.ReturnType
convertedValue = (conversion of valuetoConvert to Consolidated.ReturnType);
return convertedValue;
}
// Input from Web Reference #2
public static Consolidated.ReturnType Convert(WebReferenceName2.ReturnType valuetoConvert)
{
// Convert from valuetoConvert to Consolidated.ReturnType
convertedValue = (conversion of valuetoConvert to Consolidated.ReturnType);
return convertedValue;
}
}
Basically you add methods to the web reference, call the {WebMethod}Local() methods, and that gets routed through the Consolidator and converts the simple WSDL generated class to something you can actually use.
Consolidated.ReturnType is what you define in your local project, its the local version of the data type that the WSDL generated under the web reference. Typically the "conversion" is just a clone / property by property copy from one type to another.