سؤال

Is there a way in CXF to implement a Restful webservice which will accept different xml requests using one Web service method?

e.g. Can one create a Restful endpoint to accept this type of XML through one web service method?

  <Data>
  <Book>BN1</Book>
  </Data>

& this too using same web service method?

<Data>
  <Disk>DN1</Disk>
  </Data>
هل كانت مفيدة؟

المحلول 2

Ok so I am using this for generic XML.

public interface Callback {

    @POST
    @Path("/submit")
    @Consumes("text/xml")
    @Produces("application/xml")
    public Response submit(String incomingXML);


}

Basically I am getting whole xml as a string in my method body, As CXF is not parsing it, it can remain generic.

نصائح أخرى

I think this post: Apache CXF: Consume XML POST payload... shows a good example of how to declare a CXF REST service as receiving POST XML data.

For your example of handling different XML content, instead of 'Bean' in the above you'd have an @XmlRootElement that's the Data, with a child that's a @XmlAnyElement.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top