webserivce reference without default url

H

Hans

Hi

I add a webreference to a webservice. I set the URL Behavior to dynamic and set the url with the web.config
It works well

I check the reference.cs and there I have a default URL pointing to the URL I used to bind the webservice

Does anyone now how to have dynamic webreferences and avoiding the default url

Thanks in advance

/Hans
 
J

Jan Tielens

This is possible, but it involves some manual work. You must save the
generated wsdl file into a file on your hard disk. Then you have to edit the
xml: remove the <service> tag and it's contents. So far the wsdl, in your
VS.NET when you choose Add Web Reference, choose the altered wsdl file on
your harddisk instead of navigating to your webservice. Now the generated
proxy clients won't have the default url filled out.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Hans said:
Hi,

I add a webreference to a webservice. I set the URL Behavior to dynamic
and set the url with the web.config.
It works well.

I check the reference.cs and there I have a default URL pointing to the
URL I used to bind the webservice.
 
J

Jan Tielens

You can use the URLBehavior property of the Web Reference: set this to
dynamic so the setting is stored in the app.config file. You can change this
file without having to rebuild the complete solution.

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
Hans said:
Thanks Jan.

I will try that.

But its strange. There are lots of webservices out there.
Does all the developers build a extra time before production deployment,
just to bind to the production enviroment instead of the develop enviroment,
or do they do the manual thing, or pehaps they dont care?
Because if the configuration setting fails you dont want to set the
connection string to the production test.
 
H

Hans

Thanks Jan,

Sorry i might have expressed my self poorly...

I use the dynamic binding and set this in the web.config.
It works well.
But if i some how lose the url in the web.config I dont want the app reference the default url.

This is because last time I did build the app was for a production test enviroment and then it will move
to the production enviroment.
What if the people that does the move do not handle the web.config in correct way och destory det binding information.

If there are no binding information the webservice will go to the default url.
But this url is the production test with data that are bad and it is harder to detect this problem...

That way I wonder how everybody else does this. There must be a simple solution.

Or else I can naturaly fall back to you solution to remove the section part in wsdl.
But what if to edit the reference.cs or reference.map?

/Hans
 
J

Jan Tielens

You could check in code, when your application starts, if the key exists in
the app.config file. If not you can show a message telling the user his
configuration is screwed. :)

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Hans said:
Thanks Jan,

Sorry i might have expressed my self poorly...

I use the dynamic binding and set this in the web.config.
It works well.
But if i some how lose the url in the web.config I dont want the app reference the default url.

This is because last time I did build the app was for a production test
enviroment and then it will move
to the production enviroment.
What if the people that does the move do not handle the web.config in
correct way och destory det binding information.
If there are no binding information the webservice will go to the default url.
But this url is the production test with data that are bad and it is
harder to detect this problem...
 
H

Hans

Thanks for your reply.

Of course I can do that.

I was just thinking since there are quite a lot webservices out there and many of them most have the same problem...

I'm probobly driving at: The .NET enviroment is missing someting her. It can be done, - but with a little manual work.
Why not a settning when creating the webservice proxy...


But what happend to the question about edit the reference.cs or reference.map compare to the wsdl file. Do you know?

/Hans
 
J

Jan Tielens

But what happend to the question about edit the reference.cs or
reference.map compare to the wsdl file. Do you know?

Can you explain a little bit more... I don't understand your question.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Hans said:
Thanks for your reply.

Of course I can do that.

I was just thinking since there are quite a lot webservices out there and
many of them most have the same problem...
I'm probobly driving at: The .NET enviroment is missing someting her. It
can be done, - but with a little manual work.
Why not a settning when creating the webservice proxy...


But what happend to the question about edit the reference.cs or
reference.map compare to the wsdl file. Do you know?
 
H

Hans

Sorr

If i open the reference.cs the default URL is hard coded in there
I was just thinking about removing that line or set it to blank., to solve my first question about the default url
Because your solution about the wsdl incorporated a lot of manual work.

Such as save the wsdl fil
remove the service sectio
change the binding name so it doesn't ends with Soa
go to the wsdl file insted
Reading the connection url from web.confi
set the url for the webservic

I was thinking: Way not just make the change in reference.cs?
Then I saw that in the reference.map there was a lot of references to
Can they be removed

And one more question
If i have a DISCO file, The one that is generated when creating the proxy
Whay not always use the discover method insted of setting the Url Behavior
The only change the disoc file instead of web.config ...

/Hans
 
J

Jan Tielens

I was thinking: Way not just make the change in reference.cs??
Then I saw that in the reference.map there was a lot of references to.
Can they be removed?

The references are used when you choose "Update Web Reference", if you
remove the references, you won't be able to update the web reference.

Probably you know this, but it's possible to generate proxy classes using
the WSDL too (command line tool). By doing so, you won't have the
Reference.map and stuff like that in VS.NET, only the class for the
generated method.
And one more question.
If i have a DISCO file, The one that is generated when creating the proxy.
Whay not always use the discover method insted of setting the Url Behavior.
The only change the disoc file instead of web.config ...
I pass on this one... Dino? :)

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Hans said:
Sorry

If i open the reference.cs the default URL is hard coded in there.
I was just thinking about removing that line or set it to blank., to solve
my first question about the default url.
 
H

Hans

The references are used when you choose "Update Web Reference", if yo
remove the references, you won't be able to update the web reference

I have webservice that returns a typed dataset. If I change the dataset for some reason I find that a update doesent do the job. I have to remove the reference and then add it again
And the webservice is still under development. (The client to
I know that interfaces must be decided early and then not be changed :). But sometimes I do must change the interface
That way I was looking for an way round my original problem that does not include to much work

Anyway thanks alot for your help!!

/Han
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top