2
I’m consuming a webservice on android. But I’m having trouble with the following method:
public static SoapObject Retornar_Lista_UFs(int pCodigo_Entidade) {
Financeiro_NG oFinanceiro = new Financeiro_NG();
SoapObject request = new SoapObject(oFinanceiro.WSDL_TARGET_NAMESPACE, oFinanceiro.OPERATION_NAME_UF);
PropertyInfo pi = new PropertyInfo();
pi.setName("pCodigo_Entidade");
pi.setValue(pCodigo_Entidade);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(oFinanceiro.SOAP_ADDRESS);
SoapObject response = null;
try {
httpTransport.call(oFinanceiro.SOAP_ACTION_UF, envelope);
response = (SoapObject) envelope.bodyIn;
} catch (Exception exception) {
Log.d("Erro", exception.toString());
}
return response;
}
It is a simple method to search the UF list in the database.
But when calling this method on android gives the error unexpected end of stream
;
In debug it even shows the list there, and I don’t know what that error means. I spent hours looking for a solution.
If it changes the envelope.bodyIn
for envelope.getResponse()
the error continues.
EDIT:
I managed to get around the problem by adding another catch:
catch (ProtocolException exception)
{
response = (SoapObject) envelope.bodyIn;
}
So it returns the list if there is the error described, which is clearly not the right thing to do, but I still can’t solve the problem.