2
I’m trying to make a query in the WEB SERVER implemented in PHP in this link.
In the web service I have to send a request by passing the parameters Imei, password, operation.
public class cargaColetaDao {
private static final String URL = "http://www.termaco.com.br/cargasmobile/cargasmobiledev.php?wsdl";
private static final String targetNamespace = "urn:server.smbc";
private static final String SMBC = "smbc";
public void smbcRequest(smbc smbc) {
SoapObject carregarDados = new SoapObject(targetNamespace, SMBC);
SoapObject spSmbc = new SoapObject(targetNamespace, "smbc");
spSmbc.addProperty("<smbc>", "smbc");
spSmbc.addProperty("<imei>", smbc.getImei());
spSmbc.addProperty("<senha>", smbc.getSenha());
spSmbc.addProperty("<operacao>", smbc.getOperacao());
carregarDados.addSoapObject(spSmbc);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(carregarDados);
envelope.implicitTypes = true;
HttpTransportSE http = new HttpTransportSE(URL);
try {
http.call("urn:smbc", envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
Log.e("Resultado ****:", response.toString());
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
He was supposed to return the following XML...
<SOAP-ENV:Envelope 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/">
<SOAP-ENV:Body>
<ns1:smbcResponse xmlns:ns1="urn:server.smbc">
<return xsi:type="xsd:string">
<![CDATA[<smbc>
<operacao>1</operacao>
<item>
<empcodigo>FOR</empcodigo>
<codigo>1234</codigo>
<tipo>1</tipo>
<nome>Daniel</nome>
<endereco>Rua D, 300</endereco>
<ordem>1</ordem>
<status>2</status>
<parada>2</parada>
</item>
<retorno>1</retorno>
<descricao>Carga Realizada com sucesso.</descricao>
</smbc>]]>
</return>
</ns1:smbcResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
but he’s casting the exception saying that the namespace is not right.
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions targetNamespace='urn:server.smbc'>@2:431 in java.io.InputStreamReader@2ed5f2c1)
I’ve been trying to figure it out for a week and I can’t.
From now on, thank you very much.
I’m going through a problem similar to this, could help me?
– rodrigo.oliveira