I am working on a nusoap client call, for a web service, I am using nusoap.php last library.
When I made the XML structure I use this:
$string =<<<XML<?xml version='1.0'?><cliente> <nombre>$posts['nombre']</nombre> <apellido>$posts['apellido']</apellido> <calle>$posts['direccion']</calle> <altura>$posts['altura']</altura> <pisodto>$posts['pisodto']</pisodto> <localidad>$posts['localidad']</localidad> <provincia>$posts['provincia']</provincia> <partido>$posts['partido']</partido> <telefono>$posts['telefono']</telefono> <celular>$posts['celular']</celular> <email>$posts['email']</email> </cliente> XML; But for some reason WAMP doesn't like it and I always get this error:
Parse error: syntax error, unexpected '<<' (T_SL) in G:\wamp\www\bsmart\PHPtoXML2\enviarxml.php on line 98
Here is the full code
date_default_timezone_set('America/Argentina/Buenos_Aires'); require_once 'assets/clases/nusoap/nusoap.php'; $wsdl = "http://ws.maxirest.com/wsclientes/wscli06896.php?WSDL"; $cliente = new nusoap_client($wsdl); $produccion = false; //Cambiar a verdadero por producction $endpoint = $wsdl; //print_r($_POST); $posts = $_POST; if ($produccion == false) { $posts['nombre'] = $posts['apellido'] = $posts['direccion'] = $posts['pisodto'] = $posts['localidad'] = $posts['partido'] = $posts['provincia'] = $posts['telefono'] = $posts['celular'] = $posts['altura'] = $posts['email'] = "PRUEBA"; } $string =<<<XML<?xml version='1.0'?><cliente> <nombre>$posts['nombre']</nombre> <apellido>$posts['apellido']</apellido> <calle>$posts['direccion']</calle> <altura>$posts['altura']</altura> <pisodto>$posts['pisodto']</pisodto> <localidad>$posts['localidad']</localidad> <provincia>$posts['provincia']</provincia> <partido>$posts['partido']</partido> <telefono>$posts['telefono']</telefono> <celular>$posts['celular']</celular> <email>$posts['email']</email> </cliente> XML; $param = array('cXml' => $string, 'clave' => "123ClubMilaMREST5"); $client = new nusoap_client($wsdl);//Ruta donde se encuentra nuestro servicio para consumirlo $resultado = $client->call('AltaSolicitud',$param); //Codigo para debugear y ver la respuesta y posibles errores, comentar cuando se comprueba que está correcto el servicio y la llamada $err = $client->getError(); if ($err) { echo '<p><b>Constructor error: ' . $err . '</b></p>'; } echo '<h2>Request</h2>'; echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; echo '<h2>Response</h2>'; echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; echo htmlspecialchars($client->response, ENT_QUOTES) . '</b></p>'; echo '<p><b>Debug: <br>'; echo htmlspecialchars($client->debug_str, ENT_QUOTES) .'</b></p>'; //Comentar hasta aquí if($client->fault) { echo "FAULT: <p>Code: (".$client->faultcode.")</p>"; echo "String: ".$client->faultstring; } else { var_dump ($resultado); } I think maybe a library could be missing, but I am not sure, any help would be very appreciated, thanks in advance.
$postsvariable chaining like that is wrong.$postschaining wrong. That should set all toPRUEBAI know its nonsence as in that code$produccionwill always be == false but?