If I use Visual Studio.Net 2003 to generate "web references" for clients
using either sproxy.exe (for C++) client or wsdl.exe (for C#) clients, the
web service endpoint gets "baked" into the generated code, making it
difficult, if not impossible, to change the server that the client connects
to at runtime.
e.g. sproxy.exe generated code that looks like this ...
static const _soapmap __CCluProvider_GetCertificate_atlsoapheader_map =
{
0xF0E178D2,
"GetCertificate",
L"GetCertificateResponse",
sizeof("GetCertificate")-1,
sizeof("GetCertificateResponse")-1,
SOAPMAP_HEADER,
__CCluProvider_GetCertificate_atlsoapheader_entrie s,
0,
0,
-1,
SOAPFLAG_NONE | SOAPFLAG_PID | SOAPFLAG_DOCUMENT | SOAPFLAG_LITERAL,
0x2C42131A,
"http://localhost/CluServer/",
L"http://localhost/CluServer/",
sizeof("http://localhost/CluServer/")-1
};
and wsdl.exe generate code like this ...
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="CluProviderSoap",
Namespace="http://localhost/CluServer/")]
public class CluProvider :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
/// <remarks/>
public CluProvider() {
this.Url = "http://localhost/CluServer/CluProvider.asmx";
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost
/CluServer/CanConnect", RequestNamespace="http://localhost/CluServer/",
ResponseNamespace="http://localhost/CluServer/",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
public bool CanConnect() {
object[] results = this.Invoke("CanConnect", new object[0]);
return ((bool)(results[0]));
}
Is there an elegent, idiomatic technique for changing the server endpoint at
runtime with these "generated" proxies or is it necessary to 'hand craft'
your own proxy code if you want to change the server at runtime?
Changing the server endpoint at runtime seems like a reasonable thing to
want to do, or have I missed something?
Andy 3 10544
You can either set the type to dynamic in the web reference in VS.Net, or
you can use the publicly accessible "Url" property on the generated class to
change the url at runtime prior to executing web methods on it.
I.E:
MyClientClass o = new MyClientClass();
o.Url = "http://MyServer/MyWebService.asmx";
o.MyWebMethod();
"Andy" <ar******@hotmail.com> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl... If I use Visual Studio.Net 2003 to generate "web references" for clients using either sproxy.exe (for C++) client or wsdl.exe (for C#) clients, the web service endpoint gets "baked" into the generated code, making it difficult, if not impossible, to change the server that the client connects to at runtime.
e.g. sproxy.exe generated code that looks like this ...
static const _soapmap __CCluProvider_GetCertificate_atlsoapheader_map = { 0xF0E178D2, "GetCertificate", L"GetCertificateResponse", sizeof("GetCertificate")-1, sizeof("GetCertificateResponse")-1, SOAPMAP_HEADER, __CCluProvider_GetCertificate_atlsoapheader_entrie s, 0, 0, -1, SOAPFLAG_NONE | SOAPFLAG_PID | SOAPFLAG_DOCUMENT | SOAPFLAG_LITERAL, 0x2C42131A, "http://localhost/CluServer/", L"http://localhost/CluServer/", sizeof("http://localhost/CluServer/")-1 };
and wsdl.exe generate code like this ...
/// <remarks/> [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("c ode")] [System.Web.Services.WebServiceBindingAttribute(Nam e="CluProviderSoap", Namespace="http://localhost/CluServer/")] public class CluProvider : System.Web.Services.Protocols.SoapHttpClientProtoc ol {
/// <remarks/> public CluProvider() { this.Url = "http://localhost/CluServer/CluProvider.asmx"; }
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost /CluServer/CanConnect", RequestNamespace="http://localhost/CluServer/", ResponseNamespace="http://localhost/CluServer/", Use=System.Web.Services.Description.SoapBindingUse .Literal, ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)] public bool CanConnect() { object[] results = this.Invoke("CanConnect", new object[0]); return ((bool)(results[0])); }
Is there an elegent, idiomatic technique for changing the server endpoint at runtime with these "generated" proxies or is it necessary to 'hand craft' your own proxy code if you want to change the server at runtime?
Changing the server endpoint at runtime seems like a reasonable thing to want to do, or have I missed something?
Andy
> You can either set the type to dynamic in the web reference in VS.Net, or
I will try that and see what the generated code looks like. you can use the publicly accessible "Url" property on the generated class
to
Hmmm. Does that really work?
I thought about that but when I saw all of the string literals 'baked in' to
the proxy code I thought it would be unlikely to work.
Andy
"Nathan Craddock" <na*************@xtoenergy.com> wrote in message
news:OL**************@TK2MSFTNGP15.phx.gbl... You can either set the type to dynamic in the web reference in VS.Net, or you can use the publicly accessible "Url" property on the generated class
to change the url at runtime prior to executing web methods on it.
I.E:
MyClientClass o = new MyClientClass(); o.Url = "http://MyServer/MyWebService.asmx"; o.MyWebMethod(); "Andy" <ar******@hotmail.com> wrote in message news:eC**************@TK2MSFTNGP12.phx.gbl... If I use Visual Studio.Net 2003 to generate "web references" for clients using either sproxy.exe (for C++) client or wsdl.exe (for C#) clients,
the web service endpoint gets "baked" into the generated code, making it difficult, if not impossible, to change the server that the client connects to at runtime.
e.g. sproxy.exe generated code that looks like this ...
static const _soapmap __CCluProvider_GetCertificate_atlsoapheader_map = { 0xF0E178D2, "GetCertificate", L"GetCertificateResponse", sizeof("GetCertificate")-1, sizeof("GetCertificateResponse")-1, SOAPMAP_HEADER, __CCluProvider_GetCertificate_atlsoapheader_entrie s, 0, 0, -1, SOAPFLAG_NONE | SOAPFLAG_PID | SOAPFLAG_DOCUMENT | SOAPFLAG_LITERAL, 0x2C42131A, "http://localhost/CluServer/", L"http://localhost/CluServer/", sizeof("http://localhost/CluServer/")-1 };
and wsdl.exe generate code like this ...
/// <remarks/> [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="CluProviderSoap", Namespace="http://localhost/CluServer/")] public class CluProvider : System.Web.Services.Protocols.SoapHttpClientProtoc ol {
/// <remarks/> public CluProvider() { this.Url = "http://localhost/CluServer/CluProvider.asmx"; }
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost /CluServer/CanConnect", RequestNamespace="http://localhost/CluServer/", ResponseNamespace="http://localhost/CluServer/", Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)] public bool CanConnect() { object[] results = this.Invoke("CanConnect", new object[0]); return ((bool)(results[0])); }
Is there an elegent, idiomatic technique for changing the server
endpoint at runtime with these "generated" proxies or is it necessary to 'hand
craft' your own proxy code if you want to change the server at runtime?
Changing the server endpoint at runtime seems like a reasonable thing to want to do, or have I missed something?
Andy
The VS.Net web reference thing is pretty much just a placeholder for
settings so it can run WSDL when you do "Update Web Reference".
Also, if you notice in the generated class for C#, the literals in the
constructor are actually being applied to "this.Url" which is the same
publicly accessible property I was suggesting you set. Setting that Url
property immediately after instantiating the object is pretty standard, I
think. It's how I've always done it, and it's never given me any problems.
"Andy" <ar******@hotmail.com> wrote in message
news:Oo**************@TK2MSFTNGP14.phx.gbl... You can either set the type to dynamic in the web reference in VS.Net, or
I will try that and see what the generated code looks like.
you can use the publicly accessible "Url" property on the generated class to
Hmmm. Does that really work? I thought about that but when I saw all of the string literals 'baked in' to the proxy code I thought it would be unlikely to work.
Andy
"Nathan Craddock" <na*************@xtoenergy.com> wrote in message news:OL**************@TK2MSFTNGP15.phx.gbl... You can either set the type to dynamic in the web reference in VS.Net, or you can use the publicly accessible "Url" property on the generated class to change the url at runtime prior to executing web methods on it.
I.E:
MyClientClass o = new MyClientClass(); o.Url = "http://MyServer/MyWebService.asmx"; o.MyWebMethod(); "Andy" <ar******@hotmail.com> wrote in message news:eC**************@TK2MSFTNGP12.phx.gbl... > If I use Visual Studio.Net 2003 to generate "web references" for > clients > using either sproxy.exe (for C++) client or wsdl.exe (for C#) clients, the > web service endpoint gets "baked" into the generated code, making it > difficult, if not impossible, to change the server that the client > connects > to at runtime. > > e.g. sproxy.exe generated code that looks like this ... > > static const _soapmap __CCluProvider_GetCertificate_atlsoapheader_map = > { > 0xF0E178D2, > "GetCertificate", > L"GetCertificateResponse", > sizeof("GetCertificate")-1, > sizeof("GetCertificateResponse")-1, > SOAPMAP_HEADER, > __CCluProvider_GetCertificate_atlsoapheader_entrie s, > 0, > 0, > -1, > SOAPFLAG_NONE | SOAPFLAG_PID | SOAPFLAG_DOCUMENT | SOAPFLAG_LITERAL, > 0x2C42131A, > "http://localhost/CluServer/", > L"http://localhost/CluServer/", > sizeof("http://localhost/CluServer/")-1 > }; > > and wsdl.exe generate code like this ... > > /// <remarks/> > [System.Diagnostics.DebuggerStepThroughAttribute()] > [System.ComponentModel.DesignerCategoryAttribute("c ode")] > [System.Web.Services.WebServiceBindingAttribute(Nam e="CluProviderSoap", > Namespace="http://localhost/CluServer/")] > public class CluProvider : > System.Web.Services.Protocols.SoapHttpClientProtoc ol { > > /// <remarks/> > public CluProvider() { > this.Url = "http://localhost/CluServer/CluProvider.asmx"; > } > > /// <remarks/> > > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost > /CluServer/CanConnect", RequestNamespace="http://localhost/CluServer/", > ResponseNamespace="http://localhost/CluServer/", > Use=System.Web.Services.Description.SoapBindingUse .Literal, > ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)] > public bool CanConnect() { > object[] results = this.Invoke("CanConnect", new object[0]); > return ((bool)(results[0])); > } > > > Is there an elegent, idiomatic technique for changing the server endpoint > at > runtime with these "generated" proxies or is it necessary to 'hand craft' > your own proxy code if you want to change the server at runtime? > > Changing the server endpoint at runtime seems like a reasonable thing > to > want to do, or have I missed something? > > Andy > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: andreas.w.h.k. :-\) |
last post by:
How do I change the address location in the wsdl
<wsdl:port name="SearchSoap12" binding="tns:SearchSoap12">
<soap12:address location="http://searchservices/engine/search.asmx" />
</wsdl:port>
...
|
by: ArkJ |
last post by:
Hello.
I have a little problem. I created a little Service which uses SIP, all works rather well, but when I want to shut it down in the Services panel, it looks as if it's shut down, but in fact...
|
by: Karch |
last post by:
I am writing a WCF Service using MSMQ hosted in a Windows Service on Windows
XP. All the required components are installed (.NET3, MSMQ, etc).
For some reason my service tries to start and then...
|
by: =?Utf-8?B?QWRyaWFuIENvbGU=?= |
last post by:
I have written a simple WCF service hosted in a Windows console application
and a simple WCF client console application that connects successfully to
that service and retrieves data. I then ported...
|
by: =?Utf-8?B?R3JlZw==?= |
last post by:
I have just created a WCF service that is using WShttpbasic and all is good
when another .net 3.0 application consumes it. However, I have legacy apps
that must use this service and are running on...
|
by: Dylan |
last post by:
Hello,
I was trying to do a WCF tutorial (http://wcf.netfx3.com/content/
BuildingHelloWorld.aspx). I need to get the meta data from my service
usin svcutil.exe why is not working? Please see...
|
by: =?Utf-8?B?QW5keSBZdQ==?= |
last post by:
Hi,
I'm trying to return exceptions from a WCF Service using FaultExceptions. I
got the service compiled and running. But I get an error while adding a
service reference to it. The error reads:
"...
|
by: =?Utf-8?B?RGFuaWVs?= |
last post by:
Hi,
How could I change a WCF client endpoint address programatically? The client
is generated by Visual Studio. The purpose of doing this is to use different
service address under different...
|
by: Andrew Jocelyn |
last post by:
Hi
How do I programmatically change (read/write) the values in this app.config
file at runtime? Specifically I want to change the client endpoint address
but it would be nice to change other...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |