[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 782
  • Last Modified:

Access web service through code without Visual Studio project

Hi, I need to be able to access a web service through code in C#. I am unable to use the Visual Studio wizard to reference the web service with the third party app that I'm using. Can anyone tell me how to do so directly in C#. I am given the address to the asmx file but I don't know what to do from there.
0
dynamk
Asked:
dynamk
  • 2
  • 2
1 Solution
 
wht1986Commented:
You can use disco.exe to create a WSDL file
http://msdn.microsoft.com/en-us/library/cy2a3ybs(VS.80).aspx

and then use WSDL.exe to create the classes for your code
http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx
0
 
dynamkAuthor Commented:
These articles are very good. For someone who is not very experienced can an example be provided as to how to programmatically access a web service through code?
0
 
wht1986Commented:
using the web service http://www.webservicex.net/CurrencyConvertor.asmx as an example

1) I opened up the command prompt via VS 2008 tools
2) I created a directory on my system "C:\disco"
3) I ran the discovery command

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>disco /o:c:\disco http://www.webservicex.net/CurrencyConvertor.asmx

4)  I then ran the wsdl compiler

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>wsdl.exe /l:CS /o:C:\DISCO c:\disco\CurrencyConvertor.wsdl

5) I now have a file ('C:\DISCO\CurrencyConvertor.cs) that I can include in my project

6) After adding to my project I create a service proxy and issue a command, using that web service I am asking for a conversion rate between US dollars and the British pound

        CurrencyConvertor c = new CurrencyConvertor();
        double cnv = c.ConversionRate(Currency.USD, Currency.GBP);
0
 
dynamkAuthor Commented:
Thanks
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now