Connecting to Magento Web Services with Java
- by kerry
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.