Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class API_Client {
- private static $instance = NULL;
- private function __construct() {
- }
- /** * Return client instance or create initial
- *
- * @todo save session id or set var or something so each soap call doesn't need to auth
- * @return object
- * @access public
- */
- public static function getInstance() {
- if (!self::$instance) {
- echo "Eccomi qua";
- $ns = "auth";
- $wsdl = "https://pi731.dncsrl.com/sap/bc/soap/wsdl?services=RFC_SYSTEM_INFO";
- //Create our Auth Object to pass to the SOAP service with our values
- echo "Sto inserendo i parametri di autenticazione";
- $auth->username = 'j2ee_admin';
- $auth->password = 'abcd1234!';
- $auth_vals = new SoapVar($auth, SOAP_ENC_OBJECT);
- //The 2nd variable, 'authenticate' is a method that exists inside of the SOAP service (you must create it, see next example)
- $authenticate = new SoapHeader($ns,'authenticate',$auth_vals, false);
- $client = new SoapClient($wsdl,array('cache_wsdl' => 0));
- $client->__setSoapHeaders(array($authenticate));
- self::$instance = $client;
- echo "sto per eseguire la chiamata";
- }
- return self::$instance;
- }
- private function __clone(){
- }
- } //These are a few sample calls to functions inside of the WSDL
- try {
- echo "Eseguo la chiamata";
- $data_1 = API_Client::getInstance();
- echo "Stampo il risultato";
- echo $data_1;
- }catch (Exception $e){
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement