Magento – Magento 2 Soap API with Web Service Studio Client

magento2soap-api-v2

I am programing an API Client with Filemaker and MBS Plug-in.

With Magento1 Soap API I could use a client called "Web Service Studio" https://webservicestudio.codeplex.com/ to try things out. Later i could use the XML a use within Filemaker.

Using an URL under Magento1 like

www.url.com/api/v2_soap/?wsdl 

gave me a result with which I could request a Token and could login with token I got.

To request a Token within Magento2 Soap Api I found this URL:

www.url.com/soap/?wsdl&services=integrationAdminTokenServiceV1

If I request a WSDL like I did before like

www.url.com/soap/default?wsdl&services=catalogProductRepositoryV1

I only get a 401 Unauthorised.

So where do I place my token or where do I get a WSDL like before in Magento1?

Best Answer

Try to request a token within Magento 2.

Then add the authorization token in the HTTP header

Authorization: Bearer YOURTOKEN

With this URL : www.url.com/soap/default?wsdl&services=catalogProductRepositoryV1

Documentation reference : http://devdocs.magento.com/guides/v2.1/get-started/authentication/gs-authentication-token.html http://devdocs.magento.com/guides/v2.0/get-started/soap/soap-web-api-calls.html

Code example in PHP :

<?php
$opts = array(
            'http'=>array(
                'header' => 'Authorization: Bearer 36849300bca4fbff758d93a3379f1b8e'
            )
        );
$wsdlUrl = 'http://magento.ll/soap/default?wsdl=1&services=testModule1AllSoapAndRestV1';
$serviceArgs = array("id"=>1);

$context = stream_context_create($opts);
$soapClient = new SoapClient($wsdlUrl, ['version' => SOAP_1_2, 'context' => $context]);

$soapResponse = $soapClient->testModule1AllSoapAndRestV1Item($serviceArgs); ?>
Related Topic