Hi All,


I have problem while posting JSON text to RESTService. The service is
failing with Exception

JAXBException occurred : unexpected element (uri:"
http://www.w3.org/2001/XMLSchema-instance";, local:"Customer"). Expected
elements are <{}Customer>. unexpected element (uri:"
http://www.w3.org/2001/XMLSchema-instance";, local:"Customer"). Expected
elements are <{}Customer>.

I believe this the problem with namespace. Pleas suggest me a solution





JSON Text

-----------------

{"Customer":{"id":123,"name":"Balaji"}}





Customer Service

------------------

@Path("/customerservice/")

public class CustomerService {

@POST

    @Path("/customers/")

    public Response addCustomer(Customer customer) {

        System.out.println("----invoking addCustomer, Customer name is: " +
customer.getName());

        customer.setId(++currentId);



        customers.put(customer.getId(), customer);



        return Response.ok(customer).build();

    }

}



Spring-config.xml

--------------

<util:map id="jsonNamespaceMap" map-class="java.util.Hashtable">

        <entry key="http://www.w3.org/2001/XMLSchema-instance"; value=""/>

    </util:map>



<jaxrs:serviceBeans>

<ref bean="customerService"/>

</jaxrs:serviceBeans>


Thanks

Balaji

Reply via email to