jax-rs

@Post method with capturing parenthesis in @Path not matched in Jersey

拈花ヽ惹草 提交于 2019-12-24 01:39:25
问题 I am having trouble getting JAX-RS POST methods to match with Jersey. Verbatim paths work fine ("/prefix/ABC/DEF"), but parenthesised captures ("/prefix/{alpha}/{beta}") fail to trigger. Here are the methods in question, as defined in the server interface, using Jersey. public interface CollectorEndpoint { ... @POST @Path("/prefix/{alpha}/{beta}") //doesn't match @Consumes(MediaType.APPLICATION_JSON) Response method1(@PathParam("alpha") String alpha, @PathParam("beta") String beta, String

@Produces annotation in JAX-RS

99封情书 提交于 2019-12-24 00:58:58
问题 My service method Produces one of this MediaTypes it may produce pdf or excel file or other. @Produces({"application/pdf","application/vnd.ms-excel"... My Question My service returns response type with application/pdf always even if it produces excel . Why? Than I rearranged MediaTypes . @Produces({"application/vnd.ms-excel","application/pdf",... Now it's giving type application/vnd.ms-excel for all responses,again Why? I am using com.sun.jersey API for client and getting type by the use of

JAX-RS with CXF / rest-assured: Handling multiparam file upload

不问归期 提交于 2019-12-24 00:54:50
问题 I want to upload a JPG file and a JSON-serialized Java object. On the server I am using Apache CXF, on the client I am integration testing with rest-assured. My server code looks like: @POST @Path("/document") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response storeTravelDocument( @Context UriInfo uriInfo, @Multipart(value = "document") JsonBean bean, @Multipart(value = "image") InputStream pictureStream) throws IOException {} My client code looks like: given(). multiPart("document",

Wrong WebTarget implementation SseEventSource

淺唱寂寞╮ 提交于 2019-12-24 00:37:37
问题 I have implemented a method to receive live notification from OpenHab in my application through SSE events. Previously I used glassfish server to deploy my application. But I needed to switch to Payara and now the sse connection won't be established. I am getting following error: Argument fish.payara.requesttracing.jaxrs.client.decorators.JaxrsWebTargetDecorator@45>314ad8 is not a valid JerseyWebTarget instance. SseEventSource does not support other WebTarget implementations. When switching

JAX-RS polymorphic POST request: how should I write my JSON?

空扰寡人 提交于 2019-12-24 00:12:24
问题 I'm having a bad time trying to solve this problem with JAX-RS and I believe that it has something to do with the marshalling/unmarshalling process (that I don't know very much about, I assume), and I want to recreate this: The REST endpoint to make a post is /rest/register so my services are defined like this: @ApplicationPath("/rest") public interface RestRegistration { @POST @Path("/register") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) String register

Jax-RS and Xmlhttp Communication

淺唱寂寞╮ 提交于 2019-12-23 22:56:48
问题 I have a REST Server in Java JAX-RS and an HTML page. I want to send a JSON array, a username, and an accountID from the HTML page through an xmlhttp POST request by making all of them a single big String so I can use the xmthttp.send() method. The HTML sending code is: function sendData() { var req = createRequest(); var postUrl = "rest/hello/treeData"; var dsdata = $("#treeview").data("kendoTreeView").dataSource.data(); var accID = "onthespot"; var username = "alex"; req.open("post",

How to handle Service unavailable scenarios with Jersey REST

白昼怎懂夜的黑 提交于 2019-12-23 21:54:37
问题 I have a jersey RESTful service integraed with Spring.The base url mapped in web.xml is /rest/* My service class is below: @Resource @Scope("request") @Path("/service/") @Component public class ServiceController { @GET @Produces(MediaType.APPLICATION_JSON) public Response getApiDetails() { return Response.ok("area").build(); } @Path("/area") @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) public Response processConvertCurrency( @QueryParam("length") String

Ignoring incoming json elements in jax-rs

别等时光非礼了梦想. 提交于 2019-12-23 20:55:26
问题 I'm wondering where to put the @JsonIgnoreProperties(ignoreUnknown = true) in a Java REST API. I have the following class: import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.ObjectMapper; @JsonIgnoreProperties(ignoreUnknown = true) public class QueuePayload { private String message; private String id; public String getId() { return this.id; } public String getMessage() { return this.message; } public void setId(String id) { this.id = id; } public void

Calling a SOAP service using REST service

别来无恙 提交于 2019-12-23 20:25:28
问题 I want to call a SOAP service using REST service. Can anybody please share some example programme or snippets where we can invoke a soap service using JAX-RS(Jersey) written REST service. I am using jdk 1.7 & eclipse juno. What will we be using to refer to the soap service? Please note that I am entirely new to webservice, so examples will be a huge help! 回答1: You cannot use a REST service framework to access a SOAP Web-Service. This are two completely different technologies. It's like you're

Hibernate java.lang.NoSuchMethodError: > org.hibernate.integrator.internal.IntegratorServiceImpl.<init>

允我心安 提交于 2019-12-23 20:18:46
问题 Using hibernate on my jax-rs I'm getting this error: HTTP ERROR 500 Problem accessing /services/datesTest. Reason: Server Error Caused by: java.lang.ExceptionInInitializerError at connectors.Connector.buildSessionFactory(Connector.java:32) at connectors.Connector.getSessionFactory(Connector.java:37) at connectors.Connector.getSession(Connector.java:45) at mainproject.services.HibernateDatesTest.verifyToken(HibernateDatesTest.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native