Magento en Soap
Ik ben momenteel wat aan het experimenteren met Magento. Dit heb ik op localhost geïnstalleerd. Heb php_soap aan staan, echter krijg ik iedere keer dezelfde melding:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
Warning: SoapClient::SoapClient() [soapclient.soapclient]: php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\wamp\www\magento\test.php on line 8
Warning: SoapClient::SoapClient(http://schemas.xmlsoap.org/soap/encoding/) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\wamp\www\magento\test.php on line 8
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://schemas.xmlsoap.org/soap/encoding/" in C:\wamp\www\magento\test.php on line 8
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/' in C:\wamp\www\magento\test.php:8 Stack trace: #0 C:\wamp\www\magento\test.php(8): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in C:\wamp\www\magento\test.php on line 8
Warning: SoapClient::SoapClient(http://schemas.xmlsoap.org/soap/encoding/) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Host is onbekend. in C:\wamp\www\magento\test.php on line 8
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://schemas.xmlsoap.org/soap/encoding/" in C:\wamp\www\magento\test.php on line 8
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/' in C:\wamp\www\magento\test.php:8 Stack trace: #0 C:\wamp\www\magento\test.php(8): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in C:\wamp\www\magento\test.php on line 8
Ik voer de volgende code uit:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$client = new SoapClient('http://localhost/magento/index.php/api/v2_soap/?wsdl=1');
// If soap isn't default use this link instead
// http://youmagentohost/api/soap/?wsdl
// If somestuff requires api authentification,
// we should get session token
$session = $client->login('klombarts', '******');
$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
?>
$client = new SoapClient('http://localhost/magento/index.php/api/v2_soap/?wsdl=1');
// If soap isn't default use this link instead
// http://youmagentohost/api/soap/?wsdl
// If somestuff requires api authentification,
// we should get session token
$session = $client->login('klombarts', '******');
$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
?>
Ik heb ook al verschillende url's geprobeerd bij new soapclient, iemand misschien enige idee wat ik nog kan proberen?
Heb PHP versie 5.2.6 en Magento versie 1.3.2.4
Alvast bedankt!
Wat krijg je als je de SOAP URL rechtstreeks benaderd? Krijg je dan het WSDL file in XML te zien?
Als ik dit gebruik:
Code (php)
1
2
3
2
3
<?php
$client = new SoapClient('http://localhost/magento/index.php/api/v2_soap/?wsdl');
?>
$client = new SoapClient('http://localhost/magento/index.php/api/v2_soap/?wsdl');
?>
in PHP versie 5.2.6 dan krijg ik die error die ik hierboven vermelden, doe ik precies hetzelfde maar dan in versie 5.3.0 krijg ik de volgende melding:
Code (php)
1
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/magento/index.php/api/v2_soap/?wsdl' : Extra content at the end of the document in C:\wamp\www\test.php:2 Stack trace: #0 C:\wamp\www\test.php(2): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in C:\wamp\www\test.php on line 2
Alleen loop ik hiermee ook vast...
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
require_once('app/Mage.php');
require_once 'Zend/XmlRpc/Client.php';
require_once('Zend/Http/Client.php');
$client = new Zend_XmlRpc_Client('http://spiderman/magento/api/xmlrpc/');
$session = $client->call('login', array('kitty', '*****'));
?>
require_once('app/Mage.php');
require_once 'Zend/XmlRpc/Client.php';
require_once('Zend/Http/Client.php');
$client = new Zend_XmlRpc_Client('http://spiderman/magento/api/xmlrpc/');
$session = $client->call('login', array('kitty', '*****'));
?>
Dan krijg ik de volgende error..
Code (php)
1
Fatal error: Uncaught exception 'Zend_XmlRpc_Client_HttpException' with message 'Bad Request' in C:\Inetpub\wwwroot\magento\lib\Zend\XmlRpc\Client.php:284 Stack trace: #0 C:\Inetpub\wwwroot\magento\lib\Zend\XmlRpc\Client.php(339): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request)) #1 C:\Inetpub\wwwroot\magento\soapapi.php(8): Zend_XmlRpc_Client->call('login', Array) #2 {main} thrown in C:\Inetpub\wwwroot\magento\lib\Zend\XmlRpc\Client.php on line 284