473,626 Members | 3,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Consuming ASP.NET web service from WinForms application

OK, I have to do a Winforms application (C# or VB doesn't matter - that's
not the important point here) that interacts with a database on a web server
using an ASP.NET web service.

I've done a lot of WinForms programming, but never Web Services. Got a book
about it but that one only talks about how to use the web service from
ASP.NET web applications.

I assume it's pretty much the same from a windows forms app that I have to
add a web reference to my Web service.

BUT:

1) What happens if the web service is not available because the computer
running the app is not connected to the internet? Will the app crash or can
it continue if the web service referenced is not available?

2) Can I define classes in my web service and have the web service return an
instace of that class? Will my windows app be able to recognize classes
defined in a web service?

I hope somebody can answer this for me, because I have to get started now,
and I could really use any tips you might have. Is there something else I
should think of?

Cheers,
Johnny J.
Oct 2 '08 #1
2 2729
"Johnny Jörgensen" <jo**@altcom.se wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
1) What happens if the web service is not available because the computer
running the app is not connected to the internet? Will the app crash or
can it continue if the web service referenced is not available?
If the server is not available, you will get an exception when making
any call to the webservice. The exception can be caught by means of
try...catch.
2) Can I define classes in my web service and have the web service return
an instace of that class? Will my windows app be able to recognize classes
defined in a web service?
Yes. When you add a Reference to the web service, a local definition for
the remote class will be created in your project along with the proxy class
for the webservice. Note that only the data in the class will be
"transporte d". If the class defines methods on the server, those methods
will not be available to the local "copy" of the class.
I hope somebody can answer this for me, because I have to get started now,
and I could really use any tips you might have. Is there something else I
should think of?
Note that when your web service returns an instance of the class, you
don't get a reference to the original object, but the serialized contents
that are then deserialized into a local copy. So the semantics are somewhat
different to what you would get if you were doing a local call, even though
the syntax of the call looks the same on your source code.

Oct 2 '08 #2
Thanks a lot, Alberto. That was really helpful.

"Alberto Poblacion" <ea************ *************** ***@poblacion.o rgskrev i
meddelandet news:eB******** ******@TK2MSFTN GP02.phx.gbl...
"Johnny Jörgensen" <jo**@altcom.se wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>1) What happens if the web service is not available because the computer
running the app is not connected to the internet? Will the app crash or
can it continue if the web service referenced is not available?

If the server is not available, you will get an exception when making
any call to the webservice. The exception can be caught by means of
try...catch.
>2) Can I define classes in my web service and have the web service return
an instace of that class? Will my windows app be able to recognize
classes defined in a web service?

Yes. When you add a Reference to the web service, a local definition
for the remote class will be created in your project along with the proxy
class for the webservice. Note that only the data in the class will be
"transporte d". If the class defines methods on the server, those methods
will not be available to the local "copy" of the class.
>I hope somebody can answer this for me, because I have to get started
now, and I could really use any tips you might have. Is there something
else I should think of?

Note that when your web service returns an instance of the class, you
don't get a reference to the original object, but the serialized contents
that are then deserialized into a local copy. So the semantics are
somewhat different to what you would get if you were doing a local call,
even though the syntax of the call looks the same on your source code.

Oct 2 '08 #3

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

Similar topics

17
5051
by: Jeremy Chapman | last post by:
I've seen apps where if a windows exe form is running, it publishes a web service. There is no IIS folders or virtual directories required. Does anyone have information on how to do this?
2
1454
by: Glenn Venzke | last post by:
Is there any way to tell what type of application is consuming a web service? I'm writing a web service that returns a string with 2 carriage returns. What I want to do is replace these carriage returns with "<br>" tags ONLY if a web application is consuming.
17
6428
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
2
6888
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no service required. But... "A windows service enables the creation of long-running executable
1
1457
by: Peter931 | last post by:
I have a winforms Application that should share some data via WEB-Services. Remoting is not possible for other reasons. How can this be done ? When the WEB-Service is hosted in IIS on the same machine, I dont know how to access variables from the Winforms Application.
1
2848
by: Steffer [MCP] | last post by:
Hi NG I'm have made a server application (WinForms) but I would very much like to move the tasks that my app runs into a Windows Service. But have you any experience building an communication interface between the Gui and a Windows Service, I'd like to hear from you. Is the solution: Sockets - with commands and data send directly
1
1492
by: Andy | last post by:
Hi all, I'm familiar with web service compression and how to implement it in a Winforms app. What I'm trying to figure out how to do at this point is how to consume the service from an ASP.NET page. I've surfed around quite a bit looking for an answer to this, but most of the stuff I'm seeing is either talking about consuming from a Winforms app or enabling web compression for ASPX pages to the user's browser. Here's our setup: We...
1
1647
by: =?Utf-8?B?R29yZG9u?= | last post by:
Hi; I can consume a web service from an asp.net application with no problem. The web service connects to a remote server through ODBC and returns a data set to the consuming software. When I try to consume the WS from a windows app is gives a 407 error. I didn't think that the consuming application had to worry about connecting
2
956
by: Luyolo | last post by:
Hi folks, Please I need help. I'm developing a C# WinForms application. My application has a text box where a user will enter pin or a code and then my application has to search the XML web service and return the record with that Pin or Code. Did anyone developed something like this or you know any link I can get such code. I need and its quite agent.. I 'll appreciate your help..
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.