Skip to Content
author's profile photo Former Member
Former Member

HTTP 415 when using custom xml input adapter

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Dec 15, 2016 at 10:55 AM

    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,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 17, 2017 at 06:00 AM

    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>
     ... 
    
    
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.