I'm building a service that sends a POST request to UPS track package API. In PostMan, this call returns a 200 with this URL and these POST params
URL: https://onlinetools.ups.com/ups.app/xml/Track
Body: form-data
Params:
UPSSecurity
<?xml version="1.0"?> <AccessRequest xml:lang="en-US"> <AccessLicenseNumber>REDACTED</AccessLicenseNumber> <UserId>REDACTED</UserId> <Password>REDACTED</Password> </AccessRequest>
Body
<?xml version="1.0"?> <TrackRequest xml:lang="en-US"> <Request> <TransactionReference> <CustomerContext>Your Test Case Summary Description</CustomerContext> <XpciVersion>1.0</XpciVersion> </TransactionReference> <RequestAction>Track</RequestAction> <RequestOption>activity</RequestOption> </Request> <TrackingNumber>REDACTED</TrackingNumber> </TrackRequest>
Our application defines clients using OpenFeign and Spring annotations. The solution I'm going to try is to define my FeignClient like this:
interface UPSClient {
@Headers({"SOAPAction: http://onlinetools.ups.com/webservices/TrackBinding/v2.0","Content-Type: application/xml"})
@PostMapping(
value = "/Track",
consumes = MediaType.TEXT_XML_VALUE,
produces = MediaType.TEXT_XML_VALUE
)
ResponseEntity<TrackResponse> getTrackResponse(@RequestBody UPSRequest upsRequest);
and define MyRequestObject as
public class UPSRequest {
String UPSSecurity; // UPSSecurity is a POJO generated from UPS wsdl and marshalled into an XML String
String Body; // Body is a POJO generated from UPS wsdl and marshalled into an XML String
}
Is there a cleaner approach that anyone could recommend? The TrackResponse
returned from the UPS endpoint can be handled by a custom SOAPDecoder and shouldn't be an issue