1,105,578 Community Members

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

Member Avatar
maac2002
Newbie Poster
2 posts since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
mcriscolo
Posting Whiz in Training
219 posts since Apr 2008
Reputation Points: 47 [?]
Q&As Helped to Solve: 64 [?]
Skill Endorsements: 0 [?]
 
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.

Question Answered as of 3 Years Ago by mcriscolo
Member Avatar
maac2002
Newbie Poster
2 posts since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Thanks very much, it worked!

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: