Android, Ksoap, webService

help me, Iโ€™ve been around for three weeks browsing the whole site and canโ€™t get it to work!

I have WS and just want my application to have an answer. but after the right thing, unfortunately, I always get the following error!

08-09 15:29:30.930: INFO/System.out(1800): That is the bodyin envelope: SoapFault - Faultcode: 'env:Server' faultstring: 'javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Apgame"). Expected elements are <{http://master.system.com.br/}Apgame>, <{http://master.system.com.br/}numberSerie>, <{http://master.system.com.br/}idPost>, faultactor: 'null' detail: null 

My application uses this.

 private void getSOAPRequest() { //no matter what I put here in SOAP_ACTION it makes no difference String SOAP_ACTION = "http://master.system.com.br/"; String NAMESPACE = "http://system.com.br/"; String METHOD_NAME = "GetPrice"; String URL = "http://12.12.12.111/MasterWS/GetPrice?WSDL"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("Apgame", "8"); request.addProperty("numberSerie", "31345"); request.addProperty("idPost", "4"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace();} System.out.println("That is the bodyin envelope: "+ envelope.bodyIn); } 

I have a SOAP user interface and I can call WS with really no problem.

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tran="http://master.system.com.br/" xmlns:ws="http://system.com.br/"> <soapenv:Body> <ws:GetPrice> <tran:Apgame>8</tran:Apgame> <tran:numberSerie>31345</tran:numberSerie> <tran:idPost>4</tran:idPost> </ws:GetPrice> </soapenv:Body> </soapenv:Envelope> 

I tried different Ksoap libraries, different namespaces, method name. Miscellaneous SoapEnvelope.VER. I canโ€™t remember everything that I checked. I'm desperate.

Thank you very much.

+4
source share
2 answers

You must provide a namespace for each property. Try the overloaded version of addProperty and set up a PropertyInfo containing both name and namespace for each property.

Sort of:

 String TRAN_NAMESPACE = "http://master.system.com.br/"; ... SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); PropertyInfo apGame = new PropertyInfo(); apGame.name = "Apgame"; apGame.namespace = TRAN_NAMESPACE; request.addProperty(apGame, "8"); ... 
0
source

Do it like this:

 String SOAP_ACTION = "http://master.system.com.br/"; String NAMESPACE = "http://system.com.br/"; String METHOD_NAME = "GetPrice"; String URL = "http://12.12.12.111/MasterWS/GetPrice?WSDL"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("Apgame", "8"); request.addProperty("numberSerie", "31345"); request.addProperty("idPost", "4"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); try { HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive result = (SoapPrimitive)envelope.getResponse(); } catch (Exception e) { } 

If your Uri variables are correct, this should do the trick.

0
source

All Articles