I am a begginer in android,here I have activity that use web service:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
GetBoundData val = new GetBoundData() {
};
PropertyInfo pi = new PropertyInfo();
pi.setName("GetBoundData");
pi.setValue(val);
pi.setType(GetBoundData.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
Marshal floatMarshal = new MarshalFloat();
envelope.addMapping(NAMESPACE, GetBoundData.class.getSimpleName(), GetBoundData.class);
floatMarshal.register(envelope);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug =true;
TextView t = (TextView)this.findViewById(R.id.resultbox);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
System.out.println("aht requestDump is :"+androidHttpTransport.requestDump);
System.out.println("aht responseDump is :"+androidHttpTransport.responseDump);
} catch (Exception e) {
e.printStackTrace();
}
try {
Object result = (Object) envelope.bodyIn;
String s = result.toString();
t.setText(s);
} catch (ClassCastException e) {
// TODO Auto-generated catch block
e.printStackTrace();
t.setText("1");
}
and in GetBoundData class :
public abstract class GetBoundData implements KvmSerializable {
String Bound = "((-0.00021792948245596397, -0.0002648681402206421), (0.00021792948246868618, 0.0002648681402206421))";
String Zoom ="21";
public Object getProperty(int arg0) {
switch (arg0){
case 0:
return Bound;
case 1:
return Zoom;
default:
return null;
}
}
public int getPropertyCount() {
return 2;//because you have 2 parameters
}
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
switch(arg0)
{
case 0:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "Bound";
break;
case 1:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "Zoom";
break;
default:break;
}
}
public void setval(String bound, String zoom) {
Bound = bound;
Zoom = zoom;
}
public void setProperty(int arg0, Object arg1) {
switch(arg0)
{
case 0:
Bound = (String)arg1;
break;
case 1:
Zoom = (String)arg1;
break;
default:
break;
}
} }
and this is webservice xml
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="GetBoundData">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Bound" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Zoom" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetBoundDataResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetBoundDataResult" type="tns:ArrayOfAnyType"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfAnyType">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="anyType" nillable="true"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
here webservice sample:
request:
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<GetBoundData xmlns="http://tempuri.org/">
<Bound>string</Bound>
<Zoom>string</Zoom>
</GetBoundData>
</soap:Body>
</soap:Envelope>
response:
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<GetBoundDataResponse xmlns="http://tempuri.org/">
<GetBoundDataResult>
<anyType />
<anyType />
</GetBoundDataResult>
</GetBoundDataResponse>
</soap:Body>
</soap:Envelope>
but show this :
SoapFault - faultcode: 'soap:Server'
faultstring: 'Server was unable to process request. ---> Object reference not set to an
instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node@44efb360
I used soapobject with getresponse() but error occurred