SOAP_Interop
[ class tree: SOAP_Interop ] [ index: SOAP_Interop ] [ all elements ]

Source for file registrationAndNotification.php

Documentation is available at registrationAndNotification.php

  1. <?php
  2. require_once 'DB.php'// PEAR/DB
  3. require_once 'SOAP/Client.php';
  4. require_once 'config.php';
  5.  
  6. class clientInfo {
  7.     var $name;
  8.     var $version;
  9.     var $resultsURL;
  10.  
  11.     function clientInfo($ar=NULL{
  12.         if (is_array($ar)) {
  13.             foreach ($ar as $k=>$v{
  14.                 $this->$k $v;
  15.             }
  16.         }
  17.     }
  18. }
  19.  
  20. class serverInfo {
  21.     var $id;
  22.     var $service_id;
  23.     var $name;
  24.     var $version;
  25.     var $endpointURL;
  26.     var $wsdlURL;
  27.  
  28.     function serverInfo($ar=NULL{
  29.         if (is_array($ar)) {
  30.             foreach ($ar as $k=>$v{
  31.                 $this->$k $v;
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37. class Service {
  38.     var $id;
  39.     var $name;
  40.     var $description;
  41.     var $wsdlURL;
  42.     var $websiteURL;
  43.  
  44.     function Service($ar=NULL{
  45.         if (is_array($ar)) {
  46.             foreach ($ar as $k=>$v{
  47.                 $this->$k $v;
  48.             }
  49.         }
  50.     }
  51. }
  52.  
  53. class subscriberInfo {
  54.     var $notificationID;
  55.     var $expires/* dateTime */
  56. }
  57.  
  58. class ChangeItem {
  59.     var $id;
  60.     var $timestamp/* dateTime */
  61.     var $headline;
  62.     var $notes;
  63.     var $url;
  64. }
  65.  
  66. function getLocalInteropServer($testname,$id,$localBaseUrl='http://localhost/soap_interop/'{
  67.     $localServer = array();
  68.     $localServer['service_id']=$id;
  69.     $localServer['name']='Local PEAR::SOAP';
  70.     $localServer['version']=SOAP_LIBRARY_VERSION;
  71.     switch ($testname{
  72.     case 'Round 2 Base':
  73.         $localServer['endpointURL']=$localBaseUrl.'server_Round2Base.php';
  74.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/interop.wsdl.php';
  75.         return new serverInfo($localServer);
  76.     case 'Round 2 Group B':
  77.         $localServer['endpointURL']=$localBaseUrl.'server_Round2GroupB.php';
  78.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/interopB.wsdl.php';
  79.         return new serverInfo($localServer);
  80.     case 'Round 2 Group C':
  81.         $localServer['endpointURL']=$localBaseUrl.'server_Round2GroupC.php';
  82.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/echoheadersvc.wsdl.php';
  83.         return new serverInfo($localServer);
  84.     case 'Round 3 Group D EmptySA':
  85.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDEmptySA.php';
  86.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/emptysa.wsdl.php';
  87.         return new serverInfo($localServer);
  88.     case 'Round 3 Group D Compound 1':
  89.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDCompound1.php';
  90.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/compound1.wsdl.php';
  91.         return new serverInfo($localServer);
  92.     case 'Round 3 Group D Compound 2':
  93.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDCompound2.php';
  94.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/compound2.wsdl.php';
  95.         return new serverInfo($localServer);
  96.     case 'Round 3 Group D DocLit':
  97.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDDocLit.php';
  98.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/InteropTestDocLit.wsdl.php';
  99.         return new serverInfo($localServer);
  100.     case 'Round 3 Group D DocLitParams':
  101.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDDocLitParams.php';
  102.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/InteropTestDocLitParameters.wsdl.php';
  103.         return new serverInfo($localServer);
  104.     case 'Round 3 Group D Import 1':
  105.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDImport1.php';
  106.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/import1.wsdl.php';
  107.         return new serverInfo($localServer);
  108.     case 'Round 3 Group D Import 2':
  109.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDImport2.php';
  110.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/import2.wsdl.php';
  111.         return new serverInfo($localServer);
  112.     case 'Round 3 Group D Import 3':
  113.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDImport3.php';
  114.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/import3.wsdl.php';
  115.         return new serverInfo($localServer);
  116.     case 'Round 3 Group D RpcEnc':
  117.         $localServer['endpointURL']=$localBaseUrl.'server_Round3GroupDRpcEnc.php';
  118.         $localServer['wsdlURL']=$localBaseUrl.'wsdl/InteropTestRpcEnc.wsdl.php';
  119.         return new serverInfo($localServer);
  120.     #case 'Round 3 Group E DocLit':
  121.     #case 'Round 3 Group E RpcEnc':
  122.     #case 'Round 3 Group F Extensibility':
  123.     #case 'Round 3 Group F ExtensibilityRequired':
  124.     #case 'Round 3 Group F Headers':
  125.     #case 'Round 4 DIME/Doc Attachments':
  126.     #case 'Round 4 DIME/RPC Attachments':
  127.     #case 'Round 4 MIME/Doc Attachments':
  128.     #case 'Round 4 SwA/RPC Attachments':
  129.     }
  130.     return NULL;
  131. }
  132.  
  133. class SOAP_Interop_registrationAndNotificationService_ServicesPort extends SOAP_Client {
  134.     function SOAP_Interop_registrationAndNotificationService_ServicesPort({
  135.         $this->SOAP_Client("http://soap.4s4c.com/registration/soap.asp"0);
  136.         $this->_auto_translation = true;
  137.     }
  138.     function &ServiceList({
  139.         return $this->call("ServiceList"
  140.                         $v = NULL
  141.                         array('namespace'=>'http://soap.pocketsoap.com/registration/services',
  142.                             'soapaction'=>'http://soap.pocketsoap.com/registration/services#ServiceList',
  143.                             'style'=>'rpc',
  144.                             'use'=>'encoded'))
  145.     }
  146.     function &Servers($serviceID{
  147.         return $this->call("Servers"
  148.                         $v = array("serviceID"=>$serviceID)
  149.                         array('namespace'=>'http://soap.pocketsoap.com/registration/services',
  150.                             'soapaction'=>'http://soap.pocketsoap.com/registration/services#Servers',
  151.                             'style'=>'rpc',
  152.                             'use'=>'encoded'))
  153.     }
  154.     function &Clients($serviceID{
  155.         return $this->call("Clients"
  156.                         $v = array("serviceID"=>$serviceID)
  157.                         array('namespace'=>'http://soap.pocketsoap.com/registration/services',
  158.                             'soapaction'=>'http://soap.pocketsoap.com/registration/services#Clients',
  159.                             'style'=>'rpc',
  160.                             'use'=>'encoded'))
  161.     }
  162. }
  163. class SOAP_Interop_registrationAndNotificationService_ClientsPort extends SOAP_Client {
  164.     function SOAP_Interop_registrationAndNotificationService_ClientsPort({
  165.         $this->SOAP_Client("http://soap.4s4c.com/registration/soap.asp"0);
  166.         $this->_auto_translation = true;
  167.     }
  168.     function &RegisterClient($serviceID$clientInfo{
  169.         return $this->call("RegisterClient"
  170.                         $v = array("serviceID"=>$serviceID"clientInfo"=>$clientInfo)
  171.                         array('namespace'=>'http://soap.pocketsoap.com/registration/clients',
  172.                             'soapaction'=>'http://soap.pocketsoap.com/registration/clients#RegisterClient',
  173.                             'style'=>'rpc',
  174.                             'use'=>'encoded'))
  175.     }
  176.     function &UpdateClient($clientID$clientInfo{
  177.         return $this->call("UpdateClient"
  178.                         $v = array("clientID"=>$clientID"clientInfo"=>$clientInfo)
  179.                         array('namespace'=>'http://soap.pocketsoap.com/registration/clients',
  180.                             'soapaction'=>'http://soap.pocketsoap.com/registration/clients#UpdateClient',
  181.                             'style'=>'rpc',
  182.                             'use'=>'encoded'))
  183.     }
  184.     function &RemoveClient($clientID{
  185.         return $this->call("RemoveClient"
  186.                         $v = array("clientID"=>$clientID)
  187.                         array('namespace'=>'http://soap.pocketsoap.com/registration/clients',
  188.                             'soapaction'=>'http://soap.pocketsoap.com/registration/clients#RemoveClient',
  189.                             'style'=>'rpc',
  190.                             'use'=>'encoded'))
  191.     }
  192. }
  193. class SOAP_Interop_registrationAndNotificationService_ServersPort extends SOAP_Client {
  194.     function SOAP_Interop_registrationAndNotificationService_ServersPort({
  195.         $this->SOAP_Client("http://soap.4s4c.com/registration/soap.asp"0);
  196.         $this->_auto_translation = true;
  197.     }
  198.     function &RegisterServer($serviceID$serverInfo{
  199.         return $this->call("RegisterServer"
  200.                         $v = array("serviceID"=>$serviceID"serverInfo"=>$serverInfo)
  201.                         array('namespace'=>'http://soap.pocketsoap.com/registration/servers',
  202.                             'soapaction'=>'http://soap.pocketsoap.com/registration/servers#RegisterServer',
  203.                             'style'=>'rpc',
  204.                             'use'=>'encoded'))
  205.     }
  206.     function &UpdateServer($serverID$serverInfo{
  207.         return $this->call("UpdateServer"
  208.                         $v = array("serverID"=>$serverID"serverInfo"=>$serverInfo)
  209.                         array('namespace'=>'http://soap.pocketsoap.com/registration/servers',
  210.                             'soapaction'=>'http://soap.pocketsoap.com/registration/servers#UpdateServer',
  211.                             'style'=>'rpc',
  212.                             'use'=>'encoded'))
  213.     }
  214.     function &RemoveServer($serverID{
  215.         return $this->call("RemoveServer"
  216.                         $v = array("serverID"=>$serverID)
  217.                         array('namespace'=>'http://soap.pocketsoap.com/registration/servers',
  218.                             'soapaction'=>'http://soap.pocketsoap.com/registration/servers#RemoveServer',
  219.                             'style'=>'rpc',
  220.                             'use'=>'encoded'))
  221.     }
  222. }
  223. class SOAP_Interop_registrationAndNotificationService_SubscriberPort extends SOAP_Client {
  224.     function SOAP_Interop_registrationAndNotificationService_SubscriberPort({
  225.         $this->SOAP_Client("http://soap.4s4c.com/registration/soap.asp"0);
  226.         $this->_auto_translation = true;
  227.     }
  228.     function &Subscribe($serviceID$ServerChanges$ClientChanges$NotificationURL{
  229.         return $this->call("Subscribe"
  230.                         $v = array("serviceID"=>$serviceID"ServerChanges"=>$ServerChanges"ClientChanges"=>$ClientChanges"NotificationURL"=>$NotificationURL)
  231.                         array('namespace'=>'http://soap.pocketsoap.com/registration/subscriber',
  232.                             'soapaction'=>'http://soap.pocketsoap.com/registration/subscriber#Subscribe',
  233.                             'style'=>'rpc',
  234.                             'use'=>'encoded'))
  235.     }
  236.     function &Renew($notificationID{
  237.         return $this->call("Renew"
  238.                         $v = array("notificationID"=>$notificationID)
  239.                         array('namespace'=>'http://soap.pocketsoap.com/registration/subscriber',
  240.                             'soapaction'=>'http://soap.pocketsoap.com/registration/subscriber#Renew',
  241.                             'style'=>'rpc',
  242.                             'use'=>'encoded'))
  243.     }
  244.     function &Cancel($notificationID{
  245.         return $this->call("Cancel"
  246.                         $v = array("notificationID"=>$notificationID)
  247.                         array('namespace'=>'http://soap.pocketsoap.com/registration/subscriber',
  248.                             'soapaction'=>'http://soap.pocketsoap.com/registration/subscriber#Cancel',
  249.                             'style'=>'rpc',
  250.                             'use'=>'encoded'))
  251.     }
  252. }
  253. class SOAP_Interop_registrationAndNotificationService_ChangeLogPort extends SOAP_Client {
  254.     function SOAP_Interop_registrationAndNotificationService_ChangeLogPort({
  255.         $this->SOAP_Client("http://soap.4s4c.com/registration/soap.asp"0);
  256.         $this->_auto_translation = true;
  257.     }
  258.     function &RecentChanges($MaxEntries{
  259.         return $this->call("RecentChanges"
  260.                         $v = array("MaxEntries"=>$MaxEntries)
  261.                         array('namespace'=>'http://soap.pocketsoap.com/registration/changeLog',
  262.                             'soapaction'=>'http://soap.pocketsoap.com/registration/changeLog#RecentChanges',
  263.                             'style'=>'rpc',
  264.                             'use'=>'encoded'))
  265.     }
  266. }
  267.  
  268. class SOAP_Interop_registrationDB {
  269.     var $DSN;
  270.     var $dbc = NULL;
  271.     
  272.     var $client// soap_client
  273.     var $services;
  274.     var $currentServiceId;
  275.     var $servers;
  276.     var $clients;
  277.     
  278.     function SOAP_Interop_registrationDB()
  279.     {
  280.         global $interopConfig;
  281.     $this->DSN $interopConfig['DSN'];
  282.         $this->client =new SOAP_Interop_registrationAndNotificationService_ServicesPort();
  283.         $this->connectDB();
  284.         $this->getServiceList();
  285.     }
  286.     
  287.     function connectDB()
  288.     {
  289.         if (!$this->dbc)
  290.             $this->dbc =DB::connect($this->DSNtrue);
  291.         if (PEAR::isError($this->dbc)) {
  292.             echo $this->dbc->getMessage();
  293.             $this->dbc = NULL;
  294.             return false;
  295.         }
  296.         return true;
  297.     }
  298.     
  299.     function updateDB()
  300.     {
  301.         $this->updateServiceDb();
  302.         $this->updateServerDb();
  303.         $this->updateClientsDb();
  304.     }
  305.     
  306.     function &retreiveServiceList()
  307.     {
  308.         if (!$this->services{
  309.             $this->services =$this->client->ServiceList();
  310.         }
  311.         return $this->services;
  312.     }
  313.     
  314.     function &retreiveServerList($serviceID)
  315.     {
  316.         if (!$this->servers || $this->currentServiceId != $serviceID{
  317.             $this->currentServiceId $serviceID;
  318.             $this->servers =$this->client->Servers($serviceID);
  319.         }
  320.         return $this->servers;
  321.     }
  322.     
  323.     function &retreiveClientList($serviceID)
  324.     {
  325.         if (!$this->clients || $this->currentServiceId != $serviceID{
  326.             $this->currentServiceId $serviceID;
  327.             $this->clients =$this->client->Clients($serviceID);
  328.         }
  329.         return $this->clients;
  330.     }
  331.     
  332.     function updateServiceDb()
  333.     {
  334.         if (!$this->connectDB()) return false;
  335.         $this->retreiveServiceList();
  336.         echo "Updating Services\n";
  337.         foreach ($this->services as $service{
  338.             $res $this->dbc->getRow("select id from services where id='{$service->id}'");
  339.             if ($res && !PEAR::isError($res)) {
  340.                 $res $this->dbc->query("update services set name='{$service->name}',".
  341.                                          "description='{$service->description}',wsdlURL='{$service->wsdlURL}',".
  342.                                          "websiteURL='{$service->websiteURL}' where id='{$service->id}'");
  343.             else {
  344.                 $res $this->dbc->query("insert into services (id,name,description,wsdlURL,websiteURL) ".
  345.                                          "values('{$service->id}','{$service->name}','{$service->description}','{$service->wsdlURL}','{$service->websiteURL}')");
  346.             }
  347.         }
  348.     }
  349.  
  350.     function _updateOrAddServer($id$server{
  351.         $res $this->dbc->getRow("select * from serverinfo where service_id='$id' and name='{$server->name}'");
  352.         if ($res && !PEAR::isError($res)) {
  353.             $res $this->dbc->query("update serverinfo set ".
  354.                                         "version='{$server->version}', ".
  355.                                         "endpointURL='{$server->endpointURL}', ".
  356.                                         "wsdlURL='{$server->wsdlURL}' where id={$res->id}");
  357.         else {
  358.             $res $this->dbc->query("insert into serverinfo (service_id,name,version,endpointURL,wsdlURL) ".
  359.                                         "values('$id','{$server->name}','{$server->version}','{$server->endpointURL}','{$server->wsdlURL}')");
  360.         }
  361.         if (PEAR::isError($res)) {
  362.             echo $res->toString("\n";
  363.         }
  364.     }
  365.     
  366.     function updateServerDb()
  367.     {
  368.         global $INTEROP_LOCAL_SERVER;
  369.         if (!$this->connectDB()) return false;
  370.         $this->retreiveServiceList();
  371.         $c count($this->services);
  372.         for ($i=0;$i<$c;$i++{
  373.             $this->retreiveServerList($this->services[$i]->id);
  374.             echo "Updating Servers for {$this->services[$i]->name}\n";
  375.             if (!$this->serverscontinue;
  376.             foreach ($this->servers as $server{
  377.                 $this->_updateOrAddServer($this->services[$i]->id$server);
  378.             }
  379.             // add the local server now
  380.             if ($INTEROP_LOCAL_SERVER{
  381.                 $server getLocalInteropServer($this->services[$i]->name$this->services[$i]->id);
  382.                 if ($server{
  383.                     $this->_updateOrAddServer($this->services[$i]->id$server);
  384.                 }
  385.             }
  386.         }
  387.     }    
  388.  
  389.     function updateClientsDb()
  390.     {
  391.         if (!$this->connectDB()) return false;
  392.         $this->retreiveServiceList();
  393.         foreach ($this->services as $service{
  394.             $this->retreiveClientList($service->id);
  395.             echo "Updating Clients for {$service->name}\n";
  396.             if (!$this->clientscontinue;
  397.             foreach ($this->clients as $client{
  398.                 $res $this->dbc->getRow("select id from clientinfo where id='{$service->id}' and name='{$client->name}'");
  399.                 if ($res && !PEAR::isError($res)) {
  400.                     $res $this->dbc->query("update clientinfo set ".
  401.                                              "version='{$client->version}', ".
  402.                                              "resultsURL='{$client->resultsURL}' where ".
  403.                                              "id='{$service->id}',name='{$client->name}'");
  404.                 else {
  405.                     $res $this->dbc->query("insert into clientinfo (id,name,version,resultsURL) ".
  406.                                              "values('{$service->id}','{$client->name}','{$client->version}','{$client->resultsURL}')");
  407.                 }
  408.                 
  409.             }
  410.         }
  411.     }
  412.     
  413.     function &getServiceList($forcefetch=FALSE)
  414.     {
  415.         if (!$forcefetch && !$this->services{
  416.             $this->dbc->setFetchMode(DB_FETCHMODE_OBJECT,'Service');
  417.             $this->services $this->dbc->getAll('select * from services',NULLDB_FETCHMODE_OBJECT );
  418.         }
  419.         if ($forcefetch || !$this->services{
  420.             $this->updateServiceDb();
  421.         }
  422.         return $this->services;
  423.     }
  424.     
  425.     function &getServerList($serviceID,$forcefetch=FALSE)
  426.     {
  427.         if (!$forcefetch && (!$this->servers || $this->currentServiceId != $serviceID)) {
  428.             $this->dbc->setFetchMode(DB_FETCHMODE_OBJECT,'serverInfo');
  429.             $this->servers $this->dbc->getAll("select * from serverinfo where service_id = '$serviceID'",NULLDB_FETCHMODE_OBJECT );
  430.         }
  431.         if ($forcefetch || !$this->servers{
  432.             $this->updateServerDb();
  433.             $this->dbc->setFetchMode(DB_FETCHMODE_OBJECT,'serverInfo');
  434.             $this->servers $this->dbc->getAll("select * from serverinfo where service_id = '$serviceID'",NULLDB_FETCHMODE_OBJECT );
  435.             if (!$this->servers{
  436.                 die("Error retrieving server list!\n");
  437.             }
  438.         }
  439.         return $this->servers;        
  440.     }    
  441.  
  442.     function &getClientList($serviceID,$forcefetch=FALSE)
  443.     {
  444.         if (!$forcefetch && (!$this->clients || $this->currentServiceId != $serviceID)) {
  445.             $this->dbc->setFetchMode(DB_FETCHMODE_OBJECT,'clientInfo');
  446.             $this->clients $this->dbc->getAll("select * from clientinfo where id = '$serviceID'",NULLDB_FETCHMODE_OBJECT );
  447.         }
  448.         if ($forcefetch || !$this->clients{
  449.             $this->updateClientDb();
  450.             $this->dbc->setFetchMode(DB_FETCHMODE_OBJECT,'clientInfo');
  451.             $this->clients $this->dbc->getAll("select * from clientinfo where id = '$serviceID'",NULLDB_FETCHMODE_OBJECT );
  452.             if (!$this->clients{
  453.                 die("Error retrieving client list!\n");
  454.             }
  455.         }
  456.         return $this->clients;        
  457.     }
  458.     
  459.     function &findService($serviceName)
  460.     {
  461.         $this->getServiceList();
  462.         $c count($this->services);
  463.         for ($i=0 ; $i<$c$i++{
  464.             if (strcmp($serviceName$this->services[$i]->name)==0return $this->services[$i];
  465.         }
  466.         return NULL;
  467.     }
  468. }
  469.  
  470. #$reg =& new SOAP_Interop_registrationAndNotificationDB();
  471. #$reg->updateDB();
  472. //print_r($l);
  473. ?>

Documentation generated on Mon, 11 Mar 2019 15:06:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.