We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,301 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to: Consuming webservice in console application (C#)

Hi,
I'm novice by complete to webservices et al.
I've created successfully a webservice and referenced it
in a console application. By simplification let assume that
the webservice contains a webmethod, the 'classic'
CelsiusToFarenheit (string Celsius).
Once referenced i can see my new namespace
ServiceReference1 with the following classes inside:

CelsiusToFahrenheitRequest
CelsiusToFahrenheitRequestBody (it contains the property Celsius)
CelsiusToFahrenheitResponse
CelsiusToFahrenheitResponseBody (it contains the property CelsiusToFahrenheitResult)
Service1SoapClient (with 5 overloads at the instantiation).

and 2 interfaces:
IService1Soap
IService1SoapChannel

I've intantiated the first 4 classes and toying with it to no avail.
How can i obtain :

string Fahreheit = ......

Thanks

2
Contributors
2
Replies
2 Days
Discussion Span
2 Years Ago
Last Updated
3
Views
Question
Answered
maac2002
Newbie Poster
2 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Just make a new instance of the "Service1SoapClient", like this:

Service1SoapClient myWS = new Service1SoapClient();

Then, you should see your methods on the "myWS" variable:

string sResult = myWS.CelsiusToFahrenheit("25");

You may have to include the namespace, if you did not put it in the "using" section:

ServiceReference1.Service1SoapClient myWS = new ServiceReference1.Service1SoapClient();

However, after you have instantiated the class, you can call the methods on it.

mcriscolo
Posting Whiz in Training
219 posts since Apr 2008
Reputation Points: 57
Solved Threads: 64
Skill Endorsements: 0
Question Answered as of 2 Years Ago by mcriscolo

Just make a new instance of the "Service1SoapClient", like this:

Service1SoapClient myWS = new Service1SoapClient();

Then, you should see your methods on the "myWS" variable:

string sResult = myWS.CelsiusToFahrenheit("25");

You may have to include the namespace, if you did not put it in the "using" section:

ServiceReference1.Service1SoapClient myWS = new ServiceReference1.Service1SoapClient();

However, after you have instantiated the class, you can call the methods on it.

Thanks very much, it worked!

maac2002
Newbie Poster
2 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0655 seconds using 2.66MB