Beispiel #1
1
/*
+----------------------------------------------------------------------+
| Copyright IBM Corporation 2007.                                      |
| All Rights Reserved.                                                 |
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: SL                                                           |
+----------------------------------------------------------------------+
$Id$
*/
include 'SCA/SCA.php';
$greeting_service = SCA::getService('./Greeting.php');
$reversing_service = SCA::getService('./Reversing.php');
$name = $_REQUEST["inputtext"];
$greeting = $greeting_service->greet($name);
$reversed_greeting = $reversing_service->reverse($greeting);
echo "Name: " . $name . "<br/>";
echo "Greeting: " . $greeting . "<br/>";
echo "Reversed: " . $reversed_greeting . "<br/>";
Beispiel #2
1
 private function __construct()
 {
     global $conf;
     $v_cloudBankServerLocation = $conf['cloudbank_server_location'] . '/';
     $this->r_ledgerAccountService = SCA::getService('wsdl/LedgerAccountService.wsdl', 'soap', array('location' => $v_cloudBankServerLocation . 'LedgerAccountService.php'));
     $this->r_eventService = SCA::getService('wsdl/EventService.wsdl', 'soap', array('location' => $v_cloudBankServerLocation . 'EventService.php'));
     $this->r_statementService = SCA::getService('wsdl/StatementService.wsdl', 'soap', array('location' => $v_cloudBankServerLocation . 'StatementService.php'));
 }
Beispiel #3
0
 public function testScaActsAsADataFactory()
 {
     $service = SCA::getService('./SCATestService.php', 'local');
     $person = $service->reply();
     $this->assertTrue($person instanceof SDO_DataObjectImpl);
     $this->assertEquals('personType', $person->getTypename());
 }
Beispiel #4
0
function display_orders($status)
{
    $warehouse = SCA::getService('../WarehouseService/WarehouseService.php');
    $orders = $warehouse->getOrdersByStatus($status);
    if (count($orders->order) == 0) {
        echo "None\n";
        return;
    }
    include_once "./table.php";
    table_start();
    table_row_start();
    table_cell('<b>Order ID</b>', '#DDDDFF');
    table_cell('<b>Name</b>', '#DDDDFF');
    table_cell('<b>Status</b>', '#DDDDFF');
    table_row_end();
    $odd = false;
    foreach ($orders->order as $order) {
        table_row_start();
        if (!$odd) {
            table_cell("<a href=\"./order_details.php?orderId=" . $order->orderId . "\">" . $order->orderId . "</a>");
            table_cell(isset($order->customer->name) ? $order->customer->name : 'no name supplied');
            table_cell($order->status);
        } else {
            table_cell("<a href=\"./order_details.php?orderId=" . $order->orderId . "\">" . $order->orderId . "</a>", '#DDFFFF');
            table_cell(isset($order->customer->name) ? $order->customer->name : 'no name supplied', '#DDFFFF');
            table_cell($order->status, '#DDFFFF');
        }
        $odd = !$odd;
        table_row_end();
    }
    table_end();
}
Beispiel #5
0
 public function testSoapProxyActsAsADataFactory()
 {
     $service = SCA::getService('./SoapProxyTest.wsdl');
     $person = $service->createDataObject('PersonNamespace', 'personType');
     $this->assertTrue($person instanceof SDO_DataObjectImpl);
     $this->assertEquals('personType', $person->getTypename());
 }
