Advertisement
Guest User

my_webservice

a guest
Oct 3rd, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. <?php
  2.         error_reporting(E_ALL);
  3.         ini_set("display_errors", 1);
  4.         $soapUrl = "http://myserver/AIMWebservice/v1.1/AIM.asmx"; // asmx URL of WSDL
  5.  
  6.         $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
  7.                          <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/">
  8.                            <soap:Body>
  9.                              <GetPassword xmlns="https://tempuri.org/">
  10.                                  <passwordWSRequest>
  11.                                      <AppID>app Id</AppID>
  12.                                      <Safe>CofreEquipeFerrmantas</Safe>
  13.                                      <Folder>path</Folder>
  14.                                      <Object>Operating System-WinDomain</Object>
  15.                                      <UserName>SPSMON01</UserName>
  16.                                      <Address>BSBR</Address>
  17.                                      <Database>null</Database>
  18.                                      <PolicyID>null</PolicyID>
  19.                                      <Reason>null</Reason>
  20.                                      <ConnectionTimeout>360</ConnectionTimeout>
  21.                                      <Query>null</Query>
  22.                                      <QueryFormat>null/QueryFormat>
  23.                                  </passwordWSRequest>
  24.                                  </GetPassword>
  25.                            </soap:Body>
  26.                          </soap:Envelope>';
  27.  
  28.            $headers = array(
  29.                         "POST /AIMWebservice/v1.1/AIM.asmx HTTP/1.1",
  30.                         "Host: myserver",
  31.                         "Content-Type: text/xml; charset=\"utf-8\"",
  32.                         "SOAPAction: \"https://tempuri.org/GetPassword\"",
  33.                         "Content-length: ".strlen($xml_post_string),
  34.                     );
  35.  
  36.             $url = $soapUrl;
  37.  
  38.  
  39.          
  40.             $ch = curl_init();
  41.             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  42.             curl_setopt($ch, CURLOPT_URL, $url);
  43.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  44.             curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  45.             curl_setopt($ch, CURLOPT_POST, true);
  46.             curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
  47.             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  48.  
  49.            
  50.             $response = curl_exec($ch);
  51.             curl_close($ch);
  52.  
  53.             $response1 = str_replace("<soap:Body>","",$response);
  54.             $response2 = str_replace("</soap:Body>","",$response1);
  55.             echo $response1.' - '.$response2;
  56.            
  57.             $parser = simplexml_load_string($response2);
  58.          
  59.             print_r($response).PHP_EOL;
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement