Examples of JAXBElementProvider


Examples of org.apache.cxf.jaxrs.provider.JAXBElementProvider

    }
   
    @Test
    public void testPostGeneratedBook() throws Exception {
        String baseAddress = "http://localhost:" + PORT + "/the/generated/bookstore/books/1";
        JAXBElementProvider provider = new JAXBElementProvider();
        provider.setJaxbElementClassMap(Collections.singletonMap(
                                          "org.apache.cxf.systest.jaxrs.codegen.schema.Book",
                                          "{http://superbooks}thebook"));
       
        WebClient wc = WebClient.create(baseAddress,
                                        Collections.singletonList(provider));
View Full Code Here

Examples of org.restlet.ext.jaxrs.internal.provider.JaxbElementProvider

    }

    @SuppressWarnings("all")
    public static void main(String[] args) throws Exception {
        Person person = new Person("vn", "nn");
        JaxbElementProvider jaxbElementProvider = new JaxbElementProvider();
        jaxbElementProvider.contextResolver = new ContextResolver<JAXBContext>() {
            public JAXBContext getContext(Class<?> type) {
                return null;
            }
        };
        JAXBElement<Person> jaxbElement = new JAXBElement<Person>(new QName(
                "xyz"), Person.class, person);
        jaxbElementProvider.writeTo(jaxbElement, Person.class, Person.class,
                null, null, null, System.out);

        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><person><firstname>vn</firstname><lastname>nn</lastname></person>";

        Type type = new ParameterizedType() {
            public Type[] getActualTypeArguments() {
                return new Type[] { Person.class };
            }

            public Type getOwnerType() {
                throw new UnsupportedOperationException(
                        "not implemented for this test");
            }

            public Type getRawType() {
                throw new UnsupportedOperationException(
                        "not implemented for this test");
            }
        };
        JAXBElement je = jaxbElementProvider.readFrom(
                (Class) JAXBElement.class, type, null, null, null,
                new ByteArrayInputStream(xml.getBytes()));
        System.out.println();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.