Beispiel #6
0
function getResults($query)
{
    $ebay_consumer = SCA::getService('eBaySvc.wsdl', 'ebaysoap', array('config' => './config/ebay.ini'));
    // Create the body
    $request = $ebay->createDataObject('urn:ebay:apis:eBLBaseComponents', 'GetSearchResultsRequestType');
    $request->Version = 495;
    $request->Query = 'ipod';
    $request->createDataObject('Pagination');
    $request->Pagination->EntriesPerPage = 10;
    try {
        $results = $ebay->GetSearchResults($request);
        $total_results = $results->PaginationResult->TotalNumberOfEntries;
        echo "<b>{$total_results} results</b><br/><br/>";
        if ($total_results) {
            foreach ($results->SearchResultItemArray as $search_result_items) {
                foreach ($search_result_items as $search_result_item) {
                    echo '<table border="1">';
                    foreach ($search_result_item->Item as $name => $value) {
                        echo "<tr><td>{$name}</td><td>";
                        print_r($value);
                        echo "</td></tr>";
                    }
                    echo '</table></br>';
                }
            }
        }
    } catch (Exception $e) {
        echo '<b>Exception: </b>' . $e->getMessage();
    }
}
Beispiel #7
0
 public function testLocalProxyActsAsADataFactory()
 {
     $service = SCA::getService('./LocalProxyTestSDOReverser.php');
     $person = $service->createDataObject('PersonNamespace', 'personType');
     $person->name = 'William Shakespeare';
     $person->dob = 'April 1564, most likely 23rd';
     $person->pob = 'Stratford-upon-Avon, Warwickshire';
     $this->assertTrue($person instanceof SDO_DataObjectImpl);
     $this->assertEquals('personType', $person->getTypename());
 }
Beispiel #8
0
 public function testCanCreateOperationSdoRegardlessOfAlphabeticOrder()
 {
     $service = SCA::getService('./HelloPersonService.wsdl');
     $person = $service->createDataObject('aaa://PersonNamespace', 'personType');
     $person->name = 'William Shakespeare';
     $arguments = array($person);
     $method_name = 'hello';
     //  before the fix to 12193, the following call threw
     // SDO_UnsupportedOperationException: createDocument - cannot find element hello
     $operation_sdo = $service->getSoapOperationSdo($method_name, $arguments);
     $this->assertEquals('http://HelloPersonService', $operation_sdo->getTypeNamespaceURI());
 }
Beispiel #9
0
function getResults($query)
{
    $ebay_consumer = SCA::getService('eBayConsumer.php');
    try {
        $results = $ebay_consumer->GetSearchResults($query);
        $total_results = $results->PaginationResult->TotalNumberOfEntries;
        echo "<b>{$total_results} results</b><br/><br/>";
        if ($total_results) {
            foreach ($results->SearchResultItemArray as $search_result_items) {
                foreach ($search_result_items as $search_result_item) {
                    echo '<table border="1">';
                    foreach ($search_result_item->Item as $name => $value) {
                        echo "<tr><td>{$name}</td><td>";
                        print_r($value);
                        echo "</td></tr>";
                    }
                    echo '</table></br>';
                }
            }
        }
    } catch (Exception $e) {
        echo '<b>Exception: </b>' . $e->getMessage();
    }
}
Beispiel #10
0
+-----------------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2006, 2007                                    |
| All Rights Reserved.                                                        |
+-----------------------------------------------------------------------------+
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License. You may obtain a copy  |
| of the License at -                                                         |
|                                                                             |
|                   http://www.apache.org/licenses/LICENSE-2.0                |
|                                                                             |
| Unless required by applicable law or agreed to in writing, software         |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT   |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.            |
| See the License for the specific language governing  permissions and        |
| limitations under the License.                                              |
+-----------------------------------------------------------------------------+
| Authors: Graham Charters, Matthew Peters                                    |
|                                                                             |
+-----------------------------------------------------------------------------+
$Id$
*/
include_once "../shop/Cart/cart.php";
include_once "../shop/customer.php";
include "SCA/SCA.php";
$order_id = 1170781589;
$warehouse = SCA::getService("../WarehouseService/WarehouseService.php");
$order = $warehouse->getOrder($order_id);
$warehouse->signalDispatched($order_id);
$event_log = SCA::getService('../EventLogService/EventLogService.php');
$event_log->logEvent($order, 'Order dispatched from warehouse: ' . $order->item[0]->warehouseId);
print_r($order);
Beispiel #11
0
-->

<html>
<title>SCA Component Using Data Structures</title>
<body>

<h3>SCA Component Using Data Structures</h3>

