473,480 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Example calling an external webservice

I am trying to study ASP.NET by making some example programmes in Visual Web
Developper 2005 Express Edition.

I am trying to write a client that consumes a simple webservice like:

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

I've added the webservice to my project, but how do I proceed? I have found
several examples but nothing clear what I really want. For example I have
found the below but that's with localhost. I do not have the webservice on
local host. Nor do I understand where localhost should be defined anyway.

protected void ConvertButton_Click(object sender, EventArgs e)
{
localhost.Convert wsConvert = new localhost.Convert();
double temperature =
System.Convert.ToDouble(TemperatureTextbox.Text);
FahrenheitLabel.Text = "Fahrenheit To Celsius = " +
wsConvert.FahrenheitToCelsius(temperature).ToStrin g();
CelsiusLabel.Text = "Celsius To Fahrenheit = " +
wsConvert.CelsiusToFahrenheit(temperature).ToStrin g();
}

Please give me some hints!

Marc Wentink

Nov 5 '08 #1
10 8079
Try this walkthrough:
http://msdn.microsoft.com/en-us/libr...54(VS.71).aspx

You will have to set up the service to do it. Once you understand that, you
can create other services or connect to the one you want to consume. I could
show you with the service you have pointed out, but it is extremely slow.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"Marc" <no*****@chello.nlwrote in message
news:ef****************@TK2MSFTNGP05.phx.gbl...
>I am trying to study ASP.NET by making some example programmes in Visual
Web Developper 2005 Express Edition.

I am trying to write a client that consumes a simple webservice like:

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

I've added the webservice to my project, but how do I proceed? I have
found several examples but nothing clear what I really want. For example I
have found the below but that's with localhost. I do not have the
webservice on local host. Nor do I understand where localhost should be
defined anyway.

protected void ConvertButton_Click(object sender, EventArgs e)
{
localhost.Convert wsConvert = new localhost.Convert();
double temperature =
System.Convert.ToDouble(TemperatureTextbox.Text);
FahrenheitLabel.Text = "Fahrenheit To Celsius = " +
wsConvert.FahrenheitToCelsius(temperature).ToStrin g();
CelsiusLabel.Text = "Celsius To Fahrenheit = " +
wsConvert.CelsiusToFahrenheit(temperature).ToStrin g();
}

Please give me some hints!

Marc Wentink
Nov 5 '08 #2
I think you are not looking for the Client. Here is an example I have not
tested, but it has the basic methodology wrapped in a class.

Service = http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl

Class =

using ServiceConsumptionLibrary.WeatherService;

namespace ServiceConsumptionLibrary
{
public class ServiceConsumer
{
public static WeatherService.ForecastReturn
GetForecastForUsPostalCode(string postalCode)
{
var client = new WeatherHttpGetClient();
var forecast = client.GetCityForecastByZIP(postalCode);

return forecast;
}
}
}

I have not tested through this yet (I would create a unit test, personally),
but the basic idea is sound and works like .NET 2.0+ works with all
services. And, yes, it is a bit more complex than 1.x.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:u6**************@TK2MSFTNGP04.phx.gbl...
Try this walkthrough:
http://msdn.microsoft.com/en-us/libr...54(VS.71).aspx

You will have to set up the service to do it. Once you understand that,
you can create other services or connect to the one you want to consume. I
could show you with the service you have pointed out, but it is extremely
slow.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"Marc" <no*****@chello.nlwrote in message
news:ef****************@TK2MSFTNGP05.phx.gbl...
>>I am trying to study ASP.NET by making some example programmes in Visual
Web Developper 2005 Express Edition.

I am trying to write a client that consumes a simple webservice like:

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

I've added the webservice to my project, but how do I proceed? I have
found several examples but nothing clear what I really want. For example
I have found the below but that's with localhost. I do not have the
webservice on local host. Nor do I understand where localhost should be
defined anyway.

protected void ConvertButton_Click(object sender, EventArgs e)
{
localhost.Convert wsConvert = new localhost.Convert();
double temperature =
System.Convert.ToDouble(TemperatureTextbox.Text);
FahrenheitLabel.Text = "Fahrenheit To Celsius = " +
wsConvert.FahrenheitToCelsius(temperature).ToStrin g();
CelsiusLabel.Text = "Celsius To Fahrenheit = " +
wsConvert.CelsiusToFahrenheit(temperature).ToStrin g();
}

Please give me some hints!

Marc Wentink
Nov 5 '08 #3

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMschreef
Ok, now for something silly, and I am sorry this must be a real newbee question, and concurrently I am searching to solve this myself, but:

using ServiceConsumptionLibrary.WeatherService;
Gives

Error 1 The type or namespace name 'WeatherService' does not exist in the namespace 'ServiceConsumptionLibrary' (are you missing an assembly reference?) C:\Documents and Settings\Marc wentink\Mijn documenten\Visual Studio 2005\WebSites\H8Async\App_Code\ServiceConsumer.cs 10 33 C:\...\H8Async\

Now normally I would add a link to an assembly, a dll, with WeatherService in it, but what do I do now? I presume I do not have a dll with WeatherService in it.


Nov 5 '08 #4
Add Web Reference in Solution Explorer
"Marc" <no*****@chello.nlwrote in message news:e2**************@TK2MSFTNGP03.phx.gbl...

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMschreef
Ok, now for something silly, and I am sorry this must be a real newbee question, and concurrently I am searching to solve this myself, but:

