Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Magento API with SOAP

I'm trying to follow a tutorail on connecting to magento API with Soap, but am stuck already ? SOAP seems to be installed on my sever as i can browse to the ?wsld and it displays an xml file.

I've setup the user and role in magento admin webservices.

i'm confused by 2 things in the tutorial

  1. choosing a soap client, In this tutorial we will assume the usage of the PHP SoapClient. what is this where do i find it ?
  2. Logging with the SOAP client

"So let's create a simple PHP-script that allows us to login into Magento through SOAP. The logic is here that we first need to initialize a new SoapClient object with as argument the Magento SOAP URL."

 // Magento login information 
 $mage_url = 'http://MAGENTO/api/?wsdl'; 
$mage_user = 'soap_user'; 
$mage_api_key = '********'; 
// Initialize the SOAP client 
$soap = new SoapClient( $mage_url ); 
// Login to Magento 
$session_id = $soap->login( $mage_user, $mage_api_key );

Where do you create this script - is it a simple php file ? and how do you actualy make the call - do you just browse to it ?

http://blog.opensourcenetwork.eu/tutorials/guru/connecting-through-soap-with-magento-1

Many thanks in advance

like image 938
Ledgemonkey Avatar asked Nov 15 '11 15:11

Ledgemonkey


People also ask

How do I integrate third party API in Magento 2?

To do this, log in to the Magento admin, then go to System -> Web Services -> SOAP/XML-RPC – Users. Click “Add New User” and fill out the form. Keep in mind the values you set for “User Name” and “New API Key”. After saving the user, go to System -> Web Services -> SOAP/XML-RPC – Roles and click “Add New Role”.


1 Answers

You put this into a new blank file. Save this as name.php und run this is on your server:

<?php
        $host = "127.0.0.1/magento/index.php"; //our online shop url
        $client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
        $apiuser= "user"; //webservice user login
        $apikey = "key"; //webservice user pass
        $action = "sales_order.list"; //an action to call later (loading Sales Order List)
        try { 

          $sess_id= $client->login($apiuser, $apikey); //we do login


        print_r($client->call($sess_id, $action));
        }
        catch (Exception $e) { //while an error has occured
            echo "==> Error: ".$e->getMessage(); //we print this
               exit();
        }
?>

Regards boti

like image 164
boti Avatar answered Oct 20 '22 07:10

boti