cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP 415 when using custom xml input adapter

Former Member
0 Kudos

I am creating a custom input adapter for Datahub, and it need to accept XML input.

Like csv-web-service adapter I am using @Path("/data-feeds/INVENTORY_FEED/items/RawStockLevel") but I changed MediaType to consume APPLICATION_XML.

When I start datahub everything is loaded fine, but when using the following curl command HTTP 415 is returned.

curl -u admin:nimda --data-binary @somefile.xml -H "Content-Type:application/xml" http://localhost:8080/datahub-webapp/v1/data-feeds/INVENTORY_FEED/items/RawStockLevel

I have tried to modify the path so it don't clash with the csv-web-service adapter, but that results in another error.

How can I make application/xml a valid MediaType?

The feed type INVENTORY_FEED and RawStockLevel model is not the problem, as they are all good when using the csv-web-service adapter.

mpern
Employee
Employee
0 Kudos

Can you upload your log?

Additionally, I do not think you can use the path /data-feeds/... because it is part of the REST API of the datahub, so your controller is probably never called.

Former Member
0 Kudos

How can I change the path to something else? I have tried to set @path("/INVENTORY_FEED") but that didn't do the trick. It return HTTP 404, so I guess I am missing a mapping somewhere.

The stack trace is attachedlink text

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Thomas,

I've just been through the same painful exercise of trying to get my XML content to be ingested by a custom XML adapter. I also had the 415 issues and then changed my path mapping to a custom one in case it clashed with the existing path and ended up with 404s. After all my searches I've decided to have a look at the datahub web.xml and discovered that the Data Hub Web Services servlet to be the culprit.

In the web.xml jersey has been configured to scan ONLY packages that starts with "com" or "de". Since I live in Australia and my packages typically starts with "au" this would never work! After adding "au" to the list everything started to work. Suddenly no more 404s and my breakpoints are also working.

This is such a ridiculous issue, but I burnt quite a few hours to discover why my XML adapter failed to work.

Hope this helps you an anybody else with a similar issue.

Cheers, Wikus

 web.xml extract
 
 ...
                 <init-param>
                         <param-name>jersey.config.server.provider.packages</param-name>
                         <param-value>com;de;au</param-value>
                 </init-param>
 ... 


0 Kudos

Hi Thomas,

Please see how your custom class may look like:

 @Path("/custom/data-feeds/{feedName}/items/{type}")
 @Consumes(MediaType.APPLICATION_XML)
 public class CustomImportResource
 {
     @POST
     public Response importXmlFile(@PathParam("feedName") final String feedName, @PathParam("type") final String type, final InputStream in) throws ValidationException
     {
         //YOUR CODE HERE
         return Response.ok().build();
     }
 }

Best Regards,