【发布时间】:2016-11-12 20:56:53
【问题描述】:
我试图了解这个系统是如何在幕后工作的。该系统基于REST,这是非常标准的,我没有得到客户端在每次API调用之前调用OPTIONS并以格式返回xml内容。它使用的是 Jersey Java。
OPTIONS 对 DELETE 方法的响应
Access-Control-Request-Method: DELETE 在标头中传递
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://wadl.dev.java.net/2009/02">
<doc xmlns:jersey="http://jersey.java.net/" jersey:generatedBy="Jersey: 2.8 2014-04-29 01:25:26"/>
<grammars/>
<resources base=“http://domain.com”>
<resource path=“data/gasdfasdg/entity”>
<method id="deleteEntity" name="DELETE">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
<method id="getOneEntitysMetadata" name="GET">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="q" style="query" type="xs:string"/>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="x-dps-compute-content-size" style="header" type="xs:boolean"/>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
<method id="createOrUpdateEntity" name="PUT">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
</resources>
</application>
问题:
A.客户端首先调用OPTIONS,在进行实际调用之前处理和分析响应并确定API、参数等是标准还是行业惯例?早些时候,我一直在查看文档并相应地在客户端 (javascript) 中编写我的 REST 调用。
B.这个调用是由浏览器自动进行的(预检)还是在客户端编程?
【问题讨论】:
标签: javascript java rest jersey options