Re: How do I create an object?
From: Alvin Bruney [ASP.NET MVP] (www.lulu.com/owc)
Date: 03/06/05
- Next message: SB: "Re: Why no serious MS Application in .NET yet ??"
- Previous message: Dave Hall: "Re: How do I create an object?"
- In reply to: Dave Hall: "Re: How do I create an object?"
- Next in thread: Dave Hall: "Re: How do I create an object?"
- Reply: Dave Hall: "Re: How do I create an object?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 5 Mar 2005 21:35:33 -0500
The webservice exposes a WSDL document for that vary purpose. Append wsdl to
the end of the URL and it will return the valid schema for the webservice.
You can simply query the returned XML to find what you need without
resorting to reflection and the like.
>From a design perspective, that's a horrid idea because
it imposes a cost on a call to a webservice which is equal to probing and
retrieving parameters before making the actual call. Added to the turtle
performance of an XML webservice and you have a recipe for disaster in high
concurrency situations. A better approach is to program to the final
webservice API since its implementation should be set in stone after
release.
-- Regards, Alvin Bruney [Shameless Author Plug] The Microsoft Office Web Components Black Book with .NET available at www.lulu.com/owc ------------------------------------------------------------ "Dave Hall" <DHall_NoSpamPlease@deboy.com> wrote in message news:%23iTPbteIFHA.1860@TK2MSFTNGP15.phx.gbl... >I have the almost the same question, but it's regarding a web service > object. The URL is known, so I think I can avoid messing with UDDI, but I > want to discover the methods (specifically the parameters to a known > method) > at run time. The idea is this: Suppose a particular web service exposes a > Person object. It has a method such as SetInfo(int age, string firstName, > string lastName). I have a collection of personal info from another source > that I want to pass to this web service. The info I have available incudes > age, firstName, middleName, lastName, maidenName, nameSuffix and SSN. The > web service will eventually be changed to accept some of the additional > information I have available and when it does, I want to pass them to the > corresponding parameters without recompiling my code. For example, SetInfo > may be changed to look like this: SetInfo(int age, string firstName, > string > middleName, string lastName, string SSN). In that case, I want to > "discover" > the parameter names at run time and provide the corresponding values from > my > available data. If the Person object was a "normal" .NET component, I > would > know how to use reflection to learn the methods and properties at run time > and to invoke them. If the Person.SetInfo method was a stored procedure, I > could loop through the parameters collection and learn their names. I > haven't worked with .NET remoting yet, so I don't know if that's even > applicable with a web service. How can I do something comparable with a > web > service object? > > Thanks, > Dave > > > "William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message > news:eD$OfeRIFHA.1948@TK2MSFTNGP14.phx.gbl... >> "Jim Robertson" <JimRobertson@discussions.microsoft.com> wrote in message >> news:430FB08F-EFF6-47C9-832D-C93C9AE80F18@microsoft.com... >> > Is there a way to instantiate an object whose type isn't known until >> > runtime? >> > Something comparable to Java's Class.newInstance()? >> >> Yup. Check the docs for Activator.CreateInstance(). >> >> Just btw, like Java, .Net supports reflection so you'll be able to get an >> instance of a class if you like and inspect it for methods and members as >> well, if you have a need to do that. >> >> Regards, >> Will >> >> >> > >
- Next message: SB: "Re: Why no serious MS Application in .NET yet ??"
- Previous message: Dave Hall: "Re: How do I create an object?"
- In reply to: Dave Hall: "Re: How do I create an object?"
- Next in thread: Dave Hall: "Re: How do I create an object?"
- Reply: Dave Hall: "Re: How do I create an object?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|