Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ERROR | E_PARSE);
- ini_set('display_errors', 1);
- ini_set('soap.wsdl_cache_enabled',0);
- ini_set('soap.wsdl_cache_ttl',0);
- ini_set('default_socket_timeout', 1000);
- $url_wsdl ="https://exampleservice.cls?WSDL=1&CacheUserName=myusername&CachePassword=mypassword&CacheNoRedirect=1";
- print 'Starting routine';
- //logging in
- $curl = curl_init($url_wsdl);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_HEADER, 1);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($curl, CURLOPT_SSLVERSION, 3);
- // get cookies
- preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $result, $matches);
- $cookies = array();
- foreach($matches[1] as $item) {
- parse_str($item, $cookie);
- $cookies = array_merge($cookies, $cookie);
- }
- curl_close($curl);
- print 'Curl....ok. Cookies ok<br>';
- $options = array(
- 'trace' => 1
- , 'cache_wsdl' => WSDL_CACHE_NONE
- , 'user_agent' => 'PHP WS'
- , 'ssl_method' => SOAP_SSL_METHOD_SSLv3
- );
- $soapClient = new SoapClient($url_wsdl,$options );
- print 'SoapClient....ok<br>';
- //sending cookies to soapclient
- foreach ($cookies as $name => $value) {
- print '------> sending cookies: '. $value . '<br>';
- $soapClient->__setCookie($name, $value);
- }
- print 'SetCookies....ok<br>';
- $data = array('TesteInterface' => array('Request' => array('Mensagem' => 'teste')));
- $response = $soapClient->__soapCall("TesteInterface",$data);
- print 'SoapCall....ok<br>';
- print 'Response:<br>';
- print_r($response);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement