restful-architecture

Disable HTTPSession for stateless web services [duplicate]

丶灬走出姿态 提交于 2019-12-13 09:37:35
问题 This question already has answers here : Can I turn off the HttpSession in web.xml? (9 answers) Closed 3 years ago . I would like to know if it is possible to disable the HTTPSession for an application server handling only web services RESTful . I don't know if there are specific application servers or servlet containers designed to handle micro RESTful web services. I think that disabling completely the session concept will give the following advantages: Better performances No risk to save

Getting error while receiving Object in restful webservice

自闭症网瘾萝莉.ら 提交于 2019-12-13 04:28:27
问题 Code i used to convert my reg_be obj to is inputstream. ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(reg_be); oos.flush(); oos.close(); InputStream is = new ByteArrayInputStream(baos.toByteArray()); Then i pass this inputstream to webservice. My web service code is public String getText(@Context HttpServletRequest request) throws IOException { // Registration_BE reg_be=new Registration_BE(); InputStream in

406 Error when consuming restFul webService in Spring MVC project. The webService works when returning a String but fails for other data types

耗尽温柔 提交于 2019-12-13 03:45:02
问题 This is a snippet my spring servlet. My pom file has the jackson dependencies added as well but I just can't figure out why I'm getting this 406. ... <mvc:annotation-driven/> <context:component-scan base-package="com.ourcalendar.*"/> <!-- Add JPA support --> <bean id="emf" class= "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="loadTimeWeaver"> <bean class= "org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> </property> </bean> <!

Hypermedia links in Swagger UI using Springfox

☆樱花仙子☆ 提交于 2019-12-13 02:36:16
问题 I'm building a RESTful API, using spring-hateoas library to implement hypermedia. The response of my endpoints is application/hal+json (My DTO extends ResourceSupport). I'm using Swagger to document the endpoints, and using Springfox to autogenerate the swagger-ui. The problem is, that the generated documentation is not correct. As a request for a POST endpoint, the UI is setting the _links section from my DTO as part of the payload, so this is what I see I should send as a parameter for my

React/Redux concept Vs server call requests

你。 提交于 2019-12-12 23:22:21
问题 I am wondering what is the best design approach between using a big state (store) and sql request in database. Let's say you have a Todo CRUD application. You can save the Todos list in store within Redux implementation. What is the best approach if you want to make complex statistics on those TODOs: Reducers or sql requests? For example, you want to get all todos for the current month: Reducers/store approach You can get all the todos list from the store and filter todos by date to get all

RESTful API behavior for entitys with two independent primary keys

冷暖自知 提交于 2019-12-12 11:00:00
问题 I have the following entity: <car> <carID>7</carID> <...>...</...> <externalCarID>23890212</externalCarID> </car> The problem is now that carID and externalCarID are both independent primary keys that are used by/for different systems and it should be possible for API clients to access a car entity with both the carID xor the externalCarID . Both keys are ints and they do not use disjoint sets: carID(7) != externalCarID(7) I have thought of the following solutions: Access it with /restapi/car

PHP Send local file by cURL

五迷三道 提交于 2019-12-12 07:24:00
问题 Im trying to send a local file by client curl app. I found some examples to do that with files from a form. In my case, I have no form, but a local file. $fileName = $_SERVER["DOCUMENT_ROOT"]."/www/images/test.pdf"; if(!file_exists($fileName)) { $out['status'] = 'error'; $out['message'] = 'File not found.'; exit(json_encode($out)); } $data = array('name' => 'Foo', 'file' => '@'.$fileName); $cURL = curl_init("http://myapi/upload-images"); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl

POST or GET for a validation of some data endpoint in REST?

試著忘記壹切 提交于 2019-12-12 04:21:50
问题 I have a server endpoint which validates some data and return true/false if the data validation has no errors. So which Version would be correct or more suitable for a RESTful webservice? POST https://server.de/validate POST data in body and return HTTP status code 200 if validation had no errors or GET https://server.de/validate?=data Send data in header or query parameter and return true/false in the response (Status code 200 would be returned after a correct request, independent of the

How to sent XML file endpoint url in Restful web service

筅森魡賤 提交于 2019-12-12 03:18:51
问题 I need to send the request XML file to {url} as multipart form data. How this do in Restful web service. Before I use in there in, RequestDispatcher rd = request.getRequestDispatcher("/file/message.jsp"); rd.forward(request, response); But this isn't sent in specific {url}, How to sent it? 回答1: You can use the Jersey Rest Client to send your XML message as post request . try { Client client = Client.create(); WebResource webResource = client.resource(http://<your URI>); // POST method

Rails CRUD - Destroy path always routes to the User show page

大城市里の小女人 提交于 2019-12-12 02:45:16
问题 My view is the users show page <%= link_to 'Cancel?', {:url => schedule_path, :id => current_user.schedules[0].id, :confirm => "are you sure?", :method => :delete} %> Associations has_many :schedules belongs_to :user routes.rb resources :schedules resources :users I don't match anything in routes.rb. The parameters in the stack trace show id => 93 , which is what I want as I'm trying to destroy the schedule with id 93. But it's routing to the show action of the user's controller when I want