By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Help with dynamically consuming a web service

P: n/a
Hello

If someone can help me with this it would be greatly appreciated. I’m no web
service expert but I don't think i'm trying to do anything too special. I
think i must be missing something simple because i have been banging my head
against a wall with this for a while now.

I have created a web service and a client Win forms application to consume
the web service. The problem is i don't know where the web service will be
deployed so i need to be able to configure either programatically or manually
the client application to point to it.

During development i have both client and web service in the same VS 2005
solution. I added a web reference for the web service to the client
application by searching my machine (localhost). I had already set up and
configured the virtual directory for the web service on my machine.

I have carried out all of my development on them and now want to test my
deployment plan. I used the copy web site utility to deploy the web service
to a test server that we have. I set the ULR behaviour of the Web Reference
in the client app to Dynamic and built the client application. I copied the
client application to a test client machine, changed the ULR in the settings
section to point to the web service on the test server and ran the
application. Unfortunately it doesn’t work. I can’t seem to connect to the
web service.

Am I doing something wrong or have missed a step? Do I also need to deploy
the disco and wsdl files with either the client app or web service? Do I need
to make another configuration change elsewhere? Alternatively is there a way
to programmatically control the web service that the client connects to?

The only way I have found that I can fix this problem is by adding a web
reference to the web service on the Test server to my client application and
deploying that client application. This isn’t very dynamic though…..

Any help or pointers would be greatly appreciated.

Thank you

G

Mar 15 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,
Below link provides example as how to invoke web services dynamically
without adding web reference.
http://www.codeproject.com/cs/webser...cesDynamic.asp
Please do let me know if it worked
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"grazza" wrote:
Hello

If someone can help me with this it would be greatly appreciated. I’m no web
service expert but I don't think i'm trying to do anything too special. I
think i must be missing something simple because i have been banging my head
against a wall with this for a while now.

I have created a web service and a client Win forms application to consume
the web service. The problem is i don't know where the web service will be
deployed so i need to be able to configure either programatically or manually
the client application to point to it.

During development i have both client and web service in the same VS 2005
solution. I added a web reference for the web service to the client
application by searching my machine (localhost). I had already set up and
configured the virtual directory for the web service on my machine.

I have carried out all of my development on them and now want to test my
deployment plan. I used the copy web site utility to deploy the web service
to a test server that we have. I set the ULR behaviour of the Web Reference
in the client app to Dynamic and built the client application. I copied the
client application to a test client machine, changed the ULR in the settings
section to point to the web service on the test server and ran the
application. Unfortunately it doesn’t work. I can’t seem to connect to the
web service.

Am I doing something wrong or have missed a step? Do I also need to deploy
the disco and wsdl files with either the client app or web service? Do I need
to make another configuration change elsewhere? Alternatively is there a way
to programmatically control the web service that the client connects to?

The only way I have found that I can fix this problem is by adding a web
reference to the web service on the Test server to my client application and
deploying that client application. This isn’t very dynamic though…..

Any help or pointers would be greatly appreciated.

Thank you

G
Mar 15 '07 #2

P: n/a
Hi Manish

Yes thank you for your reply I found it very useful and have adapted my code
to set the URL to the web reference programmatically as in the example on the
link. This is better for me than using the config file setting from a
deployment point of view because I can now control the URL from a database
parameter.

Prior to your reply I did actually find that my problem was that the
assembly of mine which referenced the web service was a class library.
Although Visual Studio automatically creates a config file for it, the .Net
runtime doesn’t actually use it at runtime because it's a class library,
arrrggggghhhh!! I didn't know this, why would it create the file if it
doesn’t use it at runtime – bit confusing. To get this way to work I think I
may need to put some of the config settings from the myclass.dll.config into
the myapp.exe.config file for the exe that calls my class library. I'm going
to use the programmatic solution you supplied in the code project link but do
you know what setting(s) I would need to put into the myapp.exe.config file
to get it to work this way? Please could you give me a sample?

Thank you very much for your reply. It's saved me a fair bit of hassle.

