【发布时间】:2018-05-08 07:47:00
【问题描述】:
String example =
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><ns2:farm xmlns:ns2=\"http://adamish.com/example/farm\"><horse height=\"123\" name=\"glue factory\"/></ns2:farm></soapenv:Body></soapenv:Envelope>";
这是我的字符串格式的肥皂 xml,我需要如何在 Farm 对象中形成它。Farm 是我的自定义类,任何库都可以使用
使用此代码后 m 得到异常
SOAPMessage message = MessageFactory.newInstance().createMessage(null,
new ByteArrayInputStream(example.getBytes()));
Unmarshaller unmarshaller = JAXBContext.newInstance(Farm.class).createUnmarshaller();
SubscribeProductReq farm = (Farm)unmarshaller.unmarshal(message.getSOAPBody().extractContentAsDocument());
意外元素(uri:“http://yyyyyy.yyyyy*********”,本地:“农场”)。预期元素是
【问题讨论】: