android 中的 ksoap 请求格式?
ksoap request format in android?
我在 SOAP+XML 中有基于 Magento 的 Web 服务。我正在使用 ksoap2 作为库 Web 服务调用。现在,下面是我的 API 的 magento 请求格式,名称是 "customer.list"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns:ns1="urn:Magento" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding">
<SOAP-ENV:Body>
<ns1:call>
<sessionId xsi:type="xsd:string">(My Seesion ID)</sessionId>
<resourcePath xsi:type="xsd:string">customer.list</resourcePath>
<args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">email</key>
<value xsi:type="xsd:string">(User Email ID)</value>
</item>
</item>
</args>
</ns1:call>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我为此尝试了此代码,但主要是我希望根据我给定的电子邮件 ID 对所有用户进行归档,就像我只想要电子邮件 ID 与我请求的电子邮件 ID 匹配的单个用户的数据一样,问题是我的编码是它响应所有用户列表,所以我认为我的请求的参数部分不是按照 magento 的请求格式。我是基于 SOAP 的 Web 服务的新手,所以,如果有人知道,请给我一些解释。下面的代码是我尝试过的,i
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.implicitTypes = true;
soapEnvelope.dotNet = true;
soapEnvelope.avoidExceptionForUnknownProperty=true;
soapEnvelope.setAddAdornments(false);
SoapObject soapReq = new SoapObject("urn:Magento", "call");
soapReq.addProperty("sessionId", sessionId);
String NESTED_NAMESPACE = "http://schemas.microsoft.com/2003/10/Serialization/Arrays";
SoapObject recipients = new SoapObject(NESTED_NAMESPACE, "args");
Vector<String> recp = new Vector<String>();
recp.add("email");
recipients.addProperty("key", recp);
recp = new Vector<String>();
recp.add("xyz@abc.com");
recipients.addProperty("value", recp);
soapReq.addSoapObject(recipients);
soapEnvelope.setOutputSoapObject(recipients);
HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);
httpTransport.debug = true;
try {
if (headers != null) {
httpTransport.call("urn:Magento/call", soapEnvelope, headers);
} else {
httpTransport.call("urn:Magento/call", soapEnvelope);
}
Object retObj = soapEnvelope.bodyIn;
Object result = null;
try {
result = soapEnvelope.getResponse();
} catch (SoapFault soapFault) {
soapFault.printStackTrace();
}
我已经解决了我的问题,我认为我的问题不值得减分。无论如何,我正在上传我的解决方案,
SoapSerializationEnvelopesoapEnvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=true;
soapEnvelope.implicitTypes=true;
soapEnvelope.setAddAdornments(false);
SoapObjectsoapReq=newSoapObject(NAMESPACE,"call");
soapReq.addProperty("sessionId",sessionId);
soapReq.addProperty("resourcePath","customer.list");
SoapObjectnewObj=newSoapObject();
newObj.addProperty("key","email");
newObj.addProperty("value","xyz@abc.com");
newObj.addAttribute("i:type","ns2:Map");
SoapObjectFINALoBJ=newSoapObject();
FINALoBJ.addProperty("item",newObj);
SoapObjectmain_obj=newSoapObject();
main_obj.addProperty("item",FINALoBJ);
main_obj.addAttribute("xmlns:ns2","http://xml.apache.org/xml-soap");
main_obj.addAttribute("i:type","c:Array");
main_obj.addAttribute("c:arrayType","ns2:Map[1]");
soapReq.addProperty("args",main_obj);
soapEnvelope.setOutputSoapObject(soapReq);
HttpTransportSEhttpTransport=newHttpTransportSE(url,timeOut);
httpTransport.debug=true;
try{
if(headers!=null){
httpTransport.call("urn:Magento/call",soapEnvelope,headers);
}else{
httpTransport.call("urn:Magento/call",soapEnvelope);
}
ObjectretObj=soapEnvelope.bodyIn;
Objectresult=null;
try{
result=soapEnvelope.getResponse();
}catch(SoapFaultsoapFault){
soapFault.printStackTrace();
}
我在 SOAP+XML 中有基于 Magento 的 Web 服务。我正在使用 ksoap2 作为库 Web 服务调用。现在,下面是我的 API 的 magento 请求格式,名称是 "customer.list"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns:ns1="urn:Magento" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding">
<SOAP-ENV:Body>
<ns1:call>
<sessionId xsi:type="xsd:string">(My Seesion ID)</sessionId>
<resourcePath xsi:type="xsd:string">customer.list</resourcePath>
<args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">email</key>
<value xsi:type="xsd:string">(User Email ID)</value>
</item>
</item>
</args>
</ns1:call>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我为此尝试了此代码,但主要是我希望根据我给定的电子邮件 ID 对所有用户进行归档,就像我只想要电子邮件 ID 与我请求的电子邮件 ID 匹配的单个用户的数据一样,问题是我的编码是它响应所有用户列表,所以我认为我的请求的参数部分不是按照 magento 的请求格式。我是基于 SOAP 的 Web 服务的新手,所以,如果有人知道,请给我一些解释。下面的代码是我尝试过的,i
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.implicitTypes = true;
soapEnvelope.dotNet = true;
soapEnvelope.avoidExceptionForUnknownProperty=true;
soapEnvelope.setAddAdornments(false);
SoapObject soapReq = new SoapObject("urn:Magento", "call");
soapReq.addProperty("sessionId", sessionId);
String NESTED_NAMESPACE = "http://schemas.microsoft.com/2003/10/Serialization/Arrays";
SoapObject recipients = new SoapObject(NESTED_NAMESPACE, "args");
Vector<String> recp = new Vector<String>();
recp.add("email");
recipients.addProperty("key", recp);
recp = new Vector<String>();
recp.add("xyz@abc.com");
recipients.addProperty("value", recp);
soapReq.addSoapObject(recipients);
soapEnvelope.setOutputSoapObject(recipients);
HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);
httpTransport.debug = true;
try {
if (headers != null) {
httpTransport.call("urn:Magento/call", soapEnvelope, headers);
} else {
httpTransport.call("urn:Magento/call", soapEnvelope);
}
Object retObj = soapEnvelope.bodyIn;
Object result = null;
try {
result = soapEnvelope.getResponse();
} catch (SoapFault soapFault) {
soapFault.printStackTrace();
}
我已经解决了我的问题,我认为我的问题不值得减分。无论如何,我正在上传我的解决方案,
SoapSerializationEnvelopesoapEnvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=true;
soapEnvelope.implicitTypes=true;
soapEnvelope.setAddAdornments(false);
SoapObjectsoapReq=newSoapObject(NAMESPACE,"call");
soapReq.addProperty("sessionId",sessionId);
soapReq.addProperty("resourcePath","customer.list");
SoapObjectnewObj=newSoapObject();
newObj.addProperty("key","email");
newObj.addProperty("value","xyz@abc.com");
newObj.addAttribute("i:type","ns2:Map");
SoapObjectFINALoBJ=newSoapObject();
FINALoBJ.addProperty("item",newObj);
SoapObjectmain_obj=newSoapObject();
main_obj.addProperty("item",FINALoBJ);
main_obj.addAttribute("xmlns:ns2","http://xml.apache.org/xml-soap");
main_obj.addAttribute("i:type","c:Array");
main_obj.addAttribute("c:arrayType","ns2:Map[1]");
soapReq.addProperty("args",main_obj);
soapEnvelope.setOutputSoapObject(soapReq);
HttpTransportSEhttpTransport=newHttpTransportSE(url,timeOut);
httpTransport.debug=true;
try{
if(headers!=null){
httpTransport.call("urn:Magento/call",soapEnvelope,headers);
}else{
httpTransport.call("urn:Magento/call",soapEnvelope);
}
ObjectretObj=soapEnvelope.bodyIn;
Objectresult=null;
try{
result=soapEnvelope.getResponse();
}catch(SoapFaultsoapFault){
soapFault.printStackTrace();
}