Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento XML-RPC API - Create Shipment from Java - Please delete this one
 
jsquintero
Jr. Member
 
Total Posts:  4
Joined:  2012-12-10
 

Hello

Im trying to create shipments for magento orders from my third party app using the XML-RPC API. Everything works great when i make the call to \\\"sales_order_shipment.create\\\" with just the order increment id, but if i try making the same call with both an order_id and a set of items and quantities, it will say \\\"Requested order not exists.\\\” Why is that? what im doing wrong? what type should be the itemQuantity object? Map? Array of objects?

heres my code

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\\\"51.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 orderIdint itemIddouble quantity{
        
try {
            XmlRpcClient client 
prepareClient();
            
String sessionId login(\\\"myUser\\\"\\\"myKey\\\"client);
            
System.out.println(sessionId);
            
Object[] request {orderId, new HashMap()};
            
client.execute(\\\"call\\\", new Object[]{sessionId\\\"sales_order_shipment.create\\\"request});
            
endSession(sessionIdclient);
        
catch (XmlRpcException MalformedURLException ex{
            Logger
.getLogger(XMLRPCAPIClient.class.getName()).log(Level.SEVEREnullex);
        
}
    }

    
public static String login(String userString passwordXmlRpcClient clientthrows XmlRpcException {
        String sessionId 
= (String) client.execute(\\\"login\\\", new Object[]{userpassword});
        return 
sessionId;
    
}

    
public static void endSession(String sessionTokenXmlRpcClient clientthrows XmlRpcException {
        client
.execute(\\\"endSession\\\", new Object[]{sessionToken});
    
}
}

As you see in the line

Object[] request = {orderId, new HashMap()};

i try sending a hashMap that actually should contain the order item id and quantity. Ive also tried sending an array of objects and it doesnt work for any of them. What sould be there insetead then if neither a Map or an Array is available?

Thank you for your help from advance

Sorry, it seems my topic got duplicated several times, please delete this one

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top