Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //$CNPJ= "71598742";
- $CNPJ = "62173620"; //CNPJ EMEPARS
- // ESSE
- ///$CNPJ="59732586";
- ini_set("display_errors", "on");
- ini_set("max_execution_time", 60000);
- set_time_limit(60000);
- error_reporting(E_ALL);
- $ambiente = 'homol';
- class WsseAuthHeader extends SoapHeader {
- private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
- private $wsu_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
- function __construct($user, $pass) {
- $created = gmdate('Y-m-d\TH:i:s\Z');
- $nonce = mt_rand();
- $passdigest = base64_encode( pack('H*', sha1( pack('H*', $nonce) . pack('a*',$created). pack('a*',$pass))));
- $auth = new stdClass();
- $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Nonce = new SoapVar($passdigest, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
- $auth->Created = new SoapVar($created, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wsu_ns);
- $username_token = new stdClass();
- $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
- $security_sv = new SoapVar(
- new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
- SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
- parent::__construct($this->wss_ns, 'Security', $security_sv, true);
- }
- }
- if($ambiente == 'prod') {
- $urlWsdl = 'https://services.serasaexperian.com.br/MeAviseProxy?wsdl';
- $username = '51315811';
- $password = '';
- } else {
- $urlWsdl = 'https://serviceshomologa.serasaexperian.com.br/MeAviseProxy?wsdl';
- $username = '94059045';
- $password = '10203040';
- }
- $plano = 'Mensal';
- $modalidade = 'NaoAutomatica';
- try {
- $soapClient = new SoapClient($urlWsdl, array(
- 'exceptions' => true,
- 'trace' => true
- ));
- $soapClient->__setSoapHeaders(Array(new WsseAuthHeader($username, $password)));
- if($ambiente == 'prod') {
- $requestData = array( 'cnpj' => $CNPJ);
- } else {
- $requestData = array( 'cnpj' => $CNPJ );
- }
- print_r($requestData);
- $response = $soapClient->excluirClienteDistribuidor($requestData);
- echo'<pre>';
- print_r($response);
- echo'</pre><br>';
- //echo 'RESPOSTA ARRAY PHP: ';
- //print_r($response);
- //echo '<br>RESPOSTA ARRAY JSON: ';
- //$resposta_json = json_encode($response);
- //var_dump($resposta_json);
- //echo "<br>";
- //$MSG = isset($response->retorno->Mensagem);
- //echo "Menssagem Retorno do Array: ".$MSG;
- //$RazaoSocial = isset($response->dadosRelato->empresaConsultada->RazaoSocial) ? $response->dadosRelato->empresaConsultada->RazaoSocial : NULL;
- if (isset($response->erros->Mensagem->Mensagem)){
- $MSG = $response->erros->Mensagem->Mensagem;
- echo "Mensagem Retorno de ERRO: ".$MSG;
- // VERIFICA SE TEM MSG DE RESPOSTA DE SUCESSO , AO TENTAR CADASTRAR EMPRESA
- }else if(isset($response->erros->Mensagem->Mensagem)){
- $MSG = $response->retorno->Mensagem;
- echo "Mensagem Retorno de Sucesso: ".$MSG;
- }
- }catch (SoapFault $exception) {
- echo $exception->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement