Advertisement
xkeshav

try.php

Nov 24th, 2014
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.84 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4.  
  5. /* Class Start */
  6. class LocalSoapClient extends SoapClient{
  7.     public $client;
  8.     public $server;
  9.     public function __construct($wsdl, $options) {
  10.         // var_dump(func_get_args());
  11.         $this->client = new SoapClient($wsdl, $options);
  12.         // var_dump($this->client);
  13.         // $this->server = new SoapServer($wsdl, $options);
  14.     }
  15.  
  16.     public function __doRequest($request, $location, $action, $version){
  17.         // var_dump(func_get_args());
  18.         // var_dump($this->client);
  19.         // exit();
  20.         $namespace = "http://schemas.xmlsoap.org/soap/envelope/";
  21.         // $namespace = "urn:DCNZ.MSP.Wireline.Wholesale.Messages";
  22.         $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1);
  23.         $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
  24.         $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
  25.         // var_dump($request);
  26.         $result = parent::__doRequest($request, $location, $action, $version);
  27.         // ob_start();
  28.         // $this->server->handle($request);
  29.         // $response = ob_get_contents();
  30.         // ob_end_clean();
  31.         // $this->__soapAction = $action;
  32.         // return $response;
  33.         return $result;
  34.      }
  35.  
  36.     function soapDebug($client){
  37.       $requestHeaders = $client->__getLastRequestHeaders();
  38.       $request = $client->__getLastRequest();
  39.       $responseHeaders = $client->__getLastResponseHeaders();
  40.       $response = $client->__getLastResponse();
  41.       var_dump(htmlspecialchars($request,ENT_QUOTES));
  42.       var_dump(htmlspecialchars($response,ENT_QUOTES));
  43.     }
  44.  
  45. }
  46. /* Class End */
  47.  
  48. ini_set('soap.wsdl_cache_enabled',0);
  49. ini_set('soap.wsdl_cache_ttl',0);
  50. try {
  51.     $wsdl = "https://www.wirelineonboarding.co.nz/WebServices/OOTInternal/Schemas/Informationservice.WSDL";
  52.     $wsdl_uri = "https://www.wirelineonboarding.co.nz/WebServices/OOTInternal/Schemas/Orderuploadservice.WSDL";
  53.     $cert = getcwd()."/abcd.pem";
  54.     $passphrase = "Wireline";
  55.     $uri = "https://www.wirelineonboarding.co.nz/WebServices/OOTInternal/InformationService.asmx";
  56.     $_uri = "urn:DCNZ.MSP.Wireline.Wholesale.Common";
  57.  
  58.     $x = new LocalSoapClient($wsdl, [
  59.                                     // 'local_cert' => $cert,
  60.                                     'passphrase' => $passphrase,
  61.                                     // 'allow_self_signed' => true,
  62.                                     'cache_wsdl' => WSDL_CACHE_NONE,
  63.                                     'location' => 'https://wsdl.local/try.php',
  64.                                     'uri' => $wsdl_uri,
  65.                                     'exceptions' => true,
  66.                                     'trace' => true,
  67.                                     'soap_version' => SOAP_1_1,
  68.                                     'keep_alive' => true,
  69.                                     'connection_timeout'=>2000,
  70.                                     // 'encoding'=> 'UTF-8' // 'ISO-8859-1'
  71.                                 ]);
  72.  
  73.     $req = '<?xml version="1.0" encoding="utf-8"?>
  74.    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  75.      <soap:Body>
  76.        <addressVerificationRequest xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">
  77.          <addressVerification>
  78.            <samId xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</samId>
  79.            <number xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</number>
  80.            <subDescription xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</subDescription>
  81.            <street xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</street>
  82.            <streetType xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</streetType>
  83.            <direction xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</direction>
  84.            <suburb xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</suburb>
  85.            <city xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</city>
  86.            <buildingFloor xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</buildingFloor>
  87.            <buildingSuite xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</buildingSuite>
  88.            <buildingName xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</buildingName>
  89.            <postalCode xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</postalCode>
  90.          </addressVerification>
  91.        </addressVerificationRequest>
  92.      </soap:Body>
  93.    </soap:Envelope>';
  94.  
  95.     // var_dump($x);
  96.     // var_dump($x->__getFunctions());
  97.  
  98.     $x->__soapCall('AddressVerification', [ 'addressVerificationRequest' => $req ] );
  99.     $x->soapDebug($x);
  100. } catch (Exception $e) {
  101.     echo "Exception Occured:".$e->getMessage();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement