java magento,Java-Android:通过SOAP API在Magento中创建客户

如果您不回答,直到可以使用它.

public void CreateNewCustomer(String email, String firstname, String lastname, String password) {

try {

env.dotNet = false;

env.xsd = SoapSerializationEnvelope.XSD;

env.enc = SoapSerializationEnvelope.ENC;

request = new SoapObject(NAMESPACE, "login");

request.addProperty("username", "+++++");

request.addProperty("apiKey", "+++++");

env.setOutputSoapObject(request);

public static HttpTransportSE androidHttpTransport = new HttpTransportSE(URL)

androidHttpTransport.call("", env);

session = env.getResponse();

sessionId = session.toString();

Log.d("sessionId", sessionId.toString());

Log.d("Create "," Creating......");

request = new SoapObject(NAMESPACE,"customerCustomerCreate");

request.addProperty("sessionId", sessionId);

// request.addProperty("product", product_id);

//-----use Kvm Serializable class to serialize the key value data-------

CreateCustomerKVMserialize createcustomerkvm = new CreateCustomerKVMserialize();

createcustomerkvm.Email = email;

createcustomerkvm.Firstname = firstname;

createcustomerkvm.Lastname = lastname;

createcustomerkvm.Password = password;

PropertyInfo pi = new PropertyInfo();

pi.setName("customerData");

pi.setValue(createcustomerkvm);

pi.setType(createcustomerkvm.getClass());

request.addProperty(pi);

env.setOutputSoapObject(request);

env.addMapping(NAMESPACE, "customerData",new CreateCustomerKVMserialize().getClass());

androidHttpTransport.call("", env);

Object customer_create = env.getResponse();

Log.d("mainactivity "," "+customer_create.toString());

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XmlPullParserException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

——— CreateCustomerKVMserialize类———–

public class CreateCustomerKVMserialize implements KvmSerializable{

public String Email;

public String Firstname;

public String Lastname;

public String Password;

// public String Websiteid;

// public String Storeid;

// public String Groupid;

public CreateCustomerKVMserialize(){}

public CreateCustomerKVMserialize(String email, String firstname, String lastname,String password) {

Email = email;

Firstname = firstname;

Lastname = lastname;

Password = password;

}

@Override

public Object getProperty(int arg0) {

// TODO Auto-generated method stub

switch(arg0)

{

case 0:

return Email;

case 1:

return Firstname;

case 2:

return Lastname;

case 3:

return Password;

}

return null;

}

@Override

public int getPropertyCount() {

// TODO Auto-generated method stub

return 4;

}

@Override

public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {

// TODO Auto-generated method stub

switch(index)

{

case 0:

info.type = PropertyInfo.STRING_CLASS;

info.name = "email";

break;

case 1:

info.type = PropertyInfo.STRING_CLASS;

info.name = "firstname";

break;

case 2:

info.type = PropertyInfo.STRING_CLASS;

info.name = "lastname";

break;

case 3:

info.type = PropertyInfo.STRING_CLASS;

info.name = "password";

break;

default:break;

}

}

@Override

public void setProperty(int index, Object value) {

// TODO Auto-generated method stub

switch(index)

{

case 0:

Email = value.toString();

break;

case 1:

Firstname = value.toString();

break;

case 2:

Lastname = value.toString();

break;

case 3:

Password = value.toString();

break;

default:

break;

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值