Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 3
Api & .Net
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

Hi, i was trying to use 1.1 final’s api from an c# application, and i’ve found out that it’s impossible to add a web reference to c# project since it’s producing following error

Error 1 Custom tool error: Unable to import WebService/Schema. Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’. Unable to import operation ‘call’. The ref syntax for groups is not supported with encoded SOAP. Please change definition of schema type ‘Struct’ from namespace ‘http://schemas.xmlsoap.org/soap/encoding/’: replace the group reference with local group declaration. 

Error 2 Custom tool error: Unable to import WebService/Schema. Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’. Unable to import operation ‘call’. The ref syntax for groups is not supported with encoded SOAP. Please change definition of schema type ‘Struct’ from namespace ‘http://schemas.xmlsoap.org/soap/encoding/’: replace the group reference with local group declaration. 

Any thoughts? Thx in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

gonna need more info, such as
1) Where is magento being run, php version, whether it has SOAP
2) Where are you are attempting to call magento’s api from? - same server? If so, how are you running PHP and a .NET application at the same time? (etc).

 
Magento Community Magento Community
Magento Community
Magento Community
 
frontier
Member
 
Total Posts:  41
Joined:  2008-04-17
 

I am having the same problem, using VB.NET but same difference. wink
http://www.magentocommerce.com/boards/viewthread/13158/

My host (Aspiration Hosting - can’t recommend them enough btw) is running PHP 5.2.6 and has SOAP installed. (they recompiled PHP specially after I found it missing)

Anyway I have attached the generated xml. (only my domain is changed) I am connecting remotely.

File Attachments
magento_soap.xml  (File Size: 9KB - Downloads: 230)
 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 
nikefido - 25 July 2008 08:48 AM

gonna need more info, such as
1) Where is magento being run, php version, whether it has SOAP
2) Where are you are attempting to call magento’s api from? - same server? If so, how are you running PHP and a .NET application at the same time? (etc).

Magento is executed on the remote server and Soap service is working perfectly since i’m able to use it with php client. The problem is (i suppose) that generated wsdl is not compatible with .net 2.0, since the error is coming out when i’m trying to add magento as web reference.

In the past alpha i’ve read that someone has changed manualy xml file for generation, but unfortunatly that advice is not working now since xml’s configuration file has changed it’s structure :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

I’ve found that removing use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" from wsdl.xml permit to add web reference without errors, not sure if it compromise in some way it’s functionality, will test it rasberry

Edit hmm, it’s working in kinda strange way…
This php code is working perfectly

$proxy = new SoapClient("http://xxx/magento/api/soap/?wsdl");
$sessionId $proxy->login('alekc',"xxx");
$customer $proxy->call($sessionId"customer.info""1");

While c# version gives an exception “Access Denied” (session id is found correctly)

MagentoService mg = new MagentoService();
                
String sessionId mg.login("alekc""xxx");
                
mg.call(sessionId"customer.info""1");
Probably it’s implementation error, any help?
 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1093
Joined:  2008-07-16
London, United Kingdom
 

Hey Alekc

ive been struggling with trying to add a web reference to my .Net project also.. Thanks for the posts..

if you can let me know how you get on. That would be great

cheers
Brendan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 
brendanb - 29 July 2008 03:31 PM

Hey Alekc
ive been struggling with trying to add a web reference to my .Net project also.. Thanks for the posts..
if you can let me know how you get on. That would be great
cheers
Brendan

Sure, i attach my xml file from \app\code\core\Mage\Api\etc

With this file web reference is added without problem, but it seems that after login session is killed in some way so the next call will cause exception “Access Denied”. I’m not quite sure if this behavior depends on my wsdl edits or my c# code (same code in php working without problems, see my prev. post)

File Attachments
wsdl.xml  (File Size: 8KB - Downloads: 229)
 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1093
Joined:  2008-07-16
London, United Kingdom
 

thanks!

have you seen this blog. Look towards the bottom of the thread. This talks about issues with the xml. But i dont know if this is the reason why your getting this issues.
http://www.magentocommerce.com/blog/comments/magento-core-api/

also, i recall seeing someone using Java to access the API and having issues with cookies… ill hunt round for the post

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

Yep i’ve seen blog’s post, although it was not a great help :(

Right now i’ve solved the issue of Access Denied by forcing PHPSESSID so it’s kinda working.

The only things i need to understand right now are:
1) How the heck i pass arrays in “call” function
2) The comfortable way for parsing soap responce (it gives me an array of XmlNode :/)

