Best way to post binary data to a Scala playframework web site - http

I'm writing a web app in Scala using the Play framework. I'd like to be able to push some binary data to my web server from another machine I'm using to do number crunching. I'd like to do this over http. Can anyone suggest the best way to do each side? Ideas that have occurred to me so far are:
Send the data up as a file upload via the usual play form processing. Nice on the (web) server side, but I'm not sure what libraries to use for pushing the data up from the (number crunching) client. In C/C++ I'd consider using Curl.
Send the data up as raw POST with the binary attached and encoded appropriately. Not sure how to do either side.
I've done each of the above on several occasions in Python and C++ (although not recently enough to remember how!), but am not a web dev (but a more general sw engineer) and have only ever had control of one side before - so have no idea what the best way to do this is.
Any thoughts appreciated.
Alex

It depends what platform (and language) you're already using for the number-crunching client part. If that 'client' is also using the Play framework (or at least has access to the libraries), then there are some very helpful tools for accessing web services; (see here also).

Related

Creating an image within an .net core api without a graphical interface

OK, I did my share of searching and I have a good memory of what things I would know to hunt down, but have come up empty handed. I have the following:
.net core API on a really nice reliable server
the server is my data source for Open Sim projects
Open Sim servers can take a URL of an image and drop it directly onto the face of a virtual object.
My goal is to use the above to collect information from within the OpenSim (already done) and generate an image (.png is the likely target) using the data. The API is pure REST, but with a command, I'm pretty sure I can write a file to space on the server. But here's where I get stuck:
I know how to create images on a Windows console application and have done so for decades. But I'm not sure how to create a pure memory -> file graphical creation. For that further matter, almost 100% of it will involve fonts. How the heck do you make a .net core Web API aware of fonts? I'm simply not sure where to start. I'll take any advice.

Integrating Paypal API in Adobe Flex

I am writing a Flex project in which I need to communicate with Paypal via their APIs.
Really not sure how to start with - this is my first flex/air application.
I won't be using any server side technology (no Java, Php, .NET, Coldfusion) - all of the requests have to come from Flex and the response be sent back directly to the flex application.
Can someone please give me an example or something to start with. Let's say implementation of RefundTransaction API
in Flex.
Is it possible? If not, then what layer do I need to add to the technology stack?
Just need some pointers and I will pick it up from there.
Thanks
Definitely check out this article http://www.adobe.com/devnet/flex/articles/flex_paypal.html
Essentially will need to figure this out myself as well. One of the BIG, BIG, BIG (big enough for ya) keys is to NOT include your API key anywhere in the application (or other sensitive info). This is one of the pitfalls with using a JIT language because it's based on a VM it can't be hidden very effectively.

Upload file via HTTP from VBA (WinHTTP)

I'm trying to (HTTP) upload a binary file programmatically from within VBA. I intend to put an ASPX page on the server to accept the file and certain additional parameters.
I know there are lots of nice ways to do that (e.g. use web service instead of aspx), but my constraint is that it must run in VBA (in an excel file), and that I cannot install any additional components on the client.
So I guess I'll use WinHTTP, and I've found several examples to post form data, but not to post a binary file. I probably need to base64 the file contents?
So my questions are:
Do I need to do the encoding manually or can I make WinHTTP do that?
Is there a better utility to use than WinHTTP? (Remember I don't want to install any additional software, it must be shipped with WinXP Pro, Office 2007 or a .NET framework, e.g.)
Is there a better way to go, e.g. using ASP.NET web services?
Thx, chiccodoro
You may use base64 but typically writing binary is easier.
The hurdle you have to leap is constructing a valid multi-par/form POST. This is completely possible using WinHTTP, although I have not done it in years and am not tooled to provide sample code, it is not trivial.
You can reference the following articles for examples of how to do this with C# HttpWebRequest. The WinHTTP api is a bit different of course but the salient points to take away from the articles is the structure of the POST body.
C# File Upload with form fields, cookies and headers (by yours truly)
UploadFileEx: C#'s WebClient.UploadFile with more functionality (a bit more procedural and may be easier to suss out the format)
Typically I provide sample code, but as I said, I do not have any stone-age tools set up right now ;-).
HTH

Best Practices Server Side Scripting or Web Services

