4

help me, i'm on it about 3 weeks searching the entire www and cant make it work!

I have a WS and just want to make my app have the response. but I after correct everything unfortunately always get the folowing 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 app is using 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 SOAP UI and I can makes calls to WS with really no problems with.

<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 have tried diferent Ksoap libraries, diferent Namespaces, method_name. Diferent SoapEnvelope.VER . I can't remember everything I have tested. I'm desperate.

Thank you so much..

rmtheis
  • 5,992
  • 12
  • 61
  • 78
Jr.
  • 43
  • 1
  • 4

2 Answers2

0

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.

Jannik
  • 332
  • 1
  • 3
  • 12
  • Hi @Jannik ! With you tip I could se the uri setted in my response, so it helped me a lot, but it put the wrong Namespace see.. 08-10 09:14:12.488: INFO/System.out(362): SoapFault - faultcode: 'env:Server' faultstring: 'javax.xml.bind.UnmarshalException: unexpected element (uri:"http://system.com.br/", local:"Apgame"). Expected elements are <{http://master.system.com.br/}Apgame>,...' faultactor: 'null' detail: null You know hot to correct this? Thanks!.. – Jr. Aug 10 '11 at 12:54
  • ops and if I change the **namespaces x soap_Action** I get. 08-10 09:15:33.488: INFO/System.out(392): SoapFault - faultcode: 'env:Client' faultstring: 'Endpoint {http://system.com.br/}GetPriceWSPortType does not contain operation meta data for: {http://trans.system.com.br//}GetPrice' faultactor: 'null' detail: null – Jr. Aug 10 '11 at 12:57
0

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

Something like:

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");
...
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • 1
    Thank you guy! It worked! Eclipse says: "The method addProperty(PropertyInfo, Object) is deprecated" There is another way to do? Maybe put just one PropertyInfo with Namespace? You just helped me so much! – Jr. Aug 10 '11 at 12:45
  • I am supporting the question asked by `Jr`. If there is any other method kindly tell us – Moeez Feb 11 '17 at 03:51