<?php 
require_once 'SCA/SCA.php';
echo '<p>Calling BatchService locally</p>';
echo '<p>Requesting WSDL from BatchService Component</p>';
$f = file_get_contents('http://localhost/examples/SCA/Soap/SCAComponentUsingDataStructures/BatchService.php?wsdl');
file_put_contents('BatchService.wsdl', $f);
// Get proxy for BatchService
$batch_service = SCA::getService('./BatchService.wsdl');
/*****************************************************************/
/* Creating an SDO to pass to the service.  This demonstrates    */
/* how a service proxy (in this casebatch_service) acts as a     */
/* 'factory for the data structures of the target service.       */
/*****************************************************************/
$namesSDO = $batch_service->createDataObject('http://example.org/names', 'people');
// Populate the names
$namesSDO->name[] = 'Cathy';
$namesSDO->name[] = 'Bertie';
$namesSDO->name[] = 'Fred';
$namesSDO->name[] = 'Anna';
// Call the batch service
$replies = $batch_service->sayHello($namesSDO);
// Write out the replies
echo '<p>Response:<br/>';
Beispiel #12
0
| Authors: Graham Charters, Matthew Peters                                    |
|                                                                             |
+-----------------------------------------------------------------------------+
$Id$
*/
include_once "display_cart.php";
include "SCA/SCA.php";
session_start();
?>
<html>
<head>
<title>Order Submission</title>
</head>
<body>
<?php 
$order_process = SCA::getService('../OrderProcessingService/OrderProcessingService.php');
/**
 * pick up the cart from the session
 */
//if (isset($_SESSION['cart'])) {
$cart = $_SESSION['cart'];
//} else {
//    echo 'you have jumped into the middle of a dialog here. Go back to <p><a href="welcome.php">Home</a></p>';
//    exit;
//}
$total = 0;
foreach ($cart->item as $item) {
    $total += $item->quantity * $item->price;
}
// We should 'clean' the posted data at this point
$customer = $order_process->createDataObject('urn::customerNS', 'CustomerType');
Beispiel #13
0
 public function testDeclarativeServiceUsingEbayBinding()
 {
     $this->markTestIncomplete('this test fails because the ebaysoap proxy is being passed the wrong value for immediate_caller_directory (bug in SCA::getService()');
     try {
         $ebay = SCA::getService('./eBayConsumer.php');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Exception thrown for valid declarative service: ' . $e->getMessage());
     }
 }
Beispiel #14
0
| All Rights Reserved.                                                 |
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: Graham Charters                                              |
+----------------------------------------------------------------------+
$Id$
*/
require_once 'SCA/SCA.php';
$dbservice = SCA::getService('contact', 'simpledb', array('config' => 'config/mysql_config.ini', 'case' => 'mixed'));
$contact = $dbservice->createDataObject('http://example.org', 'Contact');
$contact->Shortname = 'bertie';
$contact->Fullname = 'Bertie Bassett';
$contact->Email = '*****@*****.**';
$id = $dbservice->create($contact);
echo "Created: {$id}";
$contact = $dbservice->retrieve('bertie');
echo "Retrieved: " . $contact->Fullname;
$contact->Fullname = 'Bertie B Bassett';
$dbservice->update($contact->Shortname, $contact);
$dbservice->delete($contact->Shortname);
Beispiel #15
0
#!/usr/bin/php
<?php 
require_once dirname(__FILE__) . '/../server/CloudBankServer.php';
require_once dirname(__FILE__) . '/../server/SchemaDef.php';
require_once 'SCA/SCA.php';
foreach (SchemaDef::CreateSchemaStatements() as $v_dBObject => $v_sQLStatement) {
    CloudBankServer::Singleton()->tryQuery($v_sQLStatement);
}
$v_ledgerAccountService = SCA::getService(dirname(__FILE__) . '/../server/LedgerAccountService.php');
$v_ledgerAccountService->createBeginningAccount();
Beispiel #16
0
    return;
}
if (empty($_POST['from'])) {
    echo "<h3>No from email address passed to client.</h3></br>";
    return;
}
if (empty($_POST['subject'])) {
    echo "<h3>No subject passed to client.</h3></br>";
    return;
}
if (empty($_POST['message'])) {
    echo "<h3>No message passed to client.</h3></br>";
    return;
}
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];
include 'SCA/SCA.php';
$email_service = SCA::getService('./EmailService.wsdl');
$success = $email_service->send($to, $from, $subject, $message);
if (!$success) {
    echo '<h3>Failed to send email to: ' . $_POST['to'] . '</h3></br>';
} else {
    echo '<h3>Email sent to: ' . $_POST['to'] . '</h3></br>';
}
?>
</body>
</html>