Below i attach my code with forced Cookie of php session, maybe it’s not the right way for using api, but it’s the only i’ve found working for now :(

MagentoService mg = new MagentoService();                             
                
string sid mg.login("alekc""pass");
                
mg.CookieContainer = new System.Net.CookieContainer();   
                
mg.CookieContainer.Add(new System.Net.Cookie("PHPSESSID"sid"/magento""domain.com"));
                
XmlNode[] wtf = (XmlNode[])mg.call(sid"customer.info",1);
 
Magento Community Magento Community
Magento Community
Magento Community
 
Dieter21
Member
 
Avatar
Total Posts:  51
Joined:  2008-03-29
Belgium
 

I have been able to add the webservice to my VB.NET project but when I call the ‘login’ function, I get the following error:

Client found response content type of ‘text/html; charset=UTF-8’, but expected ‘text/xml’. The request failed with the error message:
—<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:loginResponse>
<loginReturn xsi:type="xsd:string">56hb67sv8ogcn26lu1g0lh5g64</loginReturn>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> --.

What am I doing wrong?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alekc
Jr. Member
 
Total Posts:  20
Joined:  2008-05-29
 

try to add my apis to your project (http://alekc.org/magento/api/soap/?wsdl) and see if you still receive an error. If no, the issue depends on your installation of magento.

 
Magento Community Magento Community
Magento Community
Magento Community
 
frontier
Member
 
Total Posts:  41
Joined:  2008-04-17
 

Hi Alekc,

I just tried it and was successful in adding a web reference to your url.  grin
I didn’t call anything, so that is the extent of what I can confirm, but it is 1 step further than I can get on my installs.

Hmmm.. so now what can be wrong with all our installations, what did you do thar finally fixed yours?

Thanks.

Edit: Ahh I should have read above.  cool smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dieter21
Member
 
Avatar
Total Posts:  51
Joined:  2008-03-29
Belgium
 

I am currently translating/converting all XML-RPC API functions into a VB.NET program. I’ve only worked on it for one day so there’s not much translated yet, but I can allready recieve the category tree structure, info of a category & global and resource fault messages.

You can find the code here:
MagentoXtender

 
Magento Community Magento Community
Magento Community
Magento Community
 
frontier
Member
 
Total Posts:  41
Joined:  2008-04-17
 

! just tested on my fresh 1.1.3 install, I can now add the web reference, but cannot find it in the object browser.

When I right click on the reference in the Solution Explorer and do Update Web Reference, I get an error popup with this message..

Property value is not valid.

(the details are)
The custom tool ‘MSDiscoCodeGenerator’ failed.  Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’.

So still not working with .NET out of the box, as far as I can tell. :-(

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

hi @alekc, I got no idea when I try this code I got access denied,

do you have same experienced ??

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
      
$sessionId $proxy->login('apiUser''apiKey');
      
$filters = array( 'sku' => array('like'=>'zol%') );
      
$products $proxy->call($sessionId'product.list', array($filters));
      
var_dump($products);

I got this :

Access denied.

#0 [internal function]: SoapClient->__call('call', Array)
#1 /home/alkarim/vm/app/code/core/Mage/Rest/Block/Catalog/Items.php(24): SoapClient->call('c7cd5b5c3657e86...', 'product.list', Array)
#2 /home/alkarim/vm/app/code/core/Mage/Core/Block/Abstract.php(636): Mage_Rest_Block_Catalog_Items->_toHtml()
#3 /home/alkarim/vm/app/code/core/Mage/Core/Model/Layout.php(509): Mage_Core_Block_Abstract->toHtml()
#4 /home/alkarim/vm/app/code/core/Mage/Core/Controller/Varien/Action.php(320): Mage_Core_Model_Layout->getOutput()
#5 /home/alkarim/vm/app/code/core/Mage/Rest/controllers/CatalogController.php(7): Mage_Core_Controller_Varien_Action->renderLayout()
#6 /home/alkarim/vm/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Rest_CatalogController->itemsAction()
#7 /home/alkarim/vm/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(137): Mage_Core_Controller_Varien_Action->dispatch('items')
#8 /home/alkarim/vm/app/code/core/Mage/Core/Controller/Varien/Front.php(168): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http))
#9 /home/alkarim/vm/app/Mage.php(420): Mage_Core_Controller_Varien_Front->dispatch()
#10 /home/alkarim/vm/index.php(46): Mage::run()
#11 {main}

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

Never mind, I’ve solved this problem at administrator configuration -> web services, add roles and add user, (make sure your resource access, at role resources, change into ‘ALL’)

Now, I’ve a problem with this code result

$proxy = new SoapClient("http://xxx/magento/api/soap/?wsdl");
$sessionId $proxy->login('alekc',"xxx");
$customer $proxy->call($sessionId"customer.info""1");

is $customer return is XML formatted or array formatted ??

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3