silverlight process on client side - c#

i am a php developer, not knowing much about silverlight, i am working on a project which needs to process request on client browser, like post httprequests and process them, its a auto directory submitter, can it be done in silverlight application?
i want the user to open the silverlight application, which will submit the post request from client side, and also process for success and failure.
is it possible?
please guide me.
thank you

When you run a silverlight application, you basically download a .xap file (with dlls inside). Those are executed on your machine. I'm no PHP expert but I seem to recall that PHP is executed server-side - so now you know the difference.
In order to communicate with the server you can use one of the popular methods :
use a WCF Webservice
use a WCF Ria WebService
use a WCF REST Webservice
use Sockets
I'm not sure but I think that using a WebClient object is also possible with a POST verb (you'd need to look it up though).
You can access silverlight.net's learning section for some good videos about using WCF services or hand-on labs. I'd also recommend Matthew McDonald's Pro Silverlight (3 or 4) books, those have some good socket examples.
Hope that helps.
Regards

Related

What is the best way of communicating from web->web api->console app and back again?

I'm starting up a little code project to learn from the process, but I am not sure what's the best way of communicating between the different parts.
First, I have a pure html/js client where the users need to get live updates frequently.
Secondly, I'm considering having a web api application running to provide data.
Thirdly I have a console application running, that needs to communicate with the web api application.
So I'm thinking about using WebSockets all the way from client->web api->console app, but I have trouble making it work. I can make the console app work as a server, but I can't figure out how to make the web api work as a client, so that when it spins up, creates a connection to the console app, and keeps it open for communication, while it delivers data to the clients upon requests.
I tried with different implementations and I have ended up with SignalR, as it seems like that's what people use today :)
Since I have all these problems getting a connection I am wondering if there are better ways of sending data that fulfills my requirements?
If WebSocket (using SignalR) is the way to go, can you provide some links with working examples? I have tried all the top links from Google with no success ^^
Thanks in advance
Your WebAPI project can act as WebSocket server as well. Check this link that uses an IHttpHandler, but you can also do it in a WebAIP's controller how is explained here : Using WebSockets with ASP.NET Web API
The console application should connect as client, using for example ClientWebSocket class.
WebSockets are persistent full duplex connections, so once the client is connected both ends can push information to the other end.

Send requests to desktop application server

I have the following questions:
I am creating a desktop application (Windows), and I wish the same send solitudes and interact with another application running stored in server (Windows Server), I'm programming in C #.
Is there any way? With some protocol or something related? How?
Thanks.
There's a LOT of ways to do it.
In modern way, use Server: ASP.NET WebApi and desktop application: HttpClient. This is called REST and most popular in these days.
In Windows way, use Server: WCF and desktop application: WebService. Not recommended for simple service.
Oldies but goodies way: use Socket programming.
Many folks might recommend to use REST. Try to find tutorials related on C# and Rest. There's hundreds of good articles so cannot pick one of it in this reply.

How do I implement WebSockets from scratch with the .NET 4 Framework (and nothing else)?

Ok I want to build a simple chat app where people can go a url, type in a name and a message and click submit and it will basically show that message to everyone that is current connected.
Firstly i would like to state i've had zero experience in sockets programming and the like. I'm simply a web 2.0 person building websites with css/html/js/ajax and backend i have asp.net on vb and sql server for database.
The many tutorials i've read linked me to http://superwebsocket.codeplex.com/
I've downloaded it, but im totally lost. i can't get the samples working and i don't even know what to run.
So basically coming from an ajax background, i was wondering why do we even need to download any additional stuff to do web sockets? I mean in ajax i can simply create a asd.aspx file and use Response.Write(text) (text based on the input which are available through dissecting the url) and voila, the server side is done, all that's left is just to create new XMLHttpRequest and stuff in the client side.
So ok I'm not worried about the client side part of Web Sockets. but the server side part of web sockets is just difficult. so in the client side i have this: ws://localhost:8080/websocket. Is it true that it will work if is also an .aspx file as such: ws://localhost:8080/websocket.aspx ?
I'm wondering so how do i continue from here? in Ajax i will supply parameters from client in the url as such: page.aspx?a=1&b=2 and do output in the server using Response.Write it's all clear but how do we do it in web sockets?
I mean of course i do not demand a full explanation with a forum reply but if someone could link me to a tutorial/book that actually does explain these stuff it would be great.
Microsoft's implementation has a full chat client sample for both HTML5 and pure C#.
http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/download
I'm guessing this implementation is what would end up in ASP.NET and .NET framework so I'm using it because of that.

How to debug soap web services?

If I have a server sitting somewhere that is not returning the correct information to a client that uses async methods to communicate with it, how do I debug this with soap?
I mean, atleast with rest I can just type in a web address inside a browser and see on the screen the xml response. But how is debugging usually done with soap?
Note, my client is c#/wpf and the server is java
Have look at soapUI. I usually use it to develop and debug soap based web services.
As already mentioned soapUI is great tool if you want to test communication manually. If you want to see what exactly happens between your application and the service use Fiddler.

run C# code on client side in a web app

I have code on my server which works very well. It must crawl a few pages on remote sites to work properly. I know some users may want to abuse my site so instead of running the code which uses webclient and HttpRequest i would like it to run on client side so if it is abused the user may have his IP blacklisted instead of my server. How might i run this code client side? I am thinking silverlight may be a solution but i know nothing about it.
Yes, Silverlight is the solution that lets you run a limited subset of .NET code on client's machine. Just google for silverlight limitations to get more information about what's not available.
I don't know what is the scenario you're trying to implement, and whether you need real-time results, but I guess caching the crawl results could be a good idea?
In case you're after web scraping, you should be able to find a couple of JavaScript frameworks that for you.
I think your options here are Silverlight or somesort of desktop app
Unless maybe there is a jquery library or other client scripting language that can do same things
That's an interesting request (no pun). If you do use Silverlight then maybe instead of porting your logic to it, create a simple Proxy class in it that receives Requests from your server app and shuttles it forward for the dirty work. Same with the incoming Responses: have your Silverlight proxy send it back to the server app.
This way you have the option of running your server app through the Silverlight proxy in some instances, and on its own (with no proxy) in other scenarios. The silverlight plugin should provide a consistent API to program against no matter which browser it's running in.
If using a proxy solution in the web browser, you might even be able to skip Silverlight altogether and use JavaScript/AJAX calls. Of course this kind of thing is usually fraught with browser compatibility issues and it would be an obscure push/pull implementation for sure, but I think JavaScript can access domains and URLs and (in some cases of usage) not be restricted to the one it originated from.
If Silverlight security stands in the way you might look into other kinds of programmable (turing complete) browser plugins like Java, Flash, etc. If memory serves correct, for the Java plugin, it can only communicate over the network with the domain it originated from. This kind of security is too restrictive for your crawling needs.

Categories