Best way to make Linux Web Services? [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
I have a server that is running Ubuntu Linux Server Edition. I once had a Windows Server and it is easy to create web services using ASP.net on Windows. Linux on the other hand does support ASP.net using Mono, but is isn’t as full featured as Windows. So what would be the best way to create xml web services on a linux server box? Thanks
11 Answers 11
A web service can be written in any language. A web service is a program that takes request and returns response (xml or json) via http protocol. You can use a web server like Apache or lighthttpd to handle the http(s) and multithreading for you and write a simple script to do the actual work. The script can be written in anything — php, perl, python, shellscript, cgi c++, free pascal cgi etc.
Of course, You can write everything on your own by using TCP sockets, but this is not your goal I guess. For FOSS I’d do it in php, because it`s easy:http://davidwalsh.name/web-service-php-mysql-xml-json If I want it compiled, i’d use FreePascal as in this guide: http://leonardorame.blogspot.com/2010/02/web-20-programming-with-object-pascal.html
If you want to use ASP.net then use a windows server.
If you have to use Linux for some reason then you need to learn another language to work properly in the linux environment.
Linux web development is actually a world of difference from Windows web development. In leau of the bureaucracy of «applications» and «web services» we have scripts you can invoke via Apache, and if you want to get more advanced, daemons that can handle TCP/IP connections.
If you want to use something specific like SOAP, you should mention it in there, but as far as I know, Linux web development isn’t service-based like Windows is.
You don’t have to write a service, start the service, monitor the service, take it down to modify it, etc. Linux web development is typically done through a series of scripts in PHP, mod_perl, etc. that get executed when a HTTP/HTTPS request is made and return the content. If you want to get more advanced then that, you could write a custom apache module or daemon in C, but other then that, there’s no support for the «pseudo-application» thing Windows development has going for it.
This answer has opportunities in use of the term service. A web service has absolutely no relation by definition to a Windows Service although a windows service may be the thing that provides that web service. Sorry. that sentence sucks but it is accurate.
There are many ways to do this, but given your ASP.NET background why not give the MonoDevelop IDE a go, it has matured a lot and will continue to do so.
Another option is using Eclipse (Java or PHP).
Depends mostly on the web server and web language you run on Linux more than anything else. If you’re using Apache Tomcat, look at Axis2 (http://ws.apache.org/axis2/) and CXF (formerly XFire at http://cxf.apache.org/) JBoss has web service support built-in (JBossWS) so it’s fairly easy to use and since it’s a Java EE server, it uses standard web service code that is portable.
You can also write web services using PHP if you use that on your web server. Apache = IIS PHP or Java EE or JSP or JSF = ASP.Net There are a lot more choices in Linux land.
I came across the same problem recently. I wanted a thin layer to turn my SQL database into a webservice with JSON or XML support. All I wanted to do was to have to write the SQL statements. it seemed a pretty reasonable thing to ask.
However, all the options I found involved installing some sort of enterprisy «do everything» solution. So I ended up writing some «glue» which took SQL statements defined in XML «dataset» definitions, and served a simple, RESTful web service.
I documented my approach here:
If you want to use the framework, I can give you a tarball of the latest release. It’s used in three or four small applications currently, 2 ExtJS, 1 Flex, and 1 Asp.Net.
Best Command Line HTTP Client for Linux
In this tutorial, we will explore some of the most commonly used and famous HTTP clients that are present in Linux. A HTTP Client is a software that is mainly used to allow us to download files from the Internet. The primary reason for using HTTP clients is generally to download files, but these can also be used in case we want to debug or interact with a web server or multiple web servers.
Now, let’s consider the most famous HTTP Clients that are used.
HTTPie
With the name that almost resembles of the famous web protocol (i.e., HTTP), HTTPie, is command line HTTP Client that helps us when it comes to interacting with web services, and RESTful APIs. It is said that it provides a much simpler interface that is very user friendly and easy to use even for someone who hasn’t used it before.
With being a simple and easy to use client, it also provides custom headers, plugin support, JSON built-in support and colorized syntax as well and much more.
In case we want to make use of HTTPie client, the first step is to install the same on our local machine.
How to Install HTTPie?
Consider the command shown below. If you are using a Debian/Ubuntu distribution, then you can use the following command to install HTTPie.
If you are using a CentOS/RHEL distribution, then you can make use of the command shown below to install HTTPie.
Once you have installed the HTTPie client, you can use it with the following syntax −
http [options] [method] URL [ITEM]
HTTP Prompt
HTTP Prompt is command line HTTP Client that is built on top of prompt_toolkit and HTTPie that introduces more than 20+ themes. It has many features like auto-complete, syntax highlighting, http-prompt persists in-between the different sessions, auto cookies and much more.
In case you want to use the HTTP Prompt client, the first step is to install the same on your local machine.
Consider the command shown below. If you are using a Debian/Ubuntu distribution, then you can use the following command to install HTTP Prompt.
sudo pip install http-prompt
Once you have installed the HTTP Prompt client, you can use it with the following syntax −
In case you need to update the version of HTTP Prompt, use the following command −
Curl
Curl is also a common line utility like the two http clients mentioned above and is mainly used when we want to transfer files over a network using a URL. It supports different protocols, like HTTPS, IMAP, LDAP, POP3 etc.
It is a very popular utility that is mainly used not only in terminals but also when it comes to tablets, mobile phones, audio equipment, and much more.
For example, you can use the following curl command to check its version.
It will produce the following output −
curl 7.77.0 (x86_64-pc-linux-gnu) libcurl/7.77.0 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.42.0 Release-Date: 2021-05-26 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
Wget
Wget is a Linux command line utility that is used to retrieve files from World Wide Web(WWW) and makes use of protocols like HTTPS and FTP. It is a freely available package and can be downloaded and installed on any Linux supporting architecture.
One of the key features of wget is its ability to automatically start downloading where it was left off in case there is a network issue. It should also be noted that it deletes files recursively and it will keep trying to download all the files until it has been retrieved completely.
How to Install Wget
If you are using an Ubuntu/Fedora distribution, then use the following command −
If you are on Mac OS X, then use the following command −
Now, let’s take an example. You can use the following wget command to download a file from a URL:
It will produce the following output −
immukul@192 linux-code % wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz --2021-07-11 12:12:20-- http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz Resolving ftp.gnu.org (ftp.gnu.org). 209.51.188.20 Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:80. connected. HTTP request sent, awaiting response. 200 OK Length: 446966 (436K) [application/x-gzip] Saving to: 'wget-1.5.3.tar.gz' wget-1.5.3.tar.gz 100%[========================================================>] 436.49K 285KB/s in 1.5s 2021-07-11 12:12:23 (285 KB/s) - 'wget-1.5.3.tar.gz' saved [446966/446966]
Aria2
Aria2 is another command line utility that supports different protocols that allows us to transfer files over the internet. It has many features, like parallel downloading of files, automatic validation for files, IPv6 support and much more.
In case you want to use an Aria2 client, you have to first install it on your local machine.
How to Install Aria2?
If you are using a Debian/Ubuntu distribution, then use the following command to install Aria2 −
On the other hand, if you are using a CentOS/RHEL distribution, then you can use the following command −
You can use the following syntax when working with Aria2 −
Conclusion
In this tutorial, we explored different examples of the most commonly used HTTP clients that are available for Linux today.
Best Command Line HTTP Clients for Linux
HTTP clients are utility software that enables you to download files over the Internet. Apart from being able to download files remotely, these command line tools can be used for other tasks such as debugging and interacting with web servers.
Today, check out our list of the best HTTP clients created for use in the Linux Command Line.
1. HTTPie
HTTPie is an open source command line HTTP client for interacting with HTTP servers, web services, and RESTful APIs. HTTPie pronounced “aych-tee-tee-pie” and its aim is to simplify human interaction with web services via the command line, so most people use it for Wget-like downloads.
Its other features include a type-based colorized syntax, custom headers, persistent sessions, support for plugins, built-in support for JSON, etc.
2. HTTP Prompt 2
HTTP Prompt is an interactive command-line HTTP client built on prompt_toolkit and HTTPie with 20+ themes. Its feature highlights include auto-complete, syntax highlighting, auto cookies, Unix-like pipelines, compatibility with HTTpie, http-prompt persists in-between sessions, and OpenAPI/Swagger integration.
3. Curl
Curl is an open source command line utility and library for transferring files over a network using URL syntax over any of several supported protocols including SCP, SMTPS, HTTPS, IMAP, LDAP, POP3, etc.
Curl is a very popular utility used in not only terminals and scripts to transfer data but also in routers, printers, tablets, mobile phones, set-top boxes, audio equipment, media players, etc. It has a long feature list which includes support for IPv6 and socks5, custom output results after completion, no URL length limit, asynchronous name resolving.
4. Wget
Wget is an open source command-line utility for retrieving content from web servers via HTTP proxies as well as HTTP, HTTPS, and FTP protocols. Its function is recursive downloading which entails that it follows the links in HTML pages and create local versions of remote websites.
Wget boasts several features including the ability to function excellently even when your network connection is slow or unstable, support for HTTP proxies and cookies, resume aborted downloads using REST and RANGE APIs, NLS-based message files for different languages, etc.
5. Aria2
Aria2 is a lightweight open source command-line download utility with support for HTTP & HTTPS, FTP & SFTP, Metalink, and BitTorrent. Its features include automatic validation for files like BitTorrent, parallel file downloads from HTTP(S)/(S)FTP and BitTorrent at the same, Ntrc support, disk caching to reduce disk activity, IPv6 support with Happy Eyeballs, etc.
Are there any awesome command line HTTP clients that are not listed above? Feel free to add your suggestions and reasons in the discussion box below.