3
我試圖使用XML-RPC API爲我的第三方應用程序創建magento訂單的貨件。一切都很好,當我用訂單增量ID調用「sales_order_shipment.create」時,但如果我嘗試使用訂單增量ID和一組項目和數量進行同一調用,它會說「請求的訂單不是存在「。這是爲什麼?什麼即時做錯了?什麼類型應該是itemQuantity)Magento XML-RPC API - 從Java創建發貨
繼承人我代碼
package magentoapiclient;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class XMLRPCAPIClient {
public static void main(String[] args) {
createShipment("100000005", 5, 1.0);
}
public static XmlRpcClient prepareClient() throws MalformedURLException {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("myHost"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
client.setTypeFactory(new MyTypeFactory(client));
return client;
}
public static void createShipment(String orderIncrementId, int itemId, double quantity) {
try {
XmlRpcClient client = prepareClient();
String sessionId = login("myUser", "myKey", client);
System.out.println(sessionId);
Object[] request = {orderIncrementId, new HashMap()};
client.execute("call", new Object[]{sessionId, "sales_order_shipment.create", request});
endSession(sessionId, client);
} catch (XmlRpcException | MalformedURLException ex) {
Logger.getLogger(XMLRPCAPIClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static String login(String user, String password, XmlRpcClient client) throws XmlRpcException {
String sessionId = (String) client.execute("login", new Object[]{user, password});
return sessionId;
}
public static void endSession(String sessionToken, XmlRpcClient client) throws XmlRpcException {
client.execute("endSession", new Object[]{sessionToken});
}
}
正如在線路看到
對象[]請求= {orderIncrementId,新的HashMap()};
我嘗試發送一個散列映射,它實際上應該包含訂單項目標識和數量。我也嘗試發送一組對象,它不適用於它們中的任何一個。如果沒有Map或Array可用,那麼應該有什麼呢?
感謝您的幫助
您好@Robi,感謝您的回答,對不起,是我不好,我總是想說階增量ID引起了我使用的唯一一個。編輯我的問題 – Juan