Badgerfish is one of the JSON conventions supported by CXF. To use it with CXF RS Client, you need to add both cxf-rt-rs-extension-providers and cxf-rt-rs-client to your dependencies. Then you can create a JSON provider and pass it to the web client to make request. The following example calls the D&B Direct API sandbox to retrieve some sample data.
Bean declaration:
@XmlRootElement public class SampleData{ ... }
Code to map JSON to the bean:
JSONProvider<SampleData> provider = new JSONProvider<>(); provider.setConvention("badgerfish"); //Configure the provider as needed provider.setSerializeAsArray(true); provider.setDropRootElement(true); provider.setUnmarshallAsJaxbElement(true); provider.setConvertTypesToStrings(true); WebClient client = WebClient.create("https://direct.dnb.com", Collections.singletonList(badgerFishJson)); client = client.accept("application/json").path("/V5.0/organizations") .query("CountryISOAlpha2Code", "US").query("SubjectName", "GORMAN2 MANUFACTURING") .query("match", true).query("MatchTypeText", "Basic").query("TerritoryName", "CA"); client = client.header("Authorization", "xxxxxx"); SampleData result = client.get(SampleData.class);