using ServiceConsumptionLibrary.WeatherService;
Gives

Error 1 The type or namespace name 'WeatherService' does not exist in the namespace 'ServiceConsumptionLibrary' (are you missing an assembly reference?) C:\Documents and Settings\Marc wentink\Mijn documenten\Visual Studio 2005\WebSites\H8Async\App_Code\ServiceConsumer.cs 10 33 C:\...\H8Async\

Now normally I would add a link to an assembly, a dll, with WeatherService in it, but what do I do now? I presume I do not have a dll with WeatherService in it.


Nov 5 '08 #5

"Jeff Dillon" <je********@hotmailremove.comschreef in
Add Web Reference in Solution Explorer
No I did that.
Nov 5 '08 #6
Here are the steps, based on the code I have:

First create a reference to the service
Name it WeatherService
Then add the code and run it

I will have to run that code and make sure it is fine. I will not have a chance until this weekend to set up a sample application, with a simple web service (and instructions). I will slap it up on my blog and post a note here when I am done. That way you will have an "instruction manual" in the blog entry.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"Marc" <no*****@chello.nlwrote in message news:e2**************@TK2MSFTNGP03.phx.gbl...

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMschreef
Ok, now for something silly, and I am sorry this must be a real newbee question, and concurrently I am searching to solve this myself, but:

using ServiceConsumptionLibrary.WeatherService;
Gives

Error 1 The type or namespace name 'WeatherService' does not exist in the namespace 'ServiceConsumptionLibrary' (are you missing an assembly reference?) C:\Documents and Settings\Marc wentink\Mijn documenten\Visual Studio 2005\WebSites\H8Async\App_Code\ServiceConsumer.cs 10 33 C:\...\H8Async\

Now normally I would add a link to an assembly, a dll, with WeatherService in it, but what do I do now? I presume I do not have a dll with WeatherService in it.


Nov 6 '08 #7

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMschreef

"I will have to run that code and make sure it is fine. I will not have a
chance until this weekend to set up a sample application, with a simple web
service (and instructions). I will slap it up on my blog and post a note
here when I am done. That way you will have an "instruction manual" in the
blog entry."
Thanks! You're doing a whole lot!

Nov 7 '08 #8
So what did you name it? You would refer to that name in your code

"Marc" <no*****@chello.nlwrote in message
news:ey*************@TK2MSFTNGP06.phx.gbl...
>
"Jeff Dillon" <je********@hotmailremove.comschreef in
>Add Web Reference in Solution Explorer

No I did that.

Nov 13 '08 #9

"Jeff Dillon" <je********@hotmailremove.comschreef
So what did you name it? You would refer to that name in your code
Ah.......so stupid me, I think....

As far as I can see I have not named them in any moment yet. But I think the
name would be: com.cdyne.ws. That one is automatically choosen for you. So I
must use that name, com.cdyne.ws, where in the examples localhost is used? I
just overlooked that EditBox. Well I am not really sure where and how to you
that name, but that is the connection then!?

FYI: this is what I did, step by step:

I have used the service cowboy pointed out to me.
I have selected Add Webreference in the Solution Explorer
Inserted the URL from Cowboy:

http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl

In the "Add Web Reference Window" that pops up.
Pressed "Go"
The three supported Webservices are shown.
At the right low there is an EditBox with the title "Web Reference Name".
That's filled with com.cdyne.ws by default. But you can change the name (I
see that now).
Then I pressed 'Add Reference'.

Now in the solution explorer an entry appears in App_WebReferences. A sort
of folder tree with:

com->cdyne->ws

And in the latter ws folder there are two files:

Weather.discomap
Weather.wsdl
Yours Sincerely grateful
Marc Wentink


Nov 14 '08 #10

"Marc" <no*****@chello.nlschreef

And then calling the webservice is like this:

protected void Button1_Click(object sender, EventArgs e)
{
com.cdyne.ws.Weather wt = new com.cdyne.ws.Weather();
com.cdyne.ws.ForecastReturn FcR = wt.GetCityForecastByZIP("11202");
Label1.Text = FcR.ResponseText;
Label2.Text = "Tommorow Morning in NYC it's :
"+FcR.ForecastResult[1].Temperatures.MorningLow;
}

Nov 14 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6704
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name...
7
4955
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
3
12872
by: Henrik | last post by:
Hi all,,, I need to get a refferece to a XML-webservice, and get some data from it.... But I can't add it like an web-refference... What options does I else have?? I've been told that i've to...
3
9044
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
1
4007
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
2
5796
by: Flic | last post by:
Hi, Please excuse the elementry nature of this query - I'm new to web services. I created a webservice in VB.NET (studio 2005 fwk 2.0.5..) which is hosted on an external server. Then I...
2
2198
by: Peter | last post by:
I have a Web page which calls a WebService, this web service call might take few seconds to up 30 min I was thinking of having a webpage query the webservice every minute to keep it form timing...
0
1719
by: BornTOCode | last post by:
Hello, I am attempting to call a (Delphi) win32 DLL from a Delphi.Net webservice. I am using a slightly modified version of the hello world webservice that comes with Delphi 2006. The DLL...
6
4746
by: Peter | last post by:
I have a APS.NET 3.5 webpage which calls a web service. What I need is to update this page automatically when a value changes in the webservice, does anyone have an example? Thank You ...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4779
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.