Note that there are some explanatory texts on larger screens.

plurals
  1. POPass Array using Web services in Ksoap2
    text
    copied!<p>I have to call a web service in which web service is called by kSoap2 method, now in this one node is a Array so how i can pass it.</p> <pre><code>POST /opera/OperaWS.asmx HTTP/1.1 Host: 182.71.19.26 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/SendGroupMessageNotification" &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Body&gt; &lt;SendGroupMessageNotification xmlns="http://tempuri.org/"&gt; &lt;reciverMemberId&gt; &lt;Group&gt; &lt;groupid&gt;string&lt;/groupid&gt; &lt;groupMembers&gt; &lt;Id&gt;string&lt;/Id&gt; &lt;Id&gt;string&lt;/Id&gt; &lt;/groupMembers&gt; &lt;/Group&gt; &lt;Group&gt; &lt;groupid&gt;string&lt;/groupid&gt; &lt;groupMembers&gt; &lt;Id&gt;string&lt;/Id&gt; &lt;Id&gt;string&lt;/Id&gt; &lt;/groupMembers&gt; &lt;/Group&gt; &lt;/reciverMemberId&gt; &lt;MemberId&gt;int&lt;/MemberId&gt; &lt;MESSAGE&gt;string&lt;/MESSAGE&gt; &lt;CREATEDDATE&gt;string&lt;/CREATEDDATE&gt; &lt;isUrgent&gt;boolean&lt;/isUrgent&gt; &lt;Predifnemessage&gt;string&lt;/Predifnemessage&gt; &lt;/SendGroupMessageNotification&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>So in the above web service, how i can i set the values for the reciverMemberId</p> <p>remaining parameters is set easily with the propertyInfo.</p> <p>For this i made some code as below</p> <pre><code>static class Group implements KvmSerializable { String groupid; Vector groupMembers; public Group(String groupId,Vector groupmembers) { this.groupid=groupId; this.groupMembers=groupmembers; } public Object getProperty(int i) { switch(i) { case 0: return groupid; case 1: return groupMembers; } return null; } public int getPropertyCount() { return 2; } public void setProperty(int i, Object o) { switch(i) { case 0: groupid=o.toString(); break; case 1: groupMembers=(Vector) o; break; } } public void getPropertyInfo(int i, Hashtable hshtbl, PropertyInfo pi) { switch(i) { case 0: pi.type=PropertyInfo.STRING_CLASS; pi.name="groupid"; break; case 1: pi.type=PropertyInfo.VECTOR_CLASS; pi.name="groupMembers"; break; } } } static class RereciverMemberId implements KvmSerializable { Group grp; public RereciverMemberId() { Vector grpMembers=new Vector(); grpMembers.add("29"); grpMembers.add("36"); grp=new Group("1", grpMembers); } public Object getProperty(int i) { return grp; } public int getPropertyCount() { return 0; } public void setProperty(int i, Object o) { this.grp=(Group) o; } public void getPropertyInfo(int i, Hashtable hshtbl, PropertyInfo pi) { pi.type=grp.getClass(); pi.name="Group"; } } public static void sendGroupMessageNotification() { SOAP_ACTION="http://tempuri.org/SendGroupMessageNotification"; METHOD_NAME="SendGroupMessageNotification"; SoapObject myObject = new SoapObject(NAMESPACE,METHOD_NAME); //String str="&lt;Group&gt;&lt;groupid&gt;1&lt;/groupid&gt;&lt;groupMembers&gt;&lt;Id&gt;29&lt;/Id&gt;&lt;Id&gt;36&lt;/Id&gt;&lt;/groupMembers&gt;&lt;/Group&gt;"; RereciverMemberId rec=new RereciverMemberId(); PropertyInfo pi = new PropertyInfo(); pi.setName("reciverMemberId"); pi.setValue(rec); pi.setType(rec.getClass()); myObject.addProperty(pi); PropertyInfo p = new PropertyInfo(); p.setName("MemberId"); p.setValue(1); p.setType(PropertyInfo.INTEGER_CLASS); myObject.addProperty(p); p = new PropertyInfo(); p.setName("MESSAGE"); p.setValue("Test Message From JAVA"); p.setType(PropertyInfo.STRING_CLASS); myObject.addProperty(p); p = new PropertyInfo(); p.setName("CREATEDDATE"); p.setValue("15 Dec 2011"); p.setType(PropertyInfo.STRING_CLASS); myObject.addProperty(p); p = new PropertyInfo(); p.setName("isUrent"); p.setValue(false); p.setType(PropertyInfo.BOOLEAN_CLASS); myObject.addProperty(p); p = new PropertyInfo(); p.setName("Predifnemessage"); p.setValue("Hello"); p.setType(PropertyInfo.STRING_CLASS); myObject.addProperty(p); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(myObject); HttpTransportSE transport = new HttpTransportSE(URL); try { transport.call(SOAP_ACTION, envelope); } catch (IOException ex) { Logger.getLogger(SoapWebServices.class.getName()).log(Level.SEVERE, null, ex); } catch (XmlPullParserException ex) { Logger.getLogger(SoapWebServices.class.getName()).log(Level.SEVERE, null, ex); } try { SoapPrimitive result = (SoapPrimitive) envelope.getResponse(); System.out.println(result.toString()); } catch (SoapFault ex) { Logger.getLogger(SoapWebServices.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload