jax-rs

how to bind HTTP POST data to python object in Django Rest Framework?

和自甴很熟 提交于 2020-01-05 08:24:06
问题 I will give an example to better explain my question my request: POST http://localhost:8080/users/ request body: (This gets posted) {"name":"Matt", "salary":10000, "blog_url":"www.myblog.com", "dept_name":"ENG" } class CustomRequest(object): def __init__(self,name,salary,blog_url,dept_name): self.name=name self.salary=10000 self.blog_url=blog_url self.dept_name=dept_name models.py class myUser(models.Model): //fields -- username, salary class myUserProfile(models.Model): User=models

JAX-RS Rest services stopped deploying on Eclipse Glassfish

女生的网名这么多〃 提交于 2020-01-04 14:02:21
问题 I've been developing a Jersey JAX-RS application on Glassfish 4.1.1 using Eclipse for about a year now. Earlier today, I was making some normal changes to some of the classes, but Eclipse was not updating the classes when I would try and do a build. I searched here on Stack Overflow, and found this answer. So I did the following steps: Project > Clean on the project you're working on. Project > Build Automatically - turned on so the code rebuilds in your workspace on saved changes. Window >

Handle Authentication and Authorization in jax-rs webservice with cxf

隐身守侯 提交于 2020-01-04 06:55:07
问题 I have a webapp which has jsps. am not using any struts or mvc framework. We have JAX-RS service build using Apache CXF. Now i want to do following Allow user to login with username and password. For all subsequent calls to webservice, same authentication info should be used. Logged in user has some details (profile photo, full name), which i want to keep it constant across session. Also, its role are defined. Based on role(s) only certain jax-rs calls will be allowed. Roles are also used in

JAX-RS Request interceptor missing dependencies

你说的曾经没有我的故事 提交于 2020-01-04 06:28:59
问题 Here's the intereceptor code, which is the only difference in whether I get these errors. package com.lm.infrastructure; import java.io.IOException; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.PreMatching; import javax.ws.rs.ext.Provider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Provider @PreMatching class RequestLogger implements ContainerRequestFilter { @Override public void filter(

What does jersey service return if @Produces annotation missing?

我们两清 提交于 2020-01-04 02:54:21
问题 I was begun learn jersey for development restful web services. As I noticed in most of the examples uses following annotations: @Consumes defines format of input parameters @Produces defines format of output parameters But in real code I see method which looks like this: @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/login") public Response login(@FormParam("login") final String username, @FormParam("password") final String password){...} I see that this method uses POST HTTP

Jersey produces unexpected default media type when throwing WebApplicationException

此生再无相见时 提交于 2020-01-04 02:17:07
问题 I am developing a web service using the JAX-RS API with Jersey 1.17 as my implementation. I want clients to have the choice between JSON and XML which they specify using the Accept HTTP header. I want JSON to be the default when a client does not include the Accept header in the request. I have tried to achieve this by placing MediaType.APPLICATION_JSON before MediaType.APPLICATION_XML in the Produces annotation. This seems to work in normal situations: $ curl 'http://localhost:8080

Getting Conflicting URI templates errors when trying to add resource class

余生颓废 提交于 2020-01-04 02:11:41
问题 I have a restfull implementation using Jersey and Tomcat7. I have 3 resources called RegionService, ClientService and NoteService defined in my campher.rest package. When I try to add another resource called TestResource, and Tomcat starts, it gives me the following error below. I don't understand how /{notes} conflicts with /{test}?? Please help, my hair will thank you. Aug 22, 2012 2:23:39 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class

What is the right way to use entitymanager

我的未来我决定 提交于 2020-01-03 16:50:28
问题 I have a REST client in Jersey JAX-RS which takes requests and then using Hibernate's JPA implementation retrieves the data from the database and returns a JSON. Using a shared entity manager, the performance is quite good but if there are multiple requests, I get exceptions from Hibernate, mainly NullPointerException. If I use an entity manager per request I don't get any exceptions but the performance is lower. What is the proper way of handling the EntityManager? EDIT: Following Albert's

What is WSDL equivalent in restful WS . If nothing,how consumer generates required client side classes?

…衆ロ難τιáo~ 提交于 2020-01-03 15:16:15
问题 Say ,i have producer in java and consumer in dot net. Producer has a method that takes Employee as method parameter and creates employee in db. For SOAP based ws, dot net client will hit WSDL and creates the stubs (including employee data representation in dot net). Now it can fill the object and send to producer. I am not sure how it will work in restful webservices as there is no WSDL. How rest consumer will get to know what are the operations exposed by producer without any WSDL contract

How do I @Inject a CDI @ApplicationScoped bean into a @RequestScoped JAX-RS bean?

為{幸葍}努か 提交于 2020-01-03 13:35:34
问题 I've added the @ApplicationScoped CDI annotation to a simple bean: @ApplicationScoped public class History { And tried to then @Inject this into a JAX-RS (resteasy) bean: @RequestScoped @Path("/history") public class HistoryAPI { @Inject private History history; But history remains null. I've got a beans.xml file in WEB-INF. I've tried a lot of variations on this theme, but while the app server (Wildfly) acknowledges it's starting with CDI I can't get the injection to work. Any ideas what I"m