I have to do a request to a Web Service using SOAP with POST method and i have an example XML they provide me wich i have to use for the Request to the WS, and not much more info about how to do it. The Web Service i'm trying to access is for authentication purposes, the PHP code im trying includes the login and password info.
<?php
$usuario = "login";
$password = "pass";
$strXml = "<soapenv:Envelope xmlns:soapenv=\'http://schemas.xmlsoap.org /soap/envelope/\' xmlns:guia=\'link to .wsdl\'>
<soapenv:Header/>
<soapenv:Body>
<guia:infoUser>
<guia:nif>userNIF</guia:nif>
</guia:infoUser>
</soapenv:Body>
</soapenv:Envelope>";
$wsdl = 'LINK TO WSDL???.wsdl';
$namespace = 'Here i think i need to put the link that goes to the part of auth on the wsdl';
$credentials = (object)array(
'login' => $usuario,
'pass' => $password
);
$auth_values = new SoapVar($credentials, SOAP_ENC_OBJECT);
$header = new SoapHeader($namespace, "authGUIA", $auth_values);
// set client, headers, and call function
$client = new SoapClient($wsdl, array('trace' => true));
$client->__setSoapHeaders(array($header));
The thing is i tried so many things i do not know that else to try. I did many tests and some will give me the message "You must use POST and not GET method because the password would be stored in logs", wich i get it.
If someone can enlight me with an explanation/solution for my problem in case some of my code is correct, i will be very grateful.
Excuse my poor english. Thanks.
Aucun commentaire:
Enregistrer un commentaire