java如何将soap xml转换为自定义对象
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>";
下面是字符串格式的soap xml,我需要如何在场对象中形成它。Farm是我的自定义类,任何库都是现成的
使用此代码后,我得到了异常
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*******”,本地:“场”)。预期要素为<;{}农场>
共 (0) 个答案