Can webservices be accessed by Silverlight 3? On VisualStudio, a Silverlight project doesn't allow me to add a "web reference" but only a "web service reference" that is for WCF and not "normal" webservices.
Any help?
Thanks
Sure you can. In your web project, add a new asmx webservice and add whatever functions you want. Then build your web project.
Next, go to your silverlight project, right click on Service References, select Add Service reference. If you then hit the Discover button in the dialog that pops up, it should discover your new web service. If it doesn't, then you can manually enter the url to it - if you have Cassini running (press F5 in your web project, then close the browser window once launched, Cassini will continue to run in the background) just enter http://localhost:[port]/MyWebService.asmx as the address. The [port] is whatever port you have Cassini running on for this particular project).
Also don't forget to kee the cross domain limitations and work arounds in scope when considering any implementation:
http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx
Also there is a great MIX video on this:
Consuming Web Services in Microsoft Silverlight 3
Description: Come hear how to work with external REST, SOAP, and Windows Communication Foundation (WCF) services from Silverlight. Learn how to securely and efficiently communicate with services using Binary XML, debug services with improved Faults support, and implement server-to-client "push" using the new Add Service Reference for Duplex functionality.
http://videos.visitmix.com/MIX09/T42F
Related
I am trying to add a asmx web service to one windows forms app by following way ->
Right click- > add service reference.
But it seems the service is added under connected service folders only. not under service reference . Is this an expected behavior?
or are we supposed to use web reference instead of service reference for windows forms application?
To answer this question you need to know the difference between Webservice and WCF web service and you'll find that
Here.
Anyway, I'ts a noraml behavior, let's form that in another words, the Service reference will let you communicate with a WCF-based services whatever those services are, but with the web reference, you can only communicate with web services under some conditions.
I would use service reference always because it gives more options including those in web service, and it's the new-easy way.
In our application a Service Reference was added to connect to a SOAP Web Service. When connecting to the Web Service we get an error. The owner of the web service told us that the error was caused because we use SOAP 1.2 and theirs web service only supports SOAP 1.1.
This answer mentions to add a textMassageEncoding setting in our custom binding. But it is not clear where to add this setting. Where should this setting been added?
Instead of adding a Service Reference add a Web Reference. I use VS 2013 (VS 2017 is exactly the same), right click on project name in Solution Explorer, select add then Service Reference, click Advanced button, click Add Web Reference at the bottom. Web references are a bit dated, but I use them all the time because I have a ton of legacy software, including android and iOS apps that use them. RESTful apis are typically the most used api these days.
I've gone through some tutorials on creating a WCF service. I'm using Visual Studio 2012. I got a very simple WCF Service Library (vb.net) and Windows Application (vb.net) communicating via WCF. That's a start.
However, my project requires I do the following:
My Windows Service - This is already an application that has it's tasks.
My Application - This is an application that is already developed as well.
I need the service to talk to the application. The service will need to send the following information to the windows application:
Status Updates
Metric Information (mostly integers for counts)
I need the application to send information to the service. It would need to send:
Reload Configuration command
Should be relatively simple, but I've never worked with WCF until today. So I have some questions...
Do I need to re-work my current windows service into a WCF Service?
Since it won't be in IIS, do I also create a WCF Service Library or do I roll this into the windows service somehow?
What is the best way to set up the different types of communication? (i.e., sending over specific metrics and reload commands)
Probably the main question is what components, in addition to my current windows service and application, will I need to make this work?
I hope that was clear :( I think I'm confusing it all... but I hope not
Your Windows service can host the WCF service. Similarly, if you want, your application can host a WCF service. The application could talk to the WCF service in the Windows Service, and the Windows Service's WCF could talk to the one in the application. Depending on the nature of the communication, you could also just use a callback channel to permit the Windows Service's WCF to call back to the application.
I suppose you should configure your WCF windows service to use named pipes. If your windows service is already built then the easiest way to do it would be to build another one as a WCF windows service and wrap the already existing functionality.
Hope I helped!
I am working on a Silverlight application that uses WCF. I need to have my WCF project separate from the ASP.Net application that will host my Silverlight project. I am looking for some guidance on how I should organize my solution and list gotchas other people have experienced during debugging and deployment.
Specifically my questions are
What type of project should I use for the WCF service?(A WCF project, an ASP.NET project with self-hosted WCF services, something else)
What do I need to so to get it so that when I press F5 I can debug both my Silverlight project and my WCF service? Will I need a cross-domain policy just to debug the thing?
Some background info on why I want to do this:
I have legacy web application that I am gradually converting over to a Silverlight application. Because it is a large web application some of its features will be converted to Silverlight before others.
The legacy web application has lots of code in it that is no longer used. Much of the code that is no longer used references 3rd part assemblies. This is why I want to get rid of the old web application. So obviously I don't want to host WCF services that will be kept for future versions in it. That is my reason for wanting to make the WCF project separate.
We're doing the exact same thing.
We're using a WCF project just in case we have to change how it's hosted in the future. (I.E. no longer using IIS)
2.a. You can have a solution with your silverlight projects, and your wcf project. The silverlight project will have a service reference to the wcf service in your solution. That allows you to debug using F5. However, when you go to deploy, you will have to change your app.config service URIs to refer to your production location.
2.b. You will only need a cross-domain policy file if your fully qualified domain names are different for the wcf service and the silverlight app. Ours happen to be different. Here is an excellent article on when to use the policy file: Clicky
Good luck!
Just remember that when you get ready to deploy, if your service is going to be hosted on a different machine than your app, you need to deploy the service first. Then re-configure your service reference, and finally re-compile your Silverlight before deploying. Otherwise, your Silverlight app will look for the service on your local machine instead of where you deploy it.
I created a RoleService in my silverlight project and through that got hold of the embership/Role functionality. I am running this on a local machine and is wondering how to publish this to my website. I have 3 web applications:
My main web application where the silverlight object shoule be merged into
The silverlight project which lets me develop the silverlight application
The silverlight host application which I use for testing
In the web application (1) i have made the RoleService so that i can get a hold on my Roles. In the Silverlight application (2) I have a service reference to the service mentioned above which I consume and loads my Role data. This howecer doesnt work when i publich it online. But how do i get it to work online?
Is it because it is trying to connect to service with wrong address? If so, then you just need to propagate WCF service address to your Silverlight application through hosting web.config and start connecting to a correct service.
Let me know if this is the case, then I will share exact solution for this.