使用Java访问MagentoAPI:过程ххх;不在场
我需要构建特殊的JavaAPI来包装MagentoAPI。在与几个Magento bug搏斗之后,我终于能够登录并获得会话id;但是我调用的任何方法都会导致错误。错误是:使用Java访问MagentoAPI:过程ххх;不在场,java,web-services,soap,proxy,magento,Java,Web Services,Soap,Proxy,Magento,我需要构建特殊的JavaAPI来包装MagentoAPI。在与几个Magento bug搏斗之后,我终于能够登录并获得会话id;但是我调用的任何方法都会导致错误。错误是: Procedure '*procedure name*' not present 我使用Eclipse内置插件和位于本地服务器上的wsdl从wsdl生成Java代码: 我使用的java代码示例如下: Mage_Api_Model_Server_V2_HandlerPortTypeProxy proxy = new M
Procedure '*procedure name*' not present
我使用Eclipse内置插件和位于本地服务器上的wsdl从wsdl生成Java代码:
我使用的java代码示例如下:
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(), "");
这是我得到的一个例外:
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
以下是官方文件的链接:
该方法称为catalog_product.list
API的php代码运行良好:
<?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);
?>
我很乐意提供任何帮助。我以前从未使用过java的API,但是查看您的代码示例,您说您使用v2 WSDL生成代码(这应该具有更好的java/.NET SOAP支持),但在您的代码示例中,您指的是v1 URL
http://localhost/magento/index.php/api/
我假设您希望您的代码示例指向
http://magento1point4.dev/index.php/api/v2_soap
但再一次,不是一个大Java(或SOAP,就这一点而言)的家伙,所以,如果我在这里遗漏了一些明显的东西,我会进行道歉