File size: 1,964 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

class WsCaller
{

    private $wsdlurl;
    private $soapObj;
    private $client;
    private $auth;
    private $clientStream;

    public function setAuthUser($auth)
    {
        //print "<br>- auth Setup";
        $this->auth = $auth;
    }

    public function setwsdlurl($wsdl)
    {
        //print "<br>- wsdl Setup";
        $this->wsdlurl = $wsdl;
        //var_dump($wsdl);
    }

    public function loadSOAPClient()
    {
        try {
            // we unregister the current HTTP wrapper
            stream_wrapper_unregister('http');
            // we register the new HTTP wrapper
            //$client = new PMServiceProviderNTLMStream($this->auth);
            PMServiceProviderNTLMStream::setAuthStream($this->auth);
            stream_wrapper_register('http', 'PMServiceProviderNTLMStream') or die("Failed to register protocol");

            //     $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
            $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1)); // Ankit's Code
            $this->client->setAuthClient($this->auth);
            return true;
        } catch (Exception $e) {
            echo $e;
            exit();
        }
    }

    public function callWsMethod($methodName, $paramArray)
    {

        try {
            if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
                $strResult = "";
                $strResult = $this->client->$methodName($paramArray = "");
                return $strResult;
            } else {
                $strResult = "";
                $strResult = $this->client->$methodName($paramArray);
                return $strResult;
            }
        } catch (SoapFault $fault) {
            echo 'Fault code: ' . $fault->faultcode;
            echo 'Fault string: ' . $fault->faultstring;
        }
        stream_wrapper_restore('http');
    }
}