How to separate string that soap generates?

0
if(!empty($_POST['submit'])) {
$client = new SoapClient('http://hidroweb.ana.gov.br/fcthservices/mma.asmx?WSDL');

$function = 'Estado';

$options = array('location' => 'http://hidroweb.ana.gov.br/fcthservices/mma.asmx');

$result = $client->__soapCall($function,$options);

var_dump($result);
?>

The result is this:

  

object (stdClass) # 2 (1) {["StateResult"] = > object (stdClass) # 3 (1) {   ["any"] = > string (2956)   "URURUGUAIARARGENTINAPGPARAGUAICHCHILEBOBOLÍVIAPUPERUCOCOLÔMBIAEQEQUADORVEVENEZUELAGUGUIANASUSURINAMEGFGUIANA   FRANCESA11RORONDÔNIA12ACACRE13AMAMAZONAS14RRORAIMA15PAPARÁ16APAMAPÁ17TOTOCANTINS21MAMARANHÃO22PIPIAUÍ23CECEARÁ24RNRIO   GREAT   NORTE25PBPARAÍBA26PEPERNAMBUCO27ALALAGOAS28SESERGIPE29BABAHIA31MGMINAS   GERAIS32ESESPÍRITO SANTO33RJRIO DE JANEIRO35SPSÃO   PAULO41PRPARANÁ42SCSANTA CATARINA43RSRIO GRANDE DO SUL50MSMATO GROSSO   DO SOUL51MTMATO GROSSO52GOGOIÁS53DFDISTRICA DE FEDERAL "}}

I do not understand that I need the object to be separated. Because the soap is returning to me all together. Has it like ??

    
asked by anonymous 18.11.2014 / 19:57

1 answer

2

You do not need to separate anything, the return is probably in order and separate.

The problem is just the way you are displaying the data on the screen.

You can see that even your string in quotes is about 480 characters, and the returned return is 2956 characters. The returned tags are not being displayed on the screen, as the browser tries to interpret them.

Test like this:

if(!empty($_POST['submit'])) {
$client = new SoapClient('http://hidroweb.ana.gov.br/fcthservices/mma.asmx?WSDL');
$function = 'Estado';
$options = array('location' => 'http://hidroweb.ana.gov.br/fcthservices/mma.asmx');
$result = $client->__soapCall($function,$options);

//VISUALIZAÇÃO EM HTML

// Vamos capturar a saída...
ob_start();
var_dump($result);
$saida = ob_get_contents();
ob_end_clean();

//e formatar para ver na tela:
echo nl2br( htmlentities( $saida ) );

Note: depending on the case it is best to use print_r instead of var_dump .

To convert the XML into an object, we already have an answer on the site:
Webservice SOAP with PHP

    
18.11.2014 / 20:47