Hi !
I inmediately fall in love with your project, and start using it to write/parse XML content in our application, but found one xml file that's blocking me completely, as i feel unable to make it worl.
May i get some help from you ?
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body><ns1:storeTokenResponse xmlns:ns1="http://recurring.services.adyen.com">
<ns1:result><additionalData xmlns="http://recurring.services.adyen.com" xsi:nil="true" /><alias xmlns="http://recurring.services.adyen.com">B133243153928547</alias><aliasType xmlns="http://recurring.services.adyen.com">Default</aliasType><params xmlns="http://recurring.services.adyen.com" xsi:nil="true" /><pspEchoData xmlns="http://recurring.services.adyen.com" xsi:nil="true" /><pspReference xmlns="http://recurring.services.adyen.com">8514873382743402</pspReference><recurringDetailReference xmlns="http://recurring.services.adyen.com">8414873382748121</recurringDetailReference><redirectType xmlns="http://recurring.services.adyen.com" xsi:nil="true" /><redirectUrl xmlns="http://recurring.services.adyen.com" xsi:nil="true" /><result xmlns="http://recurring.services.adyen.com">Success</result></ns1:result></ns1:storeTokenResponse></soap:Body></soap:Envelope>
This is the xml itself, as arrives from the network, but all i can get is to retrieve the Body tag.
From there, everything is null.
This is my Beam :
public interface SOAPResponse {
@XBRead("/soap:Envelope/soap:Body")
Body getBody();
interface Body {
@XBRead("./ns1:storeTokenResponse/ns1:result")
Result getResult();
}
interface Result {
@XBRead("./ns1:alias")
String getAlias();
@XBRead("./ns1:aliasType")
String getAliasType();
@XBRead("./ns1:pspReference")
String getPspReference();
@XBRead("./ns1:recurringDetailReference")
String getRecurringDetailReference();
@XBRead("./ns1:result")
String getResult();
}
}
and this is my test-code
@Test
public void canParseXML() throws Exception{
String content = new String(Files.readAllBytes(Paths.get("soap.xml")));
SOAPResponse soapResponse = projector.onXMLString(content.trim())
.createProjection(SOAPResponse.class);
Assert.assertNotNull(soapResponse.getBody());
Result result = soapResponse.getBody().getResult();
Assert.assertEquals("B133243153928547",result.getAlias());
Assert.assertEquals("Default",result.getAliasType());
Assert.assertEquals("8514873382743402",result.getPspReference());
Assert.assertEquals("8414873382748121",result.getRecurringDetailReference());
Assert.assertEquals("Success",result.getResult());
}
And yes, by using XPath online on the xml, the PspReference attributes is retrieved by using "ns1" prefix.
Thanks a lot, i really appreciate your project.
bug