/** * Constructor. Calls the parent SOAP_WSDL constructor to parse the WSDL. * * @param optional string $wsdl The WSDL. Defaults to what's bundled * with the SDK. */ function PayPal_SDK_Generator($wsdl = null) { if (is_null($wsdl)) { $wsdl = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'wsdl' . DIRECTORY_SEPARATOR . 'PayPalSvc.wsdl'; } parent::SOAP_WSDL($wsdl, array(), WSDL_CACHE_USE, WSDL_CACHE_MAX_AGE, true); }
function smarty_function_amazon($params, &$smarty) { if (empty($params['var'])) { $smarty->trigger_error("assign: missing 'var' parameter"); return; } if (empty($params['asin'])) { $smarty->trigger_error("assign: missing 'asin' parameter"); return; } $wsdl_url = 'http://webservices.amazon.com/AWSECommerceService/DE/AWSECommerceService.wsdl'; $wsdl_url = 'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl'; $WSDL = new SOAP_WSDL($wsdl_url); $client = $WSDL->getProxy(); $p = array('ItemId' => trim(str_replace('-', '', $params['asin'])), 'IdType' => 'ASIN', 'tag' => 'wwwdilpsnet-21', 'devtag' => '1XKHV6RJW6ZE3BKMTYR2'); $book = $client->ItemLookup($p); print_r($book); $smarty->assign($params['var'], $book); }
private function get_soap_wsdl_client($url) { // Hier kann man das wsdl Cashing von PHP ausschalten // ini_set("soap.wsdl_cache_enabled", "0"); $wsdl = new SOAP_WSDL($url); $soap = $wsdl->getProxy(); if ($url == PIA_URL) { $soap->setOpt('curl', CURLOPT_CAINFO, PATH_CERTS . 'telekom-root-ca-2.pem'); $soap->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 1); $soap->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 2); } else { $soap->setOpt('curl', CURLOPT_CAINFO, PATH_CERTS . 'paul_certs.pem'); $soap->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); // must be 1 in productive environment $soap->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); // must be 2 in productive envoronment } return $soap; }
} if (!@(include 'SOAP' . DIRECTORY_SEPARATOR . 'Client.php')) { die('You must have PEAR::SOAP installed'); } // Just to save manaul modification... $basePath = explode('/', $_SERVER['SCRIPT_NAME']); array_pop($basePath); $basePath = implode('/', $basePath); $url = 'http://' . $_SERVER['SERVER_NAME'] . $basePath . '/7.php?wsdl'; if (!isset($_GET['y'])) { $_GET['y'] = date('Y'); } if (!isset($_GET['m'])) { $_GET['m'] = date('n'); } $wsdl = new SOAP_WSDL($url); echo '<pre>' . $wsdl->generateProxyCode() . '</pre>'; $calendarClient = $wsdl->getProxy(); $month = $calendarClient->getMonth((int) $_GET['y'], (int) $_GET['m']); if (PEAR::isError($month)) { die($month->toString()); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> Calendar over the Wire </title> </head> <body> <h1>Calendar Over the Wire (featuring PEAR::SOAP)</h1> <table>
// | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Shane Caraveo <*****@*****.**> Port to PEAR and more | // | Authors: Dietrich Ayala <*****@*****.**> Original Author | // +----------------------------------------------------------------------+ // // $Id: stockquote.php,v 1.7 2005/03/10 23:16:40 yunosh Exp $ // // include soap client class include "SOAP/Client.php"; print "<br>\n<strong>wsdl:</strong>"; $wsdl = new SOAP_WSDL("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"); $soapclient = $wsdl->getProxy(); print_r($soapclient->getQuote("ibm")); print "\n\n"; if (extension_loaded('overload')) { print "\n<br><strong>overloaded:</strong>"; $ret = $soapclient->getQuote("ibm"); print_r($ret); print "\n\n"; } unset($soapclient); print "\n<br><strong>non wsdl:</strong>"; $soapclient = new SOAP_Client("http://services.xmethods.net:80/soap"); $namespace = "urn:xmethods-delayed-quotes"; /** * some soap servers require a Soapaction http header. PEAR::SOAP does
/** * Searches for the album cover in Amazon * * @access public * @param string $Artist Artist to search for * @param string $Album Album to search for * @return string Name of the album image */ function GetAlbumCoverFromAmazon($Artist, $Album) { $wsdl = 'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl'; require_once PEAR_PATH . 'SOAP/Client.php'; $service = new SOAP_WSDL($wsdl); $page = 1; $proxy = $service->getProxy(); $devtag = $GLOBALS['app']->Registry->fetch('devtag', 'AlbumCover'); $params = array('artist' => htmlentities($Artist), 'keywords' => htmlentities($Album), 'mode' => 'music', 'page' => $page, 'tag' => 'webservices-20', 'devtag' => $devtag, 'type' => 'lite'); $result = $proxy->ArtistSearchRequest($params); $pages = isset($result->TotalPages) ? $result->TotalPages : 0; $bestMatch = ''; $lowerArtist = $this->ToLowerWithoutSpaces($Artist); $lowerAlbum = $this->ToLowerWithoutSpaces($Album); while ($page <= $pages) { foreach ($result->Details as $r) { if ($this->ToLowerWithoutSpaces($r->ProductName) == $lowerAlbum) { foreach ($r->Artists as $a) { if ($this->ToLowerWithoutSpaces($a) == $lowerArtist) { $bestMatch = $r->ImageUrlMedium; break 3; } } } } $params['page'] = $page++; $result = $proxy->ArtistSearchRequest($params); } return $bestMatch; }
<?php // PEAR::SOAP require 'SOAP/Client.php'; // Description of the API $wsdl_url = 'WhoisData.wsdl'; $WSDL = new SOAP_WSDL($wsdl_url); // Fetch supported types & methods $whois = $WSDL->getProxy(); // make an array of parameters we need to pass $params = array('domain' => 'php.net', 'clientID' => '1234', 'emailAddress' => '*****@*****.**'); // Send whois request for php.net $result = $whois->getWhoisData($params);
<?php require_once 'SOAP/Client.php'; $key = 'cSlFdvpQFHIiGEpLTO2YzQq55k1G4519'; $query = '"Sterling Hughes"'; $wsdlurl = 'GoogleSearch.wsdl'; $WSDL = new SOAP_WSDL($wsdlurl); $client = $WSDL->getProxy(); $response = $client->doGoogleSearch($key, $query, 0, 10, false, '', false, '', '', ''); foreach ($response->resultElements as $result) { echo str_repeat(' ', 40); strip_html($result->title); echo "{$result->title}\n"; echo str_repeat(' ', 40); echo "({$result->URL})\n"; echo "\n"; strip_html($result->snippet); echo $result->snippet; echo "\n\n"; } function strip_html(&$text) { $text = preg_replace('/<.*?>/', '', $text); }
/** * genproxy * * a command line tool for generating SOAP proxies from WSDL files * * genproxy.php http://site/foo.wsdl > foo.php * */ function do_wsdl($uri) { $wsdl = new SOAP_WSDL($uri); print $wsdl->generateAllProxies(); }
/** * Makes SOAP request to google * */ private function _googleSoap($query, $start = 0, $max = 10, $filter = false, $restrict = "", $safe = false, $lr = "", $ie = "", $oe = "") { $wsdl = new SOAP_WSDL('http://api.google.com/GoogleSearch.wsdl'); $soapclient = $wsdl->getProxy(); if (get_class($soapclient) != "SOAP_Fault") { $result = $soapclient->doGoogleSearch($this->Key, $query, $start, $max, $filter, $restrict, $safe, $lr, $ie, $oe); } else { throw new Exception("SOAP_Fault: " . $soapclient->message); } if (PEAR::isError($result)) { throw new Exception("PEAR Exception: " . $result->message); } else { return $result; } }
<?php require 'SOAP/Client.php'; echo date('Y-m-d H:i:s') . "\n\n"; // Descripcion de la API $wsdl_url = 'http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl'; $WSDL = new SOAP_WSDL($wsdl_url); // Generemos un proxy local $proxy = $WSDL->getProxy(); // Busquemos el factor de conversion de // dolares a euros $result = $proxy->getRate('usa', 'euro'); echo "Multiplicar dolares por {$result} para tener euros\n"; // soles a marcos $result = $proxy->getRate('peru', 'germany'); echo "Multiplicar soles por {$result} para tener marcos\n"; // Convertir 100 euros a yuen $result = $proxy->getRate('euro', 'china'); echo "100 euros son " . 100 * $result . " yuan\n";
<?php require_once 'SOAP/Client.php'; $wsdlurl = 'BabelFishService.wsdl'; $WSDL = new SOAP_WSDL($wsdlurl); $babel = $WSDL->getProxy(); echo $babel->BabelFish('de_en', 'Unser erstes SOAP Beispiel');
<?php require_once 'SOAP/Client.php'; $wsdl = new SOAP_WSDL('CarRentalQuotes.wsdl'); echo $wsdl->generateProxyCode();
public function __construct() { $wsdl = new SOAP_WSDL(self::WSDL_URL); $this->soap_client = $wsdl->getProxy(); }