Eugene Lebedev
Eugene Lebedev

Reputation: 1474

Axis: createCall with params

I generated java code with wsdl2java based on Magento WSDL (http://host/api?wsdl), but cannot call any procedure with params

Environment:

Problem:

For example, product.info api method required 2 params: sessionId and productId

code:

MagentoService magentoService = new MagentoServiceLocator();
Mage_Api_Model_Server_HandlerBindingStub service = new Mage_Api_Model_Server_HandlerBindingStub(new URL("http://myhost/api"), magentoService);

String sessionId = service.login("api-user", "AAAAAAAAAAAAAAAA");

Call serviceCall = service.createCall();
serviceCall.setOperationName(new QName("call"));
serviceCall.setTargetEndpointAddress(new URL("http://myhost/api"));
serviceCall.addParameter("sessionId", Constants.XSD_STRING, ParameterMode.IN);
serviceCall.addParameter("resourcePath", Constants.XSD_STRING, ParameterMode.IN);
serviceCall.addParameter("productId", Constants.XSD_STRING, ParameterMode.IN);
serviceCall.setReturnType(Constants.SOAP_MAP);
serviceCall.invoke("call", new Object[] {sessionId, "product.info", new Object[]{2115}});    

i checked database, product really exists. no matter which id used, i getting error:

AxisFault
 faultCode: 101
 faultString: Product not exists.

i try another api methods, like a customer.info and have the same result.

how to pass parameters correctly?

What i did:

Upvotes: 5

Views: 524

Answers (1)

TheMirrox
TheMirrox

Reputation: 358

The Magento documentation has a mistake:

http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html

The parameter "productId" should be replaced with "product".

Upvotes: 3

Related Questions