我想創建銷售訂單發票使用Magento API在android應用程序使用XMLRPC.I使用方法「sales_order_invoice.create」創建發票。此方法是給我發票ID在magento wiki中提到的給定數量的響應中。但問題是發票數量未在magento商店更新。其他事情是訂單狀態正在更改爲處理,這是正確的,並且創建的發票的條目也是出現在商店的發票清單中,但它顯示付款金額爲$ 0.0這是不正確的。創建發票方法是不正常的Magento API
我不知道在撥打sales_order_invoice.create之前是否需要調用另一種方法,或者在方法中是否有任何問題?
下面是調用方法我的代碼一些部分:
import java.util.HashMap;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class MagentoStore extends Activity {
private XMLRPCClient client;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String sessionId = "";
client = new XMLRPCClient("http://www.mystore.com/index.php/api/xmlrpc");
try {
sessionId = (String)client.call("login", "tester", "tester");
Log.d("MY_XMLRPC_SUCCESS_SESSION_ID", sessionId);
}
catch (XMLRPCException e) {
Log.d("MY_XMLRPCException_MSG", e.getMessage());
}
Object salesorderInfo = null;
Object[] methodParams = new Object[]{"100000028"};
Object[] callParams = new Object[]{sessionId,"sales_order.info", methodParams};
String salesorderinvoice= null;
try {
salesorderInfo = (Object)client.callEx("call",callParams);
HashMap map = (HashMap)salesorderInfo;
Object[]items=(Object[])map.get("items");
for(Object item :items)
{
HashMap itemlist=(HashMap)item;
String item_id=(String)itemlist.get("item_id");
int itemids=Integer.parseInt(item_id);
String base_price=(String)itemlist.get("base_price");
if(base_price.equals("0.0000"))
{
continue;
}
String name=(String)itemlist.get("name");
Double qty=1.0;
String qty_ordered =(String)itemlist.get("qty_ordered");
String qty_invoiced=(String)itemlist.get("qty_invoiced");
Object[] methodParams1 = new Object[]{"100000028",itemids,qty};
Object[] callParams1 = new Object[]{sessionId,"sales_order_invoice.create", methodParams1};
salesorderinvoice= (String)client.callEx("call",callParams1);
}
} catch (Exception e) {
Log.d("APP_INFO", "Exception: " + e.getMessage());
}
}
}
人有任何想法? 在此先感謝
您沒有收到此錯誤:: 07-17 06:23:58.895:WARN/System.err(25812):java.net.UnknownHostException:主機未解決:cws16:80 07-17 06:23: 58.916:WARN/System.err(25812):在java.net.Socket.connect(Socket.java:1037) 07-17 06:23:58.926:WARN/System.err(25812):at org.apache。 http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117) 07-17 06:23:58.926:WARN/System.err(25812):at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection( DefaultClientConnectionOperator.java:129) 07-17 06:23:58.926:WARN/System.err(25812):at org.apache。 – 2012-07-18 10:34:30
我使用相同的代碼,但得到這個錯誤...請Krushnakant幫我... Regargs。 – 2012-07-18 10:35:13
我正在使用我的本地服務器爲此..並且我知道我只有url的問題...我使用的URL爲「http://cws24/magento/index.php/api/xmlrpc」.. 。它給了我unknownhost例外 – 2012-07-18 10:55:37