magja/magja — Issue #33: 33 - Magento API Connect with Java 
Author: ceefour
Created: 2011-11-02 11:33:49+00:00
State: open

Hi people, im trying connect magento e-commerc with my java aplication, but im having problems with the connection, i will explain you step by step what i was done.

1.I create a web service role in the magento system admin;
2.I create a web service user in magento too;

So my informations related with web services are:

User: hugosousa
Pass: hugosousa
url: http://localhost/magento1.6/api/soap/?wsdl

until here, i think no problem, next i start coding my java class, and to connect i wrote the next code:

MagentoSoapClient magentoSoapClient = MagentoSoapClient.getInstance();
SoapConfig soapConfig = new SoapConfig("hugosousa", "hugosousa", "http://localhost/magento1.6/api/soap/?wsdl");
magentoSoapClient.setConfig(soapConfig);
CategoryRemoteService categoryRemoteService = new CategoryRemoteServiceImpl();
categoryRemoteService.setSoapClient(magentoSoapClient);
Category category = categoryRemoteService.getByIdClean(2);
System.out.println(category.toString());

so, i cant see problems on that code, so when i run the project, the program give me many errors like:

org.apache.axis2.AxisFault: localhost.blackhawk
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521)
at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:78)
at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:20)
at com.google.code.magja.soap.MagentoSoapClient$MagentoSoapClientHolder.<clinit>(MagentoSoapClient.java:96)
at com.google.code.magja.soap.MagentoSoapClient.getInstance(MagentoSoapClient.java:100)
at example.api.Examples.<init>(Examples.java:35)
at example.ApplicationWorkbenchAdvisor.postStartup(ApplicationWorkbenchAdvisor.java:52)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2631)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at example.Application.start(Application.java:26)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.net.UnknownHostException: localhost.blackhawk
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
... 35 more

so, its my problem, it is a strange error and i cant fix it or understand the cause of the error, its really strange, if someone already has that error or know how fix it..i apreciate...please...it s very important for me connect that technologies

Thanks

Hugo Sousa

Original link: http://code.google.com/p/magja/issues/detail?id=33