Asynchronous Web Service Call From WPF Application - asp.net

I know a lot of people have posted for this, but I'm still having trouble matching the symptoms I have to what other people have encountered. I created a simple web service in an empty asp.net website using Visual Studio 2010 (I just used the default web service with its Hello World implementation). Then I created a WPF application and tried to call the web service from the application. But I can't find the XXXAsync methods, or BeginXXX methods in the soap client proxy class using intellisense. There's a method for calling HelloWorld synchronously, but nothing for asynchronous calls. Is there something that I have to do in order to enable asynchronous support for a web service in asp.net?
Thanks,
Andrew

Okay, I think I figured out what I was doing wrong. In Visual Studio 2010, I didn't mark the checkbox labeled "Generate asynchronous operations". This can be found by:
right-clicking the name of the service in the solution explorer (which should be in the "Service References" folder".
going to "Configure Service Reference...".
Checking the box labeled "Generate asynchronous operations".
Hope this helps someone quicker than I was able to find it!
Andrew

Related

ASP.NET Web Service on localhost?

At the minute I am building an ASP.NET MVC application to learn the technology, and I want to incorporate web services as I have never used them before and I want to have experience with them.
I was wondering would it be possible to create a web service and run it on the Visual studio local host along with my MVC application an then consume it with the MVC application.
I am hoping that the web service will basically pull data from the the same db as the app and then allow the mvc app to consume the service. Would this be possible?
Sorry if this is a pointless question but it is for a college project. Any help greatly appreciated
Thanks
Yes, it is very possible with Visual Studio - in fact, it is easy. Best to follow some tutorials - one such tutorial is http://www.asp.net/mvc/tutorials/mvc-music-store.
For more specifics about the service from within VS, this link may be more helpful - msdn.microsoft.com/en-us/library/cc668184(v=vs.100).aspx
If you are talking a WCF service, this is very easy to do. You'll want to add the service to the same solution as your MVC project, right click on References in the MVC project, then click add service reference. On the dialog that comes up, click discover to the right and it will find the service in the solution allowing you to add it locally.
Once you have a service reference, you can right click and configure to see the path. Should be set to localhost in this case. Doing this will allow you to set breakpoints and debug the service through your MVC application.

Connect to a WCF web service without WCF

We have an ASP.NET 2.0 site. A 3rd party has created a web service that we are supposed to connect to, and I was naively expecting a 2.0 style web service to be created. When I was given the url, I was expecting to see a .asmx suffix...but instead was given a url with .svc suffix.
Going to that page tells me to to create a WCF client by running svcutil...but, again, we aren't running .NET 3.0+ yet.
Since it's a web service, I'm thinking the basic functionality should be essentially the same, but freely admit I know essentially nothing about WCF (yet.)
Can I expect this to work eventually, or is there some kind of potentially blocking issue (WCF web services being inherently different in some profound way)? Is there a simple path for creating a basic client (like svcutil would if we were in the 3.0+ world)?
If it's using BasicHttpBinding (SOAP 1.1) it's probably interoperable.
In the "Add Service Reference" dialog in VS2010, click on "Advanced", then click on the "Add Web Reference" button.

how to do logging in asp.net application IIS?

i have a asp.net web application written about 2 years ago .It does not have any logging mechanism in it. Ideally I would like to log any errors that happen especially at the database level. I cannot afford to break the application however, and I have limited time.
I have heard about ELMAH. Is it possible to have something that doesn't talk to my code directly and just does its own thing by monitoring the server?
It was made in ASP.NET 3.5.
It has AJAX as well as heavy use of ViewState.
The application also communicates with Excel.
It is built in Visual Studio 2008 w/ SQL Server 2005 on the backend.
How do I go about deploying this website with above requirements?
Yes.
Added ELAMH to your application - it will log the errors. It's non-invasive.
Once ELMAH is added to your application it hooks into the OnError Event and captures all errors throw by your application. This is assuming that your application does not swallow the errors.
The documentation around ELMAH is through and easy to follow.
There is also log4net -
http://logging.apache.org/log4net/

.NET and webservices: how?

Im trying to make a webservice in ASP.NET and get the data in a Smart Device Application.
I have the standard HelloWorld webservice and i wanna get the data in my application, but when i try to add a web reference to my project, Visual Studio can't find any webservices running. If i start the WebService in the WebService project and copy/paste the url to the "Add WebReference" in the Application project, Visual Studio finds the Webservice and i can use the InttilSence to find the HelloWorld Method (WebServiceClass.HelloWorld()) in the WebService. But when i then run the Application project the complier gives an error saying that it can't connect to the WebService.
How do i do this? How do i access a webservice in an Application project? Every tutorial or book i have read about the subject doesn't tell anything about how the webservice should i run. In my world the webservice project should be running before i can access it from another project or am i wrong?
Consider reading Rick Strahl's Creating Web Services with .NET and Visual Studio.
From there, you'll get the basics. You can build and deploy your XML SOAP web service.
Then you'll need to have your application use that web service as a 'Web Reference'. Start by "Add Web Reference".
(source: usaepay.com)
First, you should publish the web service to some server (even your own local IIS) rather than using the Visual Studio web server.
Then in your application, point to the correct URL wherever you published it when adding the reference.
While this is a bit low-tech, couldn't you create a web requrest from the Smart Device Application to hit the webservice directly? That would be my suggestion.
An example would be using the "WebRequest" Class.
It sounds like when you try to access the Web Service from your app, the service is not running (possibly because you're only running it in the Cassini server?).
The fact that you were able to generate the Web Reference means that at some point, the service was running and was able to generate the helper classes by examining the service.
I would do as David Stratton suggests and publish it somewhere where it can run while you are developing the Smart Device app (like your local IIS).
You might also take the opportunity to wrap the service call with some error handling - maybe catch the specific exception being thrown (System.Net.WebException?)

Web Service vs. WCF - different objects when consumed

I'm new to the WCF, and I'm looking for some advice. In my web app I consumed a web service (R+Click on project - "Add Web Reference") and started coding. My web app is really big, so it was taking forever to compile each time I wanted to debug, so I built a stripped down WinForm using the same code.
In VS2008 there is no "Add Web Reference" option when using the 3.5 framework, so I just chose "Add Service Reference" and used the same url. The objects/methods that I now have access to are completely different when compared to the objects/methods in the web app after consuming this as a web service.
Is that normal? Is this somehow related to the WCF?
Thanks
You can still add web references.
Do
Add Service Refernce
Hit the "Advanaced" button on the bottom left
Hit "Add Web Reference" on the bottom left.
Yes this is related to WCF. When your project target is >= .NET 3.0 the Add Service Referemce option will be available which will use svcutil.exe to generate client classes, otherwise you will have the Add Web Reference option which uses wsdl.exe. WCF clients use different classes to call a web service and that's why you get different classes generated.

Resources