Beispiel #17
0
#!/usr/bin/php

<?php 
#   require_once(dirname(__FILE__) . '/../server/
require_once 'SCA/SCA.php';
$v_eventService = SCA::getService('../server/EventService.php');
while (($v_record = fgetcsv(STDIN, 0, '|')) !== FALSE) {
    $v_eventService->createEvent($v_record[0], $v_record[1], $v_record[2], $v_record[3], $v_record[4]);
}
Beispiel #18
0
 public function testWrapperAndProxy()
 {
     $binding_config = array('wsdl' => dirname(__FILE__) . '/MS_TestServiceSDO_wsdl', 'replyto' => 'queue://testResponse');
     $ms_service = SCA::getService(dirname(__FILE__) . '/MS_TestServiceSDO_msd', "message", $binding_config);
     $namesSDO = $ms_service->createDataObject('http://example.org/names', 'people');
     // Populate the names
     $namesSDO->name[] = 'Cathy';
     $namesSDO->name[] = 'Bertie';
     $namesSDO->name[] = 'Fred';
     /*proxy send request*/
     $ms_service->setWaitResponseTimeout(-1);
     $ms_service->greetEveryone('hello', $namesSDO);
     /*warpper get request, process it, and send response */
     ob_start();
     SCA::initComponent("MS_TestServiceSDO.php");
     ob_end_clean();
     /*proxy get response*/
     $ms_service->setWaitResponseTimeout(0);
     $sdo = $ms_service->greetEveryone('hello', $namesSDO);
     $this->assertEquals('people', $sdo->getTypename());
     $this->assertEquals(3, sizeof($sdo->name));
 }