Cheers

G

Mar 15 '07 #3

P: n/a
Hi,
I think this is what you are looking for:

service1 = new YourWebService();
service1.Url = ConfigurationSettings.AppSettings["YourWebServiceUrl"];
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"grazza" wrote:
Hello

If someone can help me with this it would be greatly appreciated. I’m no web
service expert but I don't think i'm trying to do anything too special. I
think i must be missing something simple because i have been banging my head
against a wall with this for a while now.

I have created a web service and a client Win forms application to consume
the web service. The problem is i don't know where the web service will be
deployed so i need to be able to configure either programatically or manually
the client application to point to it.

During development i have both client and web service in the same VS 2005
solution. I added a web reference for the web service to the client
application by searching my machine (localhost). I had already set up and
configured the virtual directory for the web service on my machine.

I have carried out all of my development on them and now want to test my
deployment plan. I used the copy web site utility to deploy the web service
to a test server that we have. I set the ULR behaviour of the Web Reference
in the client app to Dynamic and built the client application. I copied the
client application to a test client machine, changed the ULR in the settings
section to point to the web service on the test server and ran the
application. Unfortunately it doesn’t work. I can’t seem to connect to the
web service.

Am I doing something wrong or have missed a step? Do I also need to deploy
the disco and wsdl files with either the client app or web service? Do I need
to make another configuration change elsewhere? Alternatively is there a way
to programmatically control the web service that the client connects to?

The only way I have found that I can fix this problem is by adding a web
reference to the web service on the Test server to my client application and
deploying that client application. This isn’t very dynamic though…..

Any help or pointers would be greatly appreciated.

Thank you

G
Mar 15 '07 #4

P: n/a
Hi Manish

That's for you reply. My concern was that i'm using WSE 3.0 MTOM to
communicate with the web service and need to switch the client mode to "On"
in the config file as well as setting Time Outs and message sizes. I was
worried that since these settings go into the class library's config file
(since it's the class library that references the web service) they wouldn't
be read by the .Net runtime at runtime and i wouldn't be able to communicate
using WSE 3.0.

I have however found that i can copy these settings into the config file for
the exe that calls the class library and it somehow works. So no problem. I
couldn't though get it to work by copying the ULR for the web service into
the exe's app.cpnfig file.

Hope that all makes sense.

Thanks a lot for you responses it is really appreciated.

Thank you

Graham
Cheers

G
"Manish Bafna" wrote:
Hi,
I think this is what you are looking for:

service1 = new YourWebService();
service1.Url = ConfigurationSettings.AppSettings["YourWebServiceUrl"];
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"grazza" wrote:
Hello

If someone can help me with this it would be greatly appreciated. I’m no web
service expert but I don't think i'm trying to do anything too special. I
think i must be missing something simple because i have been banging my head
against a wall with this for a while now.

I have created a web service and a client Win forms application to consume
the web service. The problem is i don't know where the web service will be
deployed so i need to be able to configure either programatically or manually
the client application to point to it.

During development i have both client and web service in the same VS 2005
solution. I added a web reference for the web service to the client
application by searching my machine (localhost). I had already set up and
configured the virtual directory for the web service on my machine.

I have carried out all of my development on them and now want to test my
deployment plan. I used the copy web site utility to deploy the web service
to a test server that we have. I set the ULR behaviour of the Web Reference
in the client app to Dynamic and built the client application. I copied the
client application to a test client machine, changed the ULR in the settings
section to point to the web service on the test server and ran the
application. Unfortunately it doesn’t work. I can’t seem to connect to the
web service.

Am I doing something wrong or have missed a step? Do I also need to deploy
the disco and wsdl files with either the client app or web service? Do I need
to make another configuration change elsewhere? Alternatively is there a way
to programmatically control the web service that the client connects to?

The only way I have found that I can fix this problem is by adding a web
reference to the web service on the Test server to my client application and
deploying that client application. This isn’t very dynamic though…..

Any help or pointers would be greatly appreciated.

Thank you

G
Mar 15 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.