Let me start off by stating that I am a novice developer, so please excuse the elementary nature of my question(s).
I am currently working on a Flex Application, and am getting more and more confused about when to use server side scripting, and when to develop web services. For most of the functionality I am working on, I am taking various files from the user (client), uploading to the server for processing/conversion, then sending back to client in new format.
I am accomplishing most of this using asp.net generic handlers (ashx) files, but not very confident this is best practice. But at the same time, does making web services make any more sense? What would be considered best practice for this? Any suggestions would be greatly appreciated.
The way I look at it is as follows:
Web Services mean Established Best Practice.
For most of our development, we don't need to create "Web Services", or what I'm thinking when I think REST, SOAP, and the Twitter API. You only need to start doing that once you've got something you're going to be using every day for years.
Clean and DRY code will Lead you to Creating a Web Service
If you spend the time to clearly define the parts of your upload-process-render Architecture, and you find that it can be applied to almost everything you are doing, then all you need to do to make it a Web Service is define a clear, 1-2-3 set of rules for using the system (GET/POST data, etc.). As long as you are consciously building an architecture the whole way, you'll end up creating a Web Service if it's worthy. Otherwise there's no need.
It sounds like you have a clear workflow going, I don't know anything about asp.net though.
As far as it being confusing sometimes, and best practices, I suggest the following:
Create a Flex Library Project for your "generic ashx file handling" Flex classes. Give it a cool, simple name.
Create a .NET Library Project that encapsulates all the logic for your server-side file processing. Host it online and make it open source. I recommend github. Test it as you go, and document it, its purpose and the theory behind it.
If you don't have to do anymore work at this point, and it's just plug and chug, then you've probably arrived at something that might become a Web Service, though that's probably a few years down the road.
I don't think you should try to create a Web Service right off the bat. Just make some clean and reusable code, make a few examples, get it online and open source, have others contribute and give feedback, and if it solves a specific problem, then make it a web service. You can just use REST for now probably, and build your system around that. RestfulX is a great library for that.
Best,
Lance
making web services without any sense make no sense ;)
Now in the world of FLEX as3 with flash version 10, you can easily read local files, modify them with whatever modifcation algorithm and save local files without pinging server.
You only have to use webservices if you want to get some server data or to send some data to server. that's all.
RSTanvir
Flash / Flex uses a simple HTTP POST approach for file uploads, so trying to do that using SOAP web services will be problematic. Your approach of using ASHX here sounds reasonable to me.
To send / receive data that isn't file based (e.g. a list of files the user has uploaded previously), I would recommend looking at the open source Fluorine FX library. Fluorine uses AMF which is a highly performant way of doing data transfer with Flash. It's also purely configuration-based, which means you don't need to code against any of its APIs, just configure Fluorine to expose your .NET service classes. You could easily add attributes to those same classes to expose them as SOAP web services via WCF if you need that in the future. I would not recommend using SOAP with Flex however, due to the performance losses and also because the Flex implementation of SOAP has a history of bugs and interoperability problems.

How to make two web sites appear as one - What features are important?

I am about to write a tender. The solution might be a PHP based CMS. Later I might want to integrate an ASP.NET framework and make it look like one site.
What features would make this relatively easy.
Would OpenId and similar make a difference?
In the PHP world Joomla is supposed to be more integrative than Druapal. What are the important differences here?
Are there spesific frameworks in ASP.NET, Python or Ruby that are more open to integration than others?
The most important thing is going to be putting as much of the look-and-feel in a format that can be shared by any platforms. That means you should develop a standard set of CSS files and (X)HTML files which can be imported (or directly presented) in any of those platform options. Think about it as writing a dynamic library that can be loaded by different programs.
Using OpenID for authentication, if all of your platform options support it, would be nice, but remember that each platform is going to require additional user metadata be stored for each user (preferences, last login, permissions/roles, etc) which you'll still have to wrangle between them. OpenID only solves the authentication problem, not the authorization or preferences problems.
Lastly, since there are so many options, I would stick to cross-platform solutions. That will leave you the most options going forward. There's no compelling advantage IMHO to using ASP.NET if there's a chance you may one day integrate with other systems or move to another system.
I think that most important thing is to choose the right server. The server needs to have adequate modules. Apache would be good choice as it supports all that you want, including mod_aspnet (which I didn't test, but many people say it works).
If you think asp.net integration is certanly going to come, I would choose Windows as OS as it will certanly be easier.
You could also install reverse proxy that would decide which server to render content based on request - if user request aspx page, proxy will connect to the IIS and windoze page, if it asks for php it can connect to other server. The problem with this approach is shared memory & state, which could be solved with carefull design to support this - like shared database holding all state information and model data....
OpenID doesn't make a difference - there are libs for any framework you choose.

Resources