Проблема в отправке Комплексных параметров в KSOAP - PullRequest
1 голос
/ 11 ноября 2011

Я сталкиваюсь с исключением при отправке параметров сложного класса через wsdl.

В моем ответе я получаю этот журнал:

Exception: SoapFault - faultcode: 'S:Server' faultstring: 'javax.xml.bind.UnmarshalException - with linked exception:[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,471]Message: Element type "systemGenerated" must be followed by either attribute specifications, ">" or "/>".]' faultactor: 'null' detail: org.kxml2.kdom.Node@f4fb007fRequest:::::::::::::::::::::::::::::::::::0Access00000000 BuyLimitLimit02233.000000001000.00.00.0
Response>>>>>>>in exceptionnnn>>>>>>>>>>S:Serverjavax.xml.bind.UnmarshalException - with linked exception:[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,471]Message: Element type "systemGenerated" must be followed by either attribute specifications, ">" or "/>".]javax.xml.bind.UnmarshalException - with linked exception:

Вот мой фрагмент кода для этого.Пожалуйста, предоставьте мне решение для этого.

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);


            MarshalDouble md = new MarshalDouble();// **this class is made to parse the double values**

            md.register(envelope);

            SoapObject rpc = new SoapObject(serviceNamespace, "getTradeOrderTotal");  

            envelope.dotNet = false;

            envelope.setOutputSoapObject(rpc);

            envelope.encodingStyle = SoapSerializationEnvelope.XSD;



            envelope.addMapping(serviceNamespace, "MTradeOrder", new MTradeOrder().getClass());


            MTradeOrder mt = new MTradeOrder(); //This is my complex class implementing kvmserializable.


         /*   mt.portfolioName=AppScreen.name2;
            mt.securityName=AppScreen.symbol11;  // These are the parameters that i am setting to my complex class
            mt.orderType=AppScreen.ordertype;
            mt.priceType=AppScreen.Pricetype;
            mt.quantityRequested=AppScreen.quantity1;
            mt.orderTermName=ActiveTradeOrder.orderterm;
            mt.limitPrice=AppScreen.limitprice;*/


            PropertyInfo pi = new PropertyInfo();
         //   pi.type=MarshalDouble.class;


            rpc.addProperty("arg0", new MTradeOrder());




            HttpTransportBasicAuth ht = new HttpTransportBasicAuth(serviceUrl, AppScreen.wsunS, AppScreen.wspwdS);
            ht.debug = true;

            String result;
            try
            {

                ht.call(soapAction, envelope);

                result = (envelope.getResponse()).toString();

                System.out.println("Request::::::dump::::::::::::::::::::::::::::: \n" + ht.requestDump);

                System.out.println("Response>>>>>>>>>>>>>>>>> \n" + ht.responseDump);


                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run()
                    {
                        Dialog.alert("Login Successful!");
                    }
                });

            }
            catch (Exception ex)
            {
                result = ex.toString();
                System.out.println("Exception: " + result);
                System.out.println("Request::::::::::::::::::::::::::::::::::: \n" + ht.requestDump);
                System.out.println("Response>>>>>>>in exceptionnnn>>>>>>>>>> \n" + ht.responseDump);
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run()
                    {
                        Dialog.alert("Login Unsuccessful!\nPlease try again.");
                    }
                });
            }

        }

1 Ответ

0 голосов
/ 17 ноября 2011

Я думаю, что вы действительно должны отправлять свойство 'pi' & экземпляр класса 'mt' [убедитесь, что объект не нулевой. т.е. установить значения] в вашей строке rpc.addProperty line. Вот так

<code>rpc.addProperty(pi, mt);

Обычно я делаю это так:



    String CLASS_NAME = "Complex object class name"; // set this according to your wsdl complex object name
    PropertyInfo pi = new PropertyInfo();
    pi.name = (CLASS_NAME);
    pi.type = mt.getClass(); // class instance used with get class
    request.addProperty(pi, mt); // add the property


    // finally add mapping
    final SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    env.addMapping(NAMESPACE, CLASS_NAME, new MTradeOrder().getClass());

 

Взгляните сюда, это может помочь: Сложные объекты и Ksoap2

...