Skip to content

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

Miguel Castanuela

Asked Feb 11, 2011, 12:42 PM EST2 answers
Share
LinkedInX
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 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    I think you are missing the namespace import. Sometimes namespace and webservice name can be duplicate if you use default project templates.
    Try defining your namespace and then see what classes are available.
    Create an instance of the class and see what members are available.
     
    0
  • 0
    Thanks,
    i've checked and all respect to namespace is correct,
    the classes are the same as my original post, in fact
    i deleted the referenced service, re-add the same
    but changing the namespace, and the result is the
    same, i mean, i see all pertinent classes, the problem
    is how to code to obtain the value of Fahrhenheit.
    0