我在通过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.");
}
});
}
}
答案 0 :(得分:0)
我认为你应该真正发送物业'pi'& class instance'mt“[确保对象不为null。即在您的行rpc.addProperty行中设置值]。像这样,
rpc.addProperty(pi, mt);
我通常这样做:
rpc.addProperty(pi, mt);
看看这里,它可能会有所帮助: Complex Objects and Ksoap2