cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to use 2.0 API - web-service ( SOAP, PHP )

SOLVED

Unable to use 2.0 API - web-service ( SOAP, PHP )

Hi Forum,

 

We have been using Magento version 1.7.    The API catalogInventoryStockItemList worked just fine.

 

In version 1.7 we used: 
$url        = MY_SITE_URL."/index.php/api/v2_soap?wsdl=1";
$client        = new soapclient( $url, $options );
$sessionId    = $client->login( MY_USER, MY_KEY );
$list        = $client->catalogInventoryStockItemList( $sessionId, MY_SKU_LIST );

This gave us a list of inventory for all SKUs, specified in last function.

 

NOTE:
-- MY_SITE_URL - real path to site.
-- MY_SKU_LIST - list of SKUs, registered in Magento, we want to get inventory. eg. array( 'SKU1', 'SKU2' )
-- MY_USER and MY_KEY - Magento user name and password, required for login

-------------------

 

We installed version 2.0 and want to use the web-service to get inventory.

First we tried to use web-service: catalogProductRepositoryV1
Used url:
$url        = MY_SITE_URL."/soap?wsdl&services=catalogProductRepositoryV1";
See wsdl file and list of available functions:
[0] => CatalogProductRepositoryV1SaveResponse catalogProductRepositoryV1Save(CatalogProductRepositoryV1SaveRequest $messageParameters)
[1] => CatalogProductRepositoryV1DeleteByIdResponse catalogProductRepositoryV1DeleteById(CatalogProductRepositoryV1DeleteByIdRequest $messageParameters)
[2] => CatalogProductRepositoryV1GetListResponse catalogProductRepositoryV1GetList(CatalogProductRepositoryV1GetListRequest $messageParameters)
[3] => CatalogProductRepositoryV1GetResponse catalogProductRepositoryV1Get(CatalogProductRepositoryV1GetRequest $messageParameters)

However; We CAN NOT use any of these functions
( Tried to do same with catalogInventoryStockRegistryV1
 - as far as we understand, it is used to get inventory )

We CAN NOT even login via SOAP:
function "login" is not in list of available functions.
If we try just to call , error is:
Fatal Error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from MY_SITE_URL.'/soap/default?services=catalogProductRepositoryV1&wsdl=1' : failed to load external entity MY_SITE_URL."/soap/default?services=catalogProductRepositoryV1&wsdl=1" in MY_PATH.magento20.php:36 Stack trace: #0 MY_PATH.magento20.php(36): SoapClient->__call('catalogProductR...', Array) #1 MY_PATH.magento20.php(36): SoapClient->catalogProductRepositoryV1GetList()

Note.
-- magento20.php - is standalone PHP file. We use to connect to Magento, installed on our server.

-------------------------

-- What can the problem be?
-- Why can we not login via SOAP ?
-- Can someone provide a working example script using version 2.0 web-services?

 

Thank you in advance.

9 REPLIES

Re: $100 REWARD - Unable to use 2.0 API - web-service ( SOAP, PHP )

We are looking for help with the above issue.

Any recommendations will be appreciated.


Additionally;
We are looking for part time developer who are experiences in all MAGENTO aspects... the Magento API and php, soap, etc.
(4-5 hours per week)

 

Thank you

 

Re: $100 REWARD - Unable to use 2.0 API - web-service ( SOAP, PHP )

What can we do to get by this?

any suggestions would be greatly appreciated

Re: $100 REWARD - Unable to use 2.0 API - web-service ( SOAP, PHP )

Hi,

 

Can you please post your M2 code so we can take a look at it?

 

There is no login() operation in M2 when using web-services. You must provide the Authorization Header with the Access Token.

 

Regards

Re: $100 REWARD - Unable to use 2.0 API - web-service ( SOAP, PHP )

Example of our code:

    $token        = 'OUR TOKENT';
    $url        = "OUR SERVER URL/magento/soap?wsdl&services=catalogInventoryStockRegistryV1";
        $productSku = 'JSP1';
        $options = array(
            'exceptions' => 0,
            'trace' => 1,
            'stream_context' => stream_context_create(array('http' => array( 'header' => 'Authorization: Bearer ' . $token ) ) ),                'service' => 'catalogInventoryStockRegistryV1',
            'serviceVersion' => 'SOAP_1_2',
            'operation' => 'catalogInventoryStockRegistryV1GetStockItemBySku',
        );
        $arguments = array( 'productSku' => $productSku );
        $client        = new SoapClient( $url, $options );

        $l = $client->catalogInventoryStockRegistryV1GetStockItemBySku( $arguments );

Responce is:

 

SoapFault Object
(
[message: protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'OUR SERVER/magento/soap/default?services=catalogInventoryStockRegistryV1&wsdl=1' : failed to load external entity "OUR SERVER/magento/soap/default?services=catalogInventoryStockRegistryV1&wsdl=1"

   [string: Exception: private] =>
      [code: protected] => 0
      [file: protected] => OUR FILE PATH
      [line: protected] => 19
      [trace: Exception: private] => Array
         (
            [0] => Array
               (
                  [file] => OUR FILE PATH
                  [line] => 19
                  [function] => __call
                  [class] => SoapClient
                  [type] => ->
                  [args] => Array
                     (
                        [0] => catalogInventoryStockRegistryV1GetStockItemBySku
                        [1] => Array
                           (
                              [0] => Array
                                 (
                                    [productSku] => JSP1
                                  )

                           )

                        )

            )

)

Re: Unable to use 2.0 API - web-service ( SOAP, PHP )

issue was.  server was closed by htaccess.

Re: Unable to use 2.0 API - web-service ( SOAP, PHP )

Hi, I am having the same issue. Can you please expand on what you meant by "issue was.  server was closed by htaccess."

 

Thanks

Re: Unable to use 2.0 API - web-service ( SOAP, PHP )

Hi 

 

We are having same issue what is the answer please?

 

Thanks

 

Rob

 

Re: Unable to use 2.0 API - web-service ( SOAP, PHP )

Same issue here.

Is there anybody out there nock nock.

Re: Unable to use 2.0 API - web-service ( SOAP, PHP )

I fixed the same issue by uncommenting this in the .htaccess

###########################################
## uncomment next line to enable light API calls processing

 #RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################

so above becomes

###########################################
## uncomment next line to enable light API calls processing

 RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################