PHP upload Dom XML with SOAP

Rotoorbimemon

New Member
I would like to upload monthly my invoices to a remote server with soap but the upload somehow fails without error message.I generate the XML file (the invoice) with DomDocument from my database. Then I validate it against an XSD and if that returns ok I start the SOAP request.The documentation for the remote SOAP server says that first I have to call the Authentication service to identify my self and get a session id then I can start the upload. But the Upload doesn't work and I don't get an error message. I'm not familiar with soap so I don't know what to do now.This is how I do it:\[code\]$xml = $doc->saveXML(); /*before this is a very long code which creates the XML*/$xmlauth = new DomDocument();$xmlauth = loadXML($xml);if(!$xmlauth->schemaValidate('https://test.e-szamla.hu/apeh_xml.xsd')){echo 'Error: <br />';libxml_display_errors(); /*this is a function that formats the error code and saves it to a log file*/}else { try { $trace = '1'; $url = 'https://test.e-szamla.hu/soap/AuthenticationService.wsdl'; $client = new SoapClient($url, array('trace' => $trace)); $params = array( 'username' => 'hu-0000000x-x-xx', 'password' => 'XXXXXXX' ); } catch(exception $e){ echo '<h2>Error in connection: </h2>'; echo $e->getMessage(); } try { $result = $client->startSession($params); $_SESSION['sessid'] = $result->sessionid; //echo $_SESSION['sessid']; } catch(exception $e) { echo '<h2>Something went wrong:</h2>'; echo $e->getMessage(); } try { $urlinv = 'https://test.e-szamla.hu/soap/InvoiceService.wsdl'; $clientinv = new SoapClient($urlinv, array('trace' => $trace)); $paramsinv = array('sessionid' => $_SESSION['sessid'], 'partner' => 'hu-xxxxxxxx-x-xx', 'xml' => $xmlauth); } catch(exception $err) { echo '<h2>ERROR:</h2>'; echo $err->getMessage(); } try { $resultinv = $clientinv->uploadInvoice($paramsinv); echo 'Uploaded with this session id: '. $_SESSION['sessid']; } catch(exception $err){ echo '<h2>Something went wrong: </h2>'; echo $err->getMessage(); }}\[/code\]Both the XSD and WSDL URLs are the real URL for the test service and here is a test XML: https://test.e-szamla.hu/samples/dijbekero.xmlAnd this is the example from the documentation:Auth. Service\[code\]$client = new SoapClient($url."AuthenticationService.wsdl", array('trace' => $trace));$params = array("username" => "hu-12345678-1-90","password" => "12345678");$result = $client->startSession($params);$_SESSION["sessid"] = $result->sessionid;\[/code\]Invoice Service\[code\]$client = new SoapClient($url."InvoiceService.wsdl", array('trace' => $trace));$xml = file_get_contents("samples/invoice.xml");$params = array("sessionid" => $_SESSION["sessid"],"partner" => "hu-00000000-2-00","xml" => $xml);$result = $client->uploadInvoice($params);\[/code\]How can I make this work or at least get an error message. As you can see I'm passing every required variable like username, password and the partner id and the only thing I have changed is that I doesn't load the XML from file.
 
Back
Top