Re: How do I create an object?

From: Alvin Bruney [ASP.NET MVP] (www.lulu.com/owc)
Date: 03/06/05


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
>>
>>
>>
>
> 


Relevant Pages

  • Re: DateTime WebService Discrepancy.
    ... When the datetime is sent by the webservice, ... > Ofcourse I had not even though of just passing a string as a parameter ... > locally and cut out the call to the web service. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: text gets destroyed
    ... >> It seems like "\r" is cleared from the string when you sent it to a web ... >> In the call to my webservice i changed field3 to the following: ... Tried to do the messagebox trick just before calling the webservice. ... What does your web service look like? ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: How do I create an object?
    ... terrible if I did this with each call to the web service, but in practice, I ... > the end of the URL and it will return the valid schema for the webservice. ... It has a method such as SetInfo(int age, string ... >> could loop through the parameters collection and learn their names. ...
    (microsoft.public.dotnet.framework)
  • Re: error with web service
    ... before passing to Web Service and in the Web Service convert the data back ... > Before passing, the string looks like: ... > a webservice to be saved in the database. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: WSE 3.0, usernameOverTransportSecurity, custom Token Manager w/ securityTokenManager,
    ... I've added the web service call directly to my Data binding method ... expected but not present in the security header of the incoming ... the username token to the message. ... protected override string AuthenticateToken(UsernameToken token) ...
    (microsoft.public.dotnet.framework.webservices.enhancements)