I'm trying to pass back 2 strings from my php nusoap server to my ksoap2 client but ksoap2 isn't spliting the response from nusoap into different properties.
Here's my class for making the complex object in java.
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class ArrayOfStrings implements KvmSerializable {
public String Status;
public String Data;
public ArrayOfStrings(){}
public ArrayOfStrings(String status, String data) {
Status=status;
Data=data;
}
@Override
public Object getProperty(int arg0) {
// TODO Auto-generated method stub
switch (arg0) {
case 0:
return Status;
case 1:
return Data;
}
return null;
}
@Override
public int getPropertyCount() {
// TODO Auto-generated method stub
return 2;
}
@Override
public void getPropertyInfo(int index, Hashtable hashtbl, PropertyInfo pi) {
// TODO Auto-generated method stub
switch (index) {
case 0:
pi.type=PropertyInfo.STRING_CLASS;
pi.name="Status";
break;
case 1:
pi.type=PropertyInfo.STRING_CLASS;
pi.name="Data";
default: break;
}
}
@Override
public void setProperty(int index, Object o) {
// TODO Auto-generated method stub
switch (index) {
case 0:
Status = o.toString();
break;
case 1:
Data = o.toString();
break;
default: break;
}
}
}
Here's the code for adding the complexType in PHP nusoap.
$server->wsdl->addComplexType("ArrayOfStrings",
"complexType",
"struct",
"",
"SOAP-ENC:Array",
array('Status'=> array('name' => 'Status', 'type' => 'xsd:string'),
'Data'=> array('name' => 'Data', 'type' => 'xsd:string'))
);
$server->register("appswitch",
array( "app" => "xsd:string",
"content" => "xsd:string"),
array("ArrayOfStrings" => "tns:ArrayOfStrings"),
"urn:webservices",
"urn:Submit#appswitch",
"rpc",
"encoded",
"G4Apps Webservices Gateway");
Any ideas?
Edit: Here's the soap response from php (Yes, I know it's an error. host provider is having issues)
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:webservices">
<SOAP-ENV:Body>
<ns1:appswitchResponse xmlns:ns1="http://secure.g4apps.com/webservices/">
<return xsi:type="tns:ArrayOfStrings">
<Status xsi:type="xsd:string">error</Status>
<Data xsi:type="xsd:string">
Soap Service failed to insert data:
INSERT INTO phonelog (AppID,TransactionType, TransactionSubType, VirtualTagNo, SmartphoneID, TimeStampEvent, TimeStampLog, GPSLat, GPSLong, TruckID, TruckOdometer, TruckEngType)
VALUES ('A1','M1','E1','AT333AT333','9055627513','2012-02-02 02:02:02','2012-02-02 02:02:02','-454545.343434','434343.232323','A334A334A334A443X','1000000','3434')
</Data>
</return>
</ns1:appswitchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I guess I was barking up the wrong tree. I don't need the ArrayOfStrings class at all to pull values out of my response.
heres my code snipit.
SoapObject ks= (SoapObject)env.bodyIn;
SoapObject inner = (SoapObject)ks.getProperty("return");
String Status = inner.getProperty("Status").toString();
String Data = inner.getProperty("Data").toString();
//System.out.println(ht.requestDump);
//System.out.println(ht.responseDump);
System.out.println(Status.trim());
System.out.println(Data.trim());
I guess I was barking up the wrong tree. I don't need the ArrayOfStrings class at all to pull values out of my response.
heres my code snipit.
SoapObject ks= (SoapObject)env.bodyIn;
SoapObject inner = (SoapObject)ks.getProperty("return");
String Status = inner.getProperty("Status").toString();
String Data = inner.getProperty("Data").toString();
//System.out.println(ht.requestDump);
//System.out.println(ht.responseDump);
System.out.println(Status.trim());
System.out.println(Data.trim());