Use PHP to develop SCA and SDO

Source: Internet
Author: User
Tags sca sdo

Initiated by an open service-oriented architecture joint organization (OSOA), component-Oriented Architecture (SCA) and service data object (SDO) have become the latest method for developing a service-oriented architecture. At the beginning, these development tasks were only concentrated in some common development environments, such as Java and C ++. Currently, SCA and SDO have started to enter other platforms, here we will explain how to include some SOA technologies in PHP.

First, let's take a look at what SDO can offer you. In a typical PHP application, half of the data comes from relational databases. However, if this application not only obtains data from this application, but is it getting data from a common text file or a Web service? This problem is complicated, because each data source requires its own method of acquisition.

In this case, SDO in PHP provides a transparent way to process data sources. Instead of processing each data source separately, it provides a unified way to access data objects. This process is done through the Data Access Service (DAS), which is a mediation method in the SDO architecture. Let's take a look at an SDO request in PHP.

<?php
$providers = $company->shippingByGround;
foreach ($providers as $name => $value) {
 echo "$name: $valuen";
}
?>

Note that the final request is used to process unknown data sources. You do not know where the data is extracted here, but use the SDO format of PHP for a search, the details are completed by DAS. PHP currently supports obtaining data sources of XML and relational databases.

SDO is concerned with data, while SCA uses more common classes and components to achieve the same transparency. To access existing business logic from any PHP class, do developers need to be forced to design a specific class of assumptions? Is the logic already in another local PHP class? Is it in the network? Is it written in PHP?

When the preceding scenarios are met in their respective requirements, different methods are required for each scenario.

With SCA, it doesn't matter where the logic is stored, let alone the language used for implementation. Then you must say, "Isn't this the same as a common Web Service? There is no difference !" Let's take an example to see what is included in the php sca component.

<?php

include "SCA/SCA.php";

/**
* Calculate a shipment price for a given customer using a specific provider
*
* @service
*/
class ShipmentQuote {

 /**
 * The customer discount fee service to use.
 *
 * @reference
 * @binding.php ../DiscountFeeRate/DiscountFeeRate.php
 */
 public $discountFee;

 /**
 * The shipping service to use.
 *
 * @reference
 * @binding.wsdl ../Shipper/ShipperQuote.wsdl
 */
 public $shipper;

 /**
 * Get a quote for a given customer using a specific provider
 *
 * @param string $shipping The shipping company
 * @param string $customer The customer requiring shipment, in order to obtain discount rate
 * @return float The quote for a given customer using a certain shipping provider.
 */
 function getQuote($shippingCo, $customer)
 {
$rateShip = $this->shipper->getShippingPrice($shippingCo);
$rate = $this->discountFee->getDiscountRate($customer);
return $rate * $rateShip;
 }
}
?>

The most important part above is the statement that contains @, each of which provides a specific SCA behavior. The @ service Identifier at the top layer, indicating that a class is exposed as a service. In this example, the final getQuote function will be the only operation exposed by the Service, identified by @ param and @ return.

The execution or deployment of the final service will be delegated to a php sca runtime-it will bring us into an access point for creating the WSDL contract, as you can see in network services. In addition to the simplicity of this method of deploying services, the real advantages of the SCA model will become more apparent when you check the getQuote code.

Note the two statements $ this-<shipper-> getShippingPrice ($ shippingCo) and $ this-> discountprice-> getDiscountRate ($ customer), which are based on the applications before the class. Each application is supported by its support service lock (identified by @ reference and @ binding). In the $ discountcounter use case, this will be a PHP class, and in the shipper use case, this will be a standard WSDL-based service.

Despite the simplicity of PHP and the support of a large number of user groups, PHP has become a good choice for Building web applications, but it has limited capabilities in many enterprise application scenarios. Now, by adding SCA and SDO, it provides strong support for PHP and previous technologies. Like other mainstream languages, it can participate in the service-oriented trend.

[Related articles]


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.