How can I restore the class from the DataSet that was selected by the Web Services proxy class?

Background

I have created a web service in Visual Studio and I am trying to use it using an auto generated proxy class. The web service returns a class that I have implemented that contains a list.

Question

The proxy class automatically generates SOAP submit methods to the web service. It uses the Invoke () method to make the call and then outputs the result as a DataSet. How can I return this object to a class that I know?

I know I can manually edit the auto-generated file, but it's not very convenient, so I don't want to go that route (anytime the web service is being rebuilt, the changes must be made again).

Is there a way to make the generated class more specific and actually use the correct data type? Or do I have to write a clumsy set of deserializers to get my data back in the correct form?

Example

One method in my web service class:

[WebMethod]
public UpdateList RetrieveUpdates(long sessionID, string configurationVersion, string coreVersion, string researcherDBVersion)
{ ... }

      

Adding a class as a web link generates the following proxy method:

public DataSet RetrieveUpdates(long sessionID, string configurationVersion, string coreVersion, string researcherDBVersion) {
    object[] results = this.Invoke("RetrieveUpdates", new object[] {
        sessionID,
        configurationVersion,
        coreVersion,
        researcherDBVersion});
   return ((DataSet)(results[0]));
}

      

The DataSet I get from this method is always empty (because you cannot cast it from my class in the DataSet).

Thank you in advance

0


source to share


2 answers


Since web links generate partial classes, you must add a partial class extension for the proxy class to your project that only repeats this method (just copy and paste it), but change the return type (and the name, of course). If the method signature changes, you need to update the extension, but at least if it doesn't and you update the proxy, you won't have to reapply any changes (and you can still use any other generated classes / methods as it is).



I have previously used this approach to "fix" proxy classes (for example, to add SOAP headers that are not defined in the WSDL), and while not ideal, it works.

+1


source


If your client code is not aware of your custom class (for example, it has an assembly reference), you will not be able to get an object of that type from the service.



It looks like what you want to do is the types of sections in the service layer. To do this, you will either have to provide your client application with a copy of the assembly it has UpdateList

, or you will need to look at something like WCF.

0


source







All Articles