Tuesday, March 22, 2016

Axis: createCall with params

Leave a Comment

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

Environment:

  • JDK 1.8
  • AXIS 1.4
  • php 5.6
  • Magento 1.6

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:

1 Answers

Answers 1

The Magento documentation is faulty: http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html

The parameter "productId" is in reality called "product".

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment