Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Ysa\Core\Model;
- use PHPUnit\Runner\Exception;
- use Magento\Framework\Webapi\Soap\ClientFactory;
- class Api extends \Magento\Framework\Model\AbstractModel
- {
- const URI_SOAP_PRD = "http://xml-hu.kaluahtours.com/webservice/jp/operations/";
- const URI_SOAP_HML = "https://xml-uat.bookingengine.es/webservice/jp/operations/";
- const PASS_HML = "MmeJwr8YK";
- const PASS_PRD = "Rentalcars2018";
- const USER_HML = "XML_Optur";
- const USER_PRD = "atendimento02@optur.com.br";
- const LIFETIME = 1000;
- const CONNECTTIMEOUT = 100;
- var $soapClientFactory;
- var $environment = false; // if true = prod else test enviroment
- protected $_logger;
- public function __construct(
- ClientFactory $soapClientFactory,
- \Psr\Log\LoggerInterface $logger
- )
- {
- $this->soapClientFactory = $soapClientFactory;
- $this->_logger = $logger;
- }
- public function requestCurlXML($post_string, $url_asmx)
- {
- $this->_logger->info($post_string);
- try {
- $soap_do = curl_init();
- curl_setopt($soap_do, CURLOPT_URL, $url_asmx );
- curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, self::CONNECTTIMEOUT);
- curl_setopt($soap_do, CURLOPT_TIMEOUT, self::LIFETIME);
- curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
- curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($soap_do, CURLOPT_POST, true );
- curl_setopt($soap_do, CURLOPT_ENCODING, '');
- curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string);
- curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
- $result = curl_exec($soap_do);
- $this->_logger->info($result);
- return $result;
- }catch(Exception $e){
- $err = curl_error($soap_do);
- return $e->getMessage();
- }
- curl_close($soap_do);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement