帮同事看Webservice调用问题, 网上找了半天,只有问题并没有实际解决答案,报错如下:
Unmarshalling Error: unexpected element (uri:"", local:"billType"). Expected elements are <{http://alms.acconsys.com/types/message/A4Interface/SendbillInfosToALMS}billStatus>
与soapui工具对比, 最终发现是因为传递参数没有命名空间导致的,解决办法如下:
报错代码:
QName ename = new QName(ns, "SendbillInfosToALMSRequest","com");
SOAPBodyElement ele = body.addBodyElement(ename);
// 传递参数
ele.addChildElement("billType").setValue("aaa");
ele.addChildElement("billStatus").setValue("path");
ele.addChildElement("billNum").setValue("path");
加命名空间(解决):
QName ename = new QName(ns, "SendbillInfosToALMSRequest","com");
SOAPBodyElement ele = body.addBodyElement(ename);
ele.addChildElement("billType", "sen", "http://alms.acconsys.com/types/message/A4Interface/SendbillInfosToALMS").setValue("1");
ele.addChildElement("billStatus", "sen", "http://alms.acconsys.com/types/message/A4Interface/SendbillInfosToALMS").setValue("2");
ele.addChildElement("billNum", "sen", "http://alms.acconsys.com/types/message/A4Interface/SendbillInfosToALMS").setValue("3");