New SOAP
**Heei pessoal , postei um tópico sobre WS onde estava com dúvida ' como passar uma $var em Array '
foi resolvido, más preciso de uma nova função , sou novo em PHP e me dirigi até aqui.
como posso mostrar o extrato junto ao NOME & SALDO.
// index.html**
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf8" />
<meta name="description" content="">
<meta name="author" content="Padmanaban, Mine Web Design">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='[http://fonts.googleapis.com/css?family=Raleway:400,300,600'](http://fonts.googleapis.com/css?family=Raleway:400,300,600) rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="row">
<div class="container">
<form action="include/auth.php" method="post" class="form-signin">
<h4 class="section-heading"><span>Acesso Usuario | Ciclum </span></h4>
<div class="row">
<div class="column">
<label><span id="ast">*</span>Acesso permitido so ao titular</label>
<input id="username" name="cartao" class="full-width" type="number" placeholder="Numero do Cartao" />
</div>
</div>
<br/>
<input class="button-submit" type="submit" value="ACESSAR" />
</form>
</div>
</div>
</body>
</html>
// auth.php
<?php
session_start();
?>
<html>
<head>
<title> Validando.. </title>
<meta charset="utf8">
<!-- Script Popup -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="[https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css](https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css)" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<link rel="stylesheet" href="[https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css](https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css)" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://github.com/makeusabrew/bootbox/releases/download/v4.4.0/bootbox.min.js"></script>
</head>
<body>
<?php
$cartao = $_POST['cartao'];
require_once 'vale-consulta.php';
try {
$dados = array(
'cd_grupo' => '38',
'de_login_usu' => 'vale.consulta',
'de_senha_usu' => 'v3r5b6',
'nu_cartao' => "$cartao",
'fl_apenas_saldo' => 'N'
);
$vale = new ValeConsulta();
$resposta = $vale->consultar( $dados );
if ( $vale->tem_erro() ) {
$seguranca = '0';
$_SESSION['seguranca'] = $seguranca;
PRINT "<script>bootbox.alert('Ops, Ocorreu o seguinte erro: <strong>| " . $resposta->erro->msg ." |</strong> tente novamente...')</script><meta http-equiv='refresh' content='2.3;URL=../index.html'>";
} else {
$seguranca = '2';
$_SESSION['seguranca'] = $seguranca;
$_SESSION['cartao'] = $cartao;
PRINT "<meta http-equiv='refresh' content='0;URL= /l/user/'>";
}
} catch( SoapFault $fault ) {
echo "Erro: " . $fault->faultcode . " - " . $fault->faultstring;
}
?>
</body>
</html>
// vale-consulta.php
<meta charset="utf8">
<?php
class ValeConsulta {
# private static $endpoint = "http://desenv.algorix.com:81/generix/wsInterfaceValeConsulta.asmx?wsdl";
private static $endpoint = "http://cartao3.algorix.com/ciclum/wsInterfaceValeConsulta.asmx?wsdl";
protected $soap;
protected $dom;
protected $xml;
protected $resposta;
public function __construct( $dados = null ){
$this->soap = new SoapClient( self::$endpoint );
$this->dom = new DOMDocument();
$this->dom->preserveWhiteSpace = false;
$this->dom->formatOutput = true;
$this->dados = $dados;
}
private function xml_consulta() {
$this->xml = null;
if ( is_array( $this->dados ) && count( $this->dados ) > 0 ) {
$pai = $this->dom->createElement( 'valeconsulta' );
$this->dom->appendChild( $pai );
foreach( $this->dados as $k => $v ) {
$filho = $this->dom->createElement( $k, $v );
$pai->appendChild( $filho );
}
$this->xml = $this->dom->saveXML();
$this->xml = str_replace( '<?xml version=\"1.0\"?>\n', '', $this->xml );
}
return $this->xml;
}
public function consultar( $dados = null ) {
$this->resposta = false;
if ( $dados ) {
$this->dados = $dados;
}
if ( $this->xml_consulta() ) {
$resposta = $this->soap->ValeConsulta_RecuperarExtrato( array( 'strXMLDados' => $this->xml ) );
if ( $resposta instanceof StdClass ) {
$this->dom->loadXML( current( $resposta ) );
$this->resposta = simplexml_import_dom( $this->dom );
}
}
return $this->resposta;
}
public function tem_erro() {
return $this->resposta && isset( $this->resposta->erro );
}
}
?>
Discussão (0)
Carregando comentários...