Beispiel #19
0
| limitations under the License.                                              |
+-----------------------------------------------------------------------------+
| Author: Graham Charters,                                                    |
|         Matthew Peters,                                                     |
|         Megan Beynon,                                                       |
|         Chris Miller,                                                       |
|         Caroline Maynard,                                                   |
|         Simon Laws,                                                         |
|         Rajini Sivaram                                                      |
+-----------------------------------------------------------------------------+
$Id$
*/
include_once "SCA/SCA.php";
try {
    $local_service = SCA::getService('./StockQuoteService.php');
    $remote_service = SCA::getService('http://localhost/examples/SCA/XmlRpc/StockQuoteService.php', "XmlRpc");
    /**
     * Call the component first locally then remotely, and compare
     * Normal paths first
     */
    echo '<p>Calling StockQuoteService locally</p><p>';
    echo $local_service->getQuote('IBM') . "\n";
    echo $local_service->getPreciseQuote('IBM') . "\n";
    echo $local_service->getQuoteFromExchange('IBM', 'NYSE') . "</p>\n";
    echo '<p>Calling StockQuoteService remotely</p><p>';
    echo $remote_service->getQuote('IBM') . "\n";
    echo $remote_service->getPreciseQuote('IBM') . "\n";
    echo $remote_service->getQuoteFromExchange('IBM', 'NYSE') . "</p>\n";
    /**
     * Call the component locally and remotely and compare results.
     * Ensure they are close (note that last call is 4.85 different)
Beispiel #20
0
Datei: SCA.php Projekt: psagi/sdo
 /**
  * THE OLD VERSION OF createInstanceAndFillInReferences(). INCLUDES
  * FUNCTIONALITY REQUIRED WHEN SCA IS RUNNING EMBEDDED IN TUSCANY SCA C++
  *
  * Instantiate the component, examine the annotations, find the dependencies,
  * call getService to create a proxy for each one, and assign to the
  * instance variables. The call(s) to getService may recurse back through here
  * if those dependencies also have dependencies
  *
  * @param string $class_name name of the class
  *
  * @return class instance
  */
 public static function createInstanceAndFillInReferences($class_name)
 {
     self::$logger->log("Entering");
     self::$logger->log("Class name of component to instantiate is {$class_name}");
     $instance = new $class_name();
     $reader = new SCA_AnnotationReader($instance);
     $references = $reader->reflectReferencesFull($instance);
     self::$logger->log("There are " . count($references) . " references to be filled in");
     $reflection = new ReflectionObject($instance);
     foreach ($references as $ref_name => $ref_type) {
         $ref_value = $ref_type->getBinding();
         self::$logger->log("Reference name = {$ref_name}, binding = {$ref_value}");
         $reference_proxy = null;
         if (self::$is_embedded) {
             $reference_proxy = new SCA_TuscanyProxy($ref_value);
         } else {
             if (SCA_Helper::isARelativePath($ref_value)) {
                 $ref_value = SCA_Helper::constructAbsolutePath($ref_value, $class_name);
             }
             $reference_proxy = SCA::getService($ref_value);
         }
         $prop = $reflection->getProperty($ref_name);
         // add the reference information to the proxy
         // this is added just in case there are any
         // extra types specified in the doc comment
         // for this reference
         $ref_type->addClassName($class_name);
         $reference_proxy->addReferenceType($ref_type);
         $prop->setValue($instance, $reference_proxy);
         // NB recursion here
     }
     self::$logger->log("Exiting");
     return $instance;
 }
Beispiel #21
0
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: Graham Charters                                              |
+----------------------------------------------------------------------+
$Id$
*/
include 'SCA/SCA.php';
$dbservice = SCA::getService('DbConsumer.php');
// Retrieving an existing one is the only way to get a data object at the moment
$contact = $dbservice->retrieve('charters');
$contact->shortname = 'bertie';
$contact->fullname = 'Bertie Bassett';
$contact->email = '*****@*****.**';
$id = $dbservice->create($contact);
echo "Created: {$id}";
$contact->fullname = 'Bertie B Bassett';
$dbservice->update($contact->shortname, $contact);
$contact = $dbservice->retrieve('bertie');
echo "Retrieved: {$contact->fullname}";
$dbservice->delete($contact->shortname);
Beispiel #22
0
|                                                                             |
| Unless required by applicable law or agreed to in writing, software         |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT   |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.            |
| See the License for the specific language governing  permissions and        |
| limitations under the License.                                              |
+-----------------------------------------------------------------------------+
| Authors: Graham Charters, Megan Beynon                                      |
|                                                                             |
+-----------------------------------------------------------------------------+
$Id$
-->

<html>
<title>Calling a remote SCA component using a PHP script.</title>
<body>

<h3>Calling a remote SCA component using a PHP script.</h3>

<?php 
require_once 'SCA/SCA.php';
echo '<p>Attempting to access HelloService, to trigger the automatic generation of WSDL for this component...</p>';
$f = file_get_contents('http://localhost/examples/SCA/Soap/ScriptCallingRemoteSCAComponent/HelloService.php?wsdl');
file_put_contents('HelloService.wsdl', $f);
echo '<p>Calling HelloService as a Web service...</p>';
$service = SCA::getService('./HelloService.wsdl');
echo '<p>Response: ' . $service->sayHello('Freddie') . '</p>';
?>

</body>
</html>
Beispiel #23
0
| of the License at -                                                         |
|                                                                             |
|                   http://www.apache.org/licenses/LICENSE-2.0                |
|                                                                             |
| Unless required by applicable law or agreed to in writing, software         |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT   |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.            |
| See the License for the specific language governing  permissions and        |
| limitations under the License.                                              |
+-----------------------------------------------------------------------------+
| Authors: Graham Charters, Megan Beynon                                      |
|                                                                             |
+-----------------------------------------------------------------------------+
$Id$
-->
<html>
<title>SCA Component calling local SCA Component</title>
<body>

<?php 
require_once 'SCA/SCA.php';
echo '<h3>Calling SurnameService locally</h3>';
// Get a proxy to the local service
$service = SCA::getService('./SurnameService.php');
// Call the service
echo '<p>Response: ' . $service->sayHello('Bertie') . '</p>';
?>

</body>
</html>
Beispiel #24
0
    return;
}
if (empty($_POST['from'])) {
    echo "<h3>No from email address passed to client.</h3></br>";
    return;
}
if (empty($_POST['subject'])) {
    echo "<h3>No subject passed to client.</h3></br>";
    return;
}
if (empty($_POST['message'])) {
    echo "<h3>No message passed to client.</h3></br>";
    return;
}
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];
include 'SCA/SCA.php';
$email_service = SCA::getService('ContactEmailService.php');
$success = $email_service->send($to, $from, $subject, $message);
if (!$success) {
    echo '<h3>Failed to send email to: ' . $_POST['to'] . '</h3></br>';
} else {
    echo '<h3>Email sent to: ' . $_POST['to'] . '</h3></br>';
}
?>
</body>
</html>

Beispiel #25
0
| All Rights Reserved.                                                 |
+----------------------------------------------------------------------+
|                                                                      |
| Licensed under the Apache License, Version 2.0 (the "License"); you  |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at                                      |
| http://www.apache.org/licenses/LICENSE-2.0                           |
|                                                                      |
| Unless required by applicable law or agreed to in writing, software  |
| distributed under the License is distributed on an "AS IS" BASIS,    |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
| implied. See the License for the specific language governing         |
| permissions and limitations under the License.                       |
+----------------------------------------------------------------------+
| Author: Graham Charters                                              |
+----------------------------------------------------------------------+
$Id$
*/
require_once 'SCA/SCA.php';
$dbservice = SCA::getService('CHARTERS.CONTACT', 'simpledb', array('config' => 'config/db2_config.ini'));
$contact = $dbservice->createDataObject('http://example.org', 'contact');
$contact->shortname = 'bertie';
$contact->fullname = 'Bertie Bassett';
$contact->email = '*****@*****.**';
$id = $dbservice->create($contact);
echo "Created: {$id}";
$contact = $dbservice->retrieve('bertie');
echo "Retrieved: " . $contact->fullname;
$contact->fullname = 'Bertie B Bassett';
$dbservice->update($contact->shortname, $contact);
$dbservice->delete($contact->shortname);
Beispiel #26
0
<?php

include_once "SCA/SCA.php";
$contact_service = SCA::getService('Contact.php');
$contact = $contact_service->retrieve(1);
echo '<p>';
print_r($contact);
echo '<p/>';
$id = $contact_service->create($contact);
echo '<p>';
echo 'Created: ' . $id;
echo '<p/>';
if ($contact_service->delete($id)) {
    echo 'DELETED';
}
echo '<p>';
print_r($contact);
echo '<p/>';
date_default_timezone_set('Europe/London');
$contact->updated = date('Y-m-j G-i-s');
$contact->shortname = "Fred";
echo '<p>';
if ($contact_service->update(1, $contact)) {
    echo 'UPDATED';
}
echo '</p>';
echo '<p>';
if ($contacts = $contact_service->enumerate()) {
    echo 'Returned ' . count($contacts->contact) . ' contacts.';
}
echo '</p>';
Beispiel #27
0
| All Rights Reserved.                                                        |
+-----------------------------------------------------------------------------+
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License. You may obtain a copy  |
| of the License at -                                                         |
|                                                                             |
|                   http://www.apache.org/licenses/LICENSE-2.0                |
|                                                                             |
| Unless required by applicable law or agreed to in writing, software         |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT   |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.            |
| See the License for the specific language governing  permissions and        |
| limitations under the License.                                              |
+-----------------------------------------------------------------------------+
| Authors: Graham Charters, Megan Beynon                                      |
|                                                                             |
+-----------------------------------------------------------------------------+
$Id$
-->
<html>
<title>Script calling a local SCA component</title>
<?php 
require_once 'SCA/SCA.php';
echo '<h3>Calling HelloService locally</h3>';
// Get a proxy to the local HelloService
$service = SCA::getService('./HelloService.php');
// Call the local service and write out the response
echo '<p>Response: ' . $service->sayHello('Bertie') . '</p>';
?>
</html>
Beispiel #28
0
 public function testRelativeTargetCorrectlyResolvedForComponentThreeDeepAndOneDown()
 {
     $service = SCA::getService('./downone/hello4.php', 'local');
     $this->assertContains("hello", $service->hello());
 }
