Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2005

Tip: Looking for answers? Try searching our database.

Dynamic Proxyless Web Service Access?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
localhost - 02 Aug 2004 21:20 GMT
Looking for a simple concise C# sample that will communicate with a
web service without needing WSDL.EXE or VS.NET "create web reference"
functionality.

Basically I am looking for some code that will at runtime discover
what a web service has to offer, kind of like using Reflection to
inspect a local .NET dll.

Thanks.
Jeffrey Hasan - 02 Aug 2004 23:22 GMT
You can do this in theory, as long as the Web service is installed on the
same domain, but where is the usefulness of this approach? Assuming that you
did discover the assembly attributes, what then? You will still need to
generate SOAP requests to interact with it, and you will have to do this
manually if you haven't generated a proxy class. And if the Web service is
installed on a remote server, then you cannot use reflection to discover it.
Perhaps I am missing the point of your request, so please clarify if I have.

Jeffrey Hasan, MCSD
President, Bluestone Partners, Inc.
-----------------------------------------------
Author of: Expert SOA in C# Using WSE 2.0 (APress, 2004)
http://www.bluestonepartners.com/soa.aspx

> Looking for a simple concise C# sample that will communicate with a
> web service without needing WSDL.EXE or VS.NET "create web reference"
[quoted text clipped - 5 lines]
>
> Thanks.
localhost - 06 Aug 2004 18:42 GMT
I am file with doing manual work up-front to create a dynamic proxy or
whatever.  

I have a development web server that talks to a development web
service with development DB, and an anlogous production environment.  

Right now, the dev web server has a VS.NET "add web reference" that
points to the dev web service.  When development is complete, I can't
just push (xcopy deployment) the files to the production web server
because the web reference will still point to the development server.

So still without knowing precisely what to ask for, I am looking for a
way for the web client to call "any" web service without hardcoding in
Visual Studio, or a config/script-based way to modify what web service
is used at runtime.

Thanks.

>You can do this in theory, as long as the Web service is installed on the
>same domain, but where is the usefulness of this approach? Assuming that you
[quoted text clipped - 19 lines]
>>
>> Thanks.
Scott G. - 06 Aug 2004 20:46 GMT
You can change the change the location of the host with some code on top of the web service calls to do this dynamically (change the Url property of the SoapHttpClientProtocol subclass that represents your proxy). So, off the top of my head:

YourNamespace.FoobarSoap s = new YourNamespace.FoobarSoap();
s.Url = s.Url.Replace("://localhost", "://" + yourNewHostName);

You can also, play around with the rest of the Url if you want.

Take a look at the code Reference.cs (.NET 1.1 that is generated and contains the proxy code).

I wrap all of my webservice client calls in static method that allows me to do this kind of thing, plus setup any authentication that I need (and other stuff like logging, etc...).

Scott

 I am file with doing manual work up-front to create a dynamic proxy or
 whatever.  

 I have a development web server that talks to a development web
 service with development DB, and an anlogous production environment.  

 Right now, the dev web server has a VS.NET "add web reference" that
 points to the dev web service.  When development is complete, I can't
 just push (xcopy deployment) the files to the production web server
 because the web reference will still point to the development server.

 So still without knowing precisely what to ask for, I am looking for a
 way for the web client to call "any" web service without hardcoding in
 Visual Studio, or a config/script-based way to modify what web service
 is used at runtime.

 Thanks.

 On Mon, 2 Aug 2004 15:22:47 -0700, "Jeffrey Hasan" <jeff@noreply.com>
 wrote:

 >You can do this in theory, as long as the Web service is installed on the
 >same domain, but where is the usefulness of this approach? Assuming that you
 >did discover the assembly attributes, what then? You will still need to
 >generate SOAP requests to interact with it, and you will have to do this
 >manually if you haven't generated a proxy class. And if the Web service is
 >installed on a remote server, then you cannot use reflection to discover it.
 >Perhaps I am missing the point of your request, so please clarify if I have.
 >
 >Jeffrey Hasan, MCSD
 >President, Bluestone Partners, Inc.
 >-----------------------------------------------
 >Author of: Expert SOA in C# Using WSE 2.0 (APress, 2004)
 >http://www.bluestonepartners.com/soa.aspx
 >
 >"localhost" <primpilus@cohort.ces> wrote in message
 >news:3d8tg09f7u50npqoftctiv5no196c83opt@4ax.com...
 >>
 >> Looking for a simple concise C# sample that will communicate with a
 >> web service without needing WSDL.EXE or VS.NET "create web reference"
 >> functionality.
 >>
 >> Basically I am looking for some code that will at runtime discover
 >> what a web service has to offer, kind of like using Reflection to
 >> inspect a local .NET dll.
 >>
 >> Thanks.
Jonathan Eggert - 17 Mar 2005 20:30 GMT
I have the same situation. I think what 'localhost' means is to do a proxy
call at runtime. If you are changing the web service, then you need to
change any proxy created using Add Web Reference or wsdl.exe (they both do
the same thing). By building a proxy on-the-fly, you can avoid some of this
maintenance.

In my case, I need to generate a proxy dynamically , for which I have been
using the ServiceDescriptionImporter class. With this you can generate a
proxy by providing the web service's WSDL, example:
http://host/webservice.asmx?WSDL. The problem I've run into is that I can't
seem to get ServiceDescriptionImporter to generate anything other than SOAP
a proxy. There are a lot of people who prefer to use POST rather than SOAP
(their decision). There is a property:
ServiceDescriptionImporter.ProtocolName, that supposedly allows you to
specify which proxy but I can't seem to make it fly for anything other than
SOAP. Has anyone else had experience with this class?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.