Connecting to Magento Web Services with Java

Posted by kerry on Gooder Code See other posts from Gooder Code or by kerry
Published on Tue, 22 Feb 2011 15:43:39 +0000 Indexed on 2011/02/22 23:32 UTC
Read the original article Hit count: 587

I was in the unenviable position of needing to connect to Magento, a PHP ecommerce platform, web services using Java.  It was kind of difficult to get the classes generated from the WSDL so I figured I would throw the results up on my github account for any other poor sap in a similar position.

First, pull down the project using git:

git clone git://github.com/webdevwilson/magento-java.git

and build it with maven:

mvn install

Here is a quick example of how to pull an order using the generated classes:

MagentoServiceLocator serviceLocator = new MagentoServiceLocator();
String url = "http://domain.com/index.php/api/v2_soap";
Mage_Api_Model_Server_V2_HandlerPortType port = serviceLocator.getMage_Api_Model_Server_V2_HandlerPort(url);
String sessionId = port.login("username", "key");
SalesOrderEntity salesOrder = port.salesOrderInfo(sessionId, orderId);

I also have some wrapper code in there that makes it a little easier to call the API.

Checkout the project at https://github.com/webdevwilson/magento-java

There is another option. it’s called Magja and it is located at google code.

© Gooder Code or respective owner

Related posts about Developer Tools

Related posts about java