jersey

Sending Name Value Pair in POST using Jersey Client

本小妞迷上赌 提交于 2019-12-12 15:45:06
问题 How can i pass name value pairs as body to a POST ReST Service in Jersey. Something similar to the code below using Apache Commons PostMethod final PostMethod post = new PostMethod(url); post.setRequestBody(new NameValuePair[] { new NameValuePair("loginId", userId), new NameValuePair("logonPassword", password), new NameValuePair("signature", signature), new NameValuePair("timestamp", timestamp), new NameValuePair("sourceSiteId", sourceSiteId) }); I'm porting this call to my application. The

Getting a 404 error to run a Jersey REST

自古美人都是妖i 提交于 2019-12-12 15:18:05
问题 I am trying to run my first HelloWorld Jersey project ever, read bunch of tutorials on it and I think theoretically it should work but of course I am doing something wrong that the page gives me a 404 error. Here is what I have: I started with a DynamicWebProject in Eclise and using plugins convereted it to a Maven project. And added these to the POM file: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> <version>1.8</version> </dependency> <dependency>

Jersey and Jackson serialization of subclasses does not include extra attributes

白昼怎懂夜的黑 提交于 2019-12-12 15:11:20
问题 In Jersey, when using Jackson for JSON serialization, the extra attributes of an implementing subclass are not included. For example, given the following class structure @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="@class") @JsonSubTypes({ @JsonSubTypes.Type(value = Foo.class, name = "foo") } public abstract class FooBase { private String bar; public String getBar() { return bar; } public void setBar( String bar ) { this.bar = bar; } } public class Foo

@Consumes(MediaType.APPLICATION_FORM_URLENCODED) FormParameter is null

删除回忆录丶 提交于 2019-12-12 15:09:51
问题 I've created a Jersey webservice that looks like this: @Path("/webhookservice") public class Webhook { @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response readData(@FormParam("payload") Payload payload, @Context HttpServletRequest req) { // Gets client IP address String ipAddress = (req.getRemoteHost().equals("") || req.getRemoteHost() == null) ? "UNKNOWN" : req.getRemoteHost(); // Persist data to DB Persist.saveToDb(payload.getId(), Integer.toString(payload.getTimestamp())

Status Code 415: No MessageBodyReader Found for multipart/form-data, FormDataMultiPart

这一生的挚爱 提交于 2019-12-12 15:09:19
问题 I'm running into some trouble POSTing multipart/form-data to a RESTful web service that I've made. I am trying to upload media files (images, video, audio) via a RESTful web service. I googled around to find the best way to do this and found that POSTing multipart/form-data was the best solution. The problem is when I POST some multipart/form-data I get this error message in my Tomcat server: SEVERE MessageBodyReader not found for media type=multipart/form-data; boundary=---

Neo4j Unmanaged Extension and GuardTimeoutException

百般思念 提交于 2019-12-12 14:27:37
问题 I am in great need of some advice regarding an issue I'm running into with a Neo4j unmanaged extension that I'm building in Java. I have created a very simple code sample that highlights my issue. The basic premise is that I'd like to set the org.neo4j.server.webserver.limit.executiontime for the neo4j server to a reasonable amount of time for user queries (lets say 2 minutes) which are coming in through Cypher, other endpoints, etc. But I also have some batch jobs that I need to run through

Filtering static content Jersey

自作多情 提交于 2019-12-12 13:19:15
问题 I'm trying to serve static content (a HTML form that calls a Jersey REST resource) from the same webapp as the servlet that handles the requests to the resource. As I understand I can filter requests to static content away from the Jersey servlet. My web.xml is as follows, but at the moment I am unable to access the static content nor the resource...both were working separately. <filter> <filter-name>my-filter</filter-name> <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer<

File upload using REST service

坚强是说给别人听的谎言 提交于 2019-12-12 12:17:21
问题 I use following REST service (from this tutorial) to do file uploads from various number of clients to my GlassFish server, using jersey multipart implementation: import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.sun.jersey.core.header

How to register a static class in Jersey?

蓝咒 提交于 2019-12-12 12:11:57
问题 I have a class of which only static methods are to be accessed via @path annotations and which does not have a public constructor. My simpilified program is: @Path("") static class MyStaticClass { private MyStaticClass() {...} @Get @Path("time") static public String time() { return Instant.now().toString(); } } Running and calling "time" gives me the following error: WARNUNG: The following warnings have been detected: WARNING: HK2 service reification failed for [...] with an exception:

Subresource and path variable conflicts in REST?

余生长醉 提交于 2019-12-12 11:43:07
问题 Is it considered bad practice to design a REST API that may have an ambiguity in the path resolution? For example: GET /animals/{id} // Returns the animal with the given ID GET /animals/dogs // Returns all animals of type dog Ok, that's contrived, because you would actually just do GET /dogs , but hopefully it illustrates what I mean. From a path resolution standpoint, it seems like you wouldn't know whether you were looking for an animal with id="dogs" or just all the dogs Specifically, I'm