amuck-landowner

PHP - XML SOAP API with WSDL

Hello,

I have been trying to connect a simple PHP project with a service API, but I never programmed from scratch anything that connects to an API. While I searching on Google some ways to do it, and came across this Stack Overflow article --> http://stackoverflow.com/questions/9768990/read-wsdl-file-using-php

At the moment I'm just trying to authenticate to the API, anyone can help me?

I also can share the files if people need it.

- Henrique
 

trewq

Active Member
Verified Provider
http://uk3.php.net/manual/en/soapclient.soapclient.php


"For HTTP authentication, the login and password options can be used to supply credentials. For making an HTTP connection through a proxy server, the options proxy_host, proxy_port, proxy_login and proxy_password are also available. For HTTPS client certificate authentication use local_cert and passphrase options. An authentication may be supplied in the authentication option. The authentication method may be either SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST."


I'm on my mobile so can't write you a full example but that should get you started.
 
 


http://uk3.php.net/manual/en/soapclient.soapclient.php

"For HTTP authentication, the login and password options can be used to supply credentials. For making an HTTP connection through a proxy server, the options proxy_host, proxy_port, proxy_login and proxy_password are also available. For HTTPS client certificate authentication use local_cert and passphrase options. An authentication may be supplied in the authentication option. The authentication method may be either SOAP_AUTHENTICATION_BASIC (default) or SOAP_AUTHENTICATION_DIGEST."

I'm on my mobile so can't write you a full example but that should get you started.
I already came across that manual page to, but still have a few doubts about how to implement it. The API that I'm trying to connect to already provides a folder with 1 WSDL file and some XSD files.

If you could provide a detailed example I would appreciate it :)

- Henrique 
 

trewq

Active Member
Verified Provider
Is it just basic http auth? I'll write you an example today if I get some free time.
 
Hello @trewq,

You don't need to send me the example for this API, I found a PHP library on GitHub in which the developer agreed to help us develop it further.

But now I'm working on a different API, which much more simple, this is the code I have, and it is always returning authentication error.


<?php

//Dados de Servidor & Login
$token = ''; //I can provide it, if you want to help troubleshooting this further
$wsdl = 'http://pt.keyinvoice.com/API3_ws.php?wsdl';
$client = new SoapClient($wsdl);

//Testar Autenticacao
$result = $client->authenticate(array('apikey' => $token));
print_r($result);

?>

I can send you more info if necessary, but this is my code just to try the authentication on the API.

- Henrique
 
Last edited by a moderator:
Top
amuck-landowner