I am using spring boot to call a rest service that returns XML string. if I call the service from postman it returns the correct xml string , which is similar to this (shortened for simplicity):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RateResponse>
<RateQueryResponses>
<rateQueryResponseList>
<carrierCode>CUST</carrierCode>
<mode>SLTL</mode>
< ... more content here .... >
<declaredValue>0.0</declaredValue>
<routingGuideLane>
<destLocType></destLocType>
<frequency></frequency>
<laneDest></laneDest>
<origLocType></origLocType>
</routingGuideLane>
<routingGuideLaneCarrierDetails>
<capacityVolume>0</capacityVolume>
<carrierCode>CUST</carrierCode>
<rank></rank>
<tier></tier>
</routingGuideLaneCarrierDetails>
<totalRevenue>
<rate>0.0</rate>
<revenueAccessorialList>
<accessorialCode>FUEL</accessorialCode>
<accessorialRevenue>0.0</accessorialRevenue>
<approved>true</approved>
<calculationMethod>PCT</calculationMethod>
<minimumRate>0.0</minimumRate>
<payeeCarrierId>-2147483648</payeeCarrierId>
<rate>0.735</rate>
</revenueAccessorialList>
<revenueAccessorialList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<revenueAccessorialList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<stopOffRevenue>0.0</stopOffRevenue>
<totalAccessorialRevenue>0.0</totalAccessorialRevenue>
</totalRevenue>
</rateQueryResponseList>
</RateQueryResponses>
</RateResponse>
the problem I am having when I call this service from spring boot, is that it returns the full xml except the <revenueAccessorialList> elements.
This element is supposed to repeat (it is a list) but for some unknown reason the vendor who supports the service is returning first element in the list and then 2 null elements (as you can see <revenueAccessorialList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
I don't mind if I don't get the null elements, but I am not getting the first one either from spring boot.
This is the code I am using: (I tried postForEntity and exchange)
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
HttpEntity<QueryRequest> requestlEntity = new HttpEntity<>(rreq, headers);
ResponseEntity<String> qrlEntity = null;
return restTemplate.exchange(serviceEp, HttpMethod.POST, requestlEntity, String.class);
// return restTemplate.postForEntity(serviceEp, requestlEntity, String.class);
Both methods return the full xml without those elements. Any ideas? is there anything I can try other than restTemplate with springboot?
As I mentioned, this works fine from postman and returns the full string
Thank you