Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • 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:

  • disable wsdl cache on server side
  • clean wsdl cache
  • restart web services
like image 231
Evgeny Lebedev Avatar asked Oct 19 '22 14:10

Evgeny Lebedev


1 Answers

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".

like image 189
TheMirrox Avatar answered Oct 29 '22 21:10

TheMirrox