Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide/override/wrap web service calls on client side

Status
Not open for further replies.

misterstick

Programmer
Apr 7, 2000
633
GB
i have a web service which marshalls arrays of custom data objects.

you can't pass complex list types across a web service (and rightly so) so the web service unpacks these into simple arrays on the server side.

what i'd like to do is create calls on the client side which wrap these simple arrays in complex lists.

because i'm too lazy and stupid to replicate the code, i'd still like to keep the asynchronous calls, so i've derived a wrapper object from the microsoft provided service object.

however, this makes the "real" web service calls available in code.

is there any way i can hide these calls?

i'd like to force developers to use the methods that return complex lists instead of ones that return simple arrays.

Code:
// server side
class ComplexService : System.Web.Services.WebService
{
[WebMethod]
public ComplexObject[] GetComplexObjectsWS()
{
  List<ComplexObject> list = SomeFactoryClass.ListOfComplexObject();
  ComplexObject[] array = new ComplexObject[list.Count];
  list.CopyTo(array);
  return array;
}
}

Code:
// client side
using MicrosoftGeneratedWebServiceCode;

class ComplexWrapper : ComplexService
{
// want to hide this completely
public new ComplexObject[] GetComplexObjectsWS()
{
  return base.GetComplexObjectsWS();
}

// so that developers have to use this
public List<ComplexObject> GetComplexObjects()
{
  List<ComplexObject> list = new List<ComplexObject>();
  ComplexObject[] array = base.GetComplexObjectsWS();
  foreach ( ComplexObject complex in array )
  {
    list.Add(complex);
  }
  return list;
}
}

any ideas?
MTIA,

mr s. <;)

 
You're re-creating the methods of the webservice anyways so why wouldn't you just put it in a separate class?

Then make the webservice class internal...
 
thanks for the prompt response.

i did start to wrap (exposing the methods of a contained member variable instance of the class) rather than inherit (using the service as a base class), but ran into a problem.

wrapping has the giant downside that the useful microsoft generated code has to be hand replicated.

more specifically, i really don't want to have to start generating the code to call the web service asynchronously, which is complex and probably liable to arbitrary change.

thanks again,

mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top