What are Web Services and why do I need to use them

The World Wide Web Consortium (W3C) defines a 'Web Service' as a software system designed to support interoperable machine-to-machine interaction over a network. Though this is a very broad definition, actual usage normally refers to SOAP (Simple Object Access Protocol) formatted XML envelopes for transport and WSDL (Web Services Definition Language) files for the interface definition. This more restrictive description is the one accepted and backed by the Web Services Interoperability Organization (WS-I).

A Web Service is essentially a set of functionalities that a server-side program makes available for calling by external entities. These entities can be browser-side code written by the creators of the Web Service itself or third party code calling from another server. Security restrictions within the browser do not allow code which was downloaded from one domain to make calls to server-side code from another domain.

No other web development tool allows you to create Web Services as effortlessly as with Morfik. Basically, you only need to worry about your business logic and leave the rest to the Morfik Framework.


Why do I need to use Web Services?

Web Services provide a standard for communication between the browser and server side of a web-based application. Not only are they the established standard for different systems to inter-operate, but Morfik makes use of them as the overall standard of communication between the two parts of your application. Whenever your client/browser-side code needs to request a service from the the server, this request is made in the form of a Web Services call.

As the number of companies offering on-line applications for business and personal use grows, so does the number of opportunities for you to use Web Services from your applications. Amazon, for example, provides an interface to its 'S3' storage system through a Web Services programming interface. Other companies which provide business applications, such as Salesforce.com, have been providing Web Services standards compliant interfaces for a long time.

A Morfik application can not only create and make use of its own set of Web Service interfaces, but these can make use of services such Salesforce.com and Amazon S3 to help you build a more robust and flexible application which can integrate data from these applications with that in its own database, or in some other legacy system's database, through an external database connector.

In order to make it easy for its users to import, interact with and even create Web Services, Morfik has created a concept called the Web Method. Web Methods are Morfik's abstraction of Web Services, providing a simple and direct way for you to interact with them.

What are Web Methods?

Web Methods are a web version of a relational database’s stored procedures. They are routines or services which can be called when required by your application or be published so as to be called from other applications. Web Methods are implemented fully on the server, but have a browser-side component so as to allow easy usage from within the same XApp. It is through the creation of Web Methods that you build the Web Services interface of your XApp.

In Morfik a Web Method is a class and a special kind of module. Morfik allows you two create Web Methods in two ways, through a visual designer and by hand coding. In both cases you will be creating a class that is a descendant of the 'WebMethod' class in order to do so. The hand coding option, while requiring a bit more of work, is the more flexible way and allows the developer to fully explore the potential of Web Methods.

The visually created Web Methods restrict the data types that their parameters may assume to basic types; however, they can be quickly created along with a special 'Web Method' kind of module, and as such they can be managed through the Project View of the Morfik development environment. This simpler approach can be more than sufficient when the purpose of a Web Method is to return a single bit of information such as a string. Read more...

Database access

One of the most frequently encountered reasons for using a Web Method in an application is the need to access some information that, due to security restrictions, is not accessible directly from the browser portion of your application. While Morfik uses Web Methods, transparently, for all its browser to server communication, when you become aware that you need to access a piece of information that is only available on the server side you will need to create a Web Method to retrieve and return it.

Since direct database access can only occur on the server side, database information access is one of the prime reasons for creating and using your own Web Methods. Read more...

Using Web Services in a Morfik application.

Morfik allows developers to both publish and consume Web Services. In Morfik 07, the publishing of Web Services, though adhering to industry standards, imposed limitations on the type of parameters (specifically structured/complex types) that a Web Services call could accept. This limitation has been removed as of Morfik 2.0. Morfik offers an extremely easy entrance path to the world of Web Services and Services Oriented Architecture (SOA).

Morfik offers an easy way for the uninitiated to brave new frontiers through the concept of a Web Method which is a function/method published through Web Services Standards.

All Morfik applications (XApps) are inherently Web Services compliant servers in their server-side components. This is because the Morfik Framework actively uses Web Service calls to implement all of its high level communication between the server and browser sides of Morfik XApps.

Since browsers will not allow JavaScript code downloaded from domain A to make a call to a server in domain B, for security reasons, the browser side of an application can only make calls to external Web Services from the server-side component. Calls between the browser and server portions of an XApp are considered to be a special case and the developer can create 'WebMethods' which will be callable from the browser side through the RunWebMethod command.

With this restriction in mind, there are two basic scenarios for usage of Web Services in a Morfik application, with two possible variations in one of them:

Scenario 1

Intra-application calls from the browser to services offered by the server-side portion of an XApp. In this scenario we are considering that the application/site which is running in the browser is part of the same Morfik XApp as the server-side code.

web-services-scenario-1.png
Scenario 1 Intra-application calls.

Scenario 2

Calls to Web Services external to the application, implemented in another Morfik XApp (scenario 2a) or any other source (scenario 2b). These calls are started on the server side of an XApp, sometimes in response to a an intra-application call from the browser side, as described in Scenario 1.


web-services-scenario-2a.png
Scenario 2a .


web-services-scenario-2b.png.png
Scenario 2b .

Pushing the boundaries

Aware that security restrictions impose a penalty on developers in order to safeguard the computers running the browsers, Morfik moved to ease this penalty as much as possible by building into the Morfik Framework all the code necessary to allow additional scenarios to be implemented. Morfik thus offers an extended range of scenarios for the use of Web Services and for building the blocks which will be part of a SOA environment.

With these extensions Morfik allows the developer to effectively work around these limitations in the building of industry standards compliant Web Services server applications and provides the possibility of initiating a Web Services call directly from within the browser (Scenario 3).

Scenario 3

A single browser XApp calls directly Web Services provided by two (or more) different servers within the same domain it was served from (Scenario 3a).

web-services-scenario-3a.png.png
Scenario 3a .


One of the servers which is being called directly can make a call to an external service provided by a server in another domain (Scenario 3b).

web-services-scenario-3b.png
Scenario 3b .

Scenario 4

The process of creating "proxies" to external Web Services (as described in Scenario 3b) is automated. This allows Web Services to be easily called from browser XApps through a server XApp proxy.

web-services-scenario-4.png
Scenario 4 .

In this scenario the logical communication is between the browser XApp and an external Web Service.This is impossible to implement without a server component due to browser security restrictions. Morfik automates the process of creating proxies for this type of situation and allows the developer to code the application as if the call was actually originating on the browser.

Scenario 5

The all-you-can-code Web Services scenario. It includes all the possibilities that are covered in scenarios 1 to 4 and shows that they can be used in conjunction to create sophisticated web applications and websites.

web-services-scenario-5.png
Scenario 5 .

Conclusion

Web Services offer a powerful tool to help you build better and more flexible applications that can import functions published by major service providers and can publish their functions or services. Using Web Services your applications can publish services for consumption by other applications created by the same developer or third parties.

Morfik is committed to offering increasing support for the use of Web Services. In fact, changes were introduced in the Morfik Framework as of version 2.0 in order to more fully support all aspects of creating industry standards compliant Web Service servers. These changes have been tailored to make the creation of such servers easier and faster. Using Morfik it is now much faster and practical to publish Web Wervices. Developers can very quickly create applications which publish their services so that other systems can consume them.

Given the relative ease with which Morfik applications can now publish even large sets of functions for consumption by other systems, it is now considerably simpler and faster to implement larger systems which are comprised of more than one Morfik application.

Related Topics

Back to top