Click to See Complete Forum and Search --> : Web Services C# Windows Forms


psdeveloper
March 12th, 2010, 10:54 PM
I am trying to use a web service to populate a label from two Currencies .
I right click and added the web reference to the project.

Here is the link the the service...

http://www.webservicex.net/WS/WSDetails.aspx?WSID=10

Here is the Link the the WSDL...

http://www.webservicex.net/CurrencyConvertor.asmx?WSDL

I know that this service support the following method:

"ConversionRate"

i try this but im sure this is not right..

ServiceReference1.ConversionRateRequest CMyClass = new WebService.ServiceReference1.ConversionRateRequest("USD", "PHP");

What do i need to do?

sotoasty
March 13th, 2010, 10:05 AM
I didn't try as as WCF service but as a Web Service. When you add the service reference, go to the advanced tab and add as a web service. Then I used the following code in a windows form (where "CurrenctConverter" was the name of the service I added).


private void button1_Click(object sender, EventArgs e)
{
CurrencyConverter.CurrencyConvertor aa = new Test.CurrencyConverter.CurrencyConvertor();
CurrencyConverter.Currency USA = CurrencyConverter.Currency.USD;
CurrencyConverter.Currency BPS = CurrencyConverter.Currency.GBP;
double ExchangeRate = aa.ConversionRate(USA, BPS);
MessageBox.Show(ExchangeRate.ToString());
}

Arjay
March 13th, 2010, 12:43 PM
In VS 2008, you need to add a "Web reference" instead of a "Service reference".

Right click on the References node in solution explorer and choose "Add Web reference". If you don't see this item, then choose "Add Service Reference". Once the service ref form opens, click on the "Advanced" button and choose "Add Web reference" near the bottom of the form.