androidmagentosoapksoap2magento-soap-api

ksoap request format in android?


I have Magento based web services in SOAP+XML. I am using ksoap2 as library web service calling. Now, below is my magento request format for a API which name is, "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>

I try this code for it but main thing is here is that i want filer all users as per my given email id , like i want data of only single user which email id matches with my requested email id and problem is with my coding is that it respond all users list so i thing argument portion of my request in not as per magento's request format. And i am new in SOAP based web service so, if any one knows then give me some explanation. Below code what i have tried, 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();
}

Solution

  • I have solved my problem, i think my question doesn't deserve minus rating. Anyway i am uploading my solution as below,

    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();
    }