帮同事看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");
本文介绍了解决Webservice调用中因缺少命名空间而导致的UnmarshallingError错误的方法。通过对比soapui工具,发现了参数传递时未正确设置命名空间的问题,并给出了具体的解决代码示例。
解决&spm=1001.2101.3001.5002&articleId=84818208&d=1&t=3&u=3d3f1a66ad9d4fd3b750ef559f00ed44)
1223
解决&spm=1001.2101.3001.11663&articleId=84818208&d=1&t=3&u=5a7c132c9e014a0a8b022a57a6b495b5)

被折叠的 条评论
为什么被折叠?