Beispiel #29
0
<?php 
require_once 'SCA/SCA.php';
echo "<p>Attempting to access MailApplicationService, to trigger the automatic generation of SMD for this component...</p>\n";
$f = file_get_contents('http://localhost/examples/SCA/JsonRpc/MailApplicationService.php?smd');
// write contents locally to get round the SCA cache
file_put_contents("MailApplicationService.smd", $f);
echo "<p>Attempting to access EmailService, to trigger the automatic generation of SMD for this component...</p>\n";
$f = file_get_contents('http://localhost/examples/SCA/JsonRpc/EmailService.php?smd');
// write contents locally to get round the SCA cache
file_put_contents("EmailService.smd", $f);
echo "<p>Attempting to access WebService, to trigger the automatic generation of WSDL for this component...</p>\n";
$f = file_get_contents('http://localhost/examples/SCA/JsonRpc/WebService.php?wsdl');
// write contents locally to get round the SCA cache
file_put_contents("WebService.wsdl", $f);
echo "<p>Calling MailApplicationService as a json rpc service...</p>\n";
$service = SCA::getService('./MailApplicationService.smd');
echo "<p>Response to sendMessage: " . $service->sendMessage("abc", "xyz") . "</p>\n";
echo "<p>Response to sendComplexMessage: " . $service->sendComplexMessage("abc", "xyz") . "</p>\n";
// need to do a bit of work on this as the infrastructure is currently
// unable to return an SDO based on an SMD. So we have to do some unatural stuff
// make the JSON proxy create a JSON DAS
$reference = new SCA_ReferenceType();
$service->addReferenceType($reference);
// Manually create and SDO
$xmldas = SDO_DAS_XML::create();
$xmldas->addTypes("email.xsd");
$email = $xmldas->createDataObject("http://www.example.org/email", "EmailType");
$email->address = "*****@*****.**";
$email->message = "some message";
echo "<p>Response to sendComplexMessagePassthrough: ";
print_r($service->sendComplexMessagePassthrough($email));
Beispiel #30
0
<html>
<body>
<?php 
include 'SCA/SCA.php';
date_default_timezone_set('Europe/London');
/***********************************************/
/* Get the component which calls the Atom feed */
/***********************************************/
$contact_service = SCA::getService('ContactFeedConsumer.php');
/***********************************************/
/* Create an XML entry and send it to the      */
/* Atom component via the ContactFeedConsumer. */
/***********************************************/
echo '<p>';
echo '<b>Testing Create<br/></b>';
echo '<p>This is the XML we are going to send';
$entryXML = create_entry();
echo '<pre>';
write_entry_xml($entryXML);
echo '</pre>';
$entry = $contact_service->create($entryXML);
// Write out the response (the id should have been
// changed to that of the database.
echo '<b><br/>Response from create (the id should be different)<br/></b>';
echo '<pre>';
write_entry($entry);
echo '</pre>';
echo '</p>';
echo '<p>';
// Remember the id because we will delete it later
// I would like to just get the id value, but it is the uri