Accessing Magento API with Java : Procedure ххх not present
I need to build Special Java Api to wrap Magento Api. After struggling with several Magento bugs, I am finally able to login and get session id; but any method I call leads me to an error. The error is:
Procedure '*procedure name*' not present
I generated Java code from wsdl using Eclipse build in plugin and wsdl located at my local server: http://localhost/magento/index.php/api/v2_soap?wsdl=1.
The example of java code I use:
Mage_Api_Model_Server_V2_HandlerPortTypeProxy proxy = new Mage_Api_Model_Server_V2_HandlerPortTypeProxy(
"http://localhost/magento/index.php/api/");
String sessionId = proxy.login("magentobot", "123456");
System.out.println("Session: " + sessionId);
CatalogProductEntity[] products = proxy.catalogProductList(sessionId, new Filters(), "");
And here is the exception I got:
Session: 12abdaf054fb7100b6c5d84ab8cb8311
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Procedure 'catalogProductList' not present
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:Procedure 'catalogProductList' not present
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces开发者_开发技巧.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Magento.Mage_Api_Model_Server_V2_HandlerBindingStub.catalogProductList(Mage_Api_Model_Server_V2_HandlerBindingStub.java:3104)
at Magento.Mage_Api_Model_Server_V2_HandlerPortTypeProxy.catalogProductList(Mage_Api_Model_Server_V2_HandlerPortTypeProxy.java:260)
at Main2.main(Main2.java:14)
{http://xml.apache.org/axis/}hostname:Dacer
Here is the link to the official documentation: Magento product API It says that the method is called catalog_product.list
The php code for the API works fine:
<?php
$proxy = new SoapClient('http://localhost/magento/index.php/api/?wsdl');
$sessionId = $proxy->login('magentobot', '123456');
$filters = array();
$products = $proxy->call($sessionId, 'product.list', array($filters));
var_dump($products);
?>
I will be glad to any help.
I've never used the API from java before, but looking over your code example, you said you generated code using the v2 WSDL (which is supposed to have better Java/.NET SOAP support), but in your code sample you're pointing at the v1 URL
http://localhost/magento/index.php/api/
I would assume you want your code sample pointing at
http://magento1point4.dev/index.php/api/v2_soap
but again, not a big Java (or SOAP, for that matter) guy, so appologies if there's something obvious I'm missing here.
精彩评论