私は一般的なREST Webサービスクライアントを実装しました。削除要求以外はすべて正常に動作しています。それは常に "404 - > NOT FOUND"というエラーを返しますが、他のツール(firefoxの投稿& curl)を使用しているときに、削除要求を実行できるので、Webサービスクライアントが動作しています。Jersey REST WebサービスクライアントのDELETEは常に404を投げます
失敗している方法:
private <T> Object sendDelete(String baseURL, String urlExtension, Class<T> returnClass, CustomHeaders customHeaders) throws WebServiceDeleteRequestException {
Validate.notNull(baseURL, "The specified Base URL is NULL!");
Validate.notEmpty(baseURL, "The specified Base URL is empty!");
Validate.notNull(urlExtension, "The specified URL Extension is NULL!");
Validate.notEmpty(urlExtension, "The specified URL Extension is Empty!");
Validate.notNull(returnClass, "The specified Class to return is NULL!");
WebResource webResource = null;
try {
webResource = getRESTClient().resource(baseURL);
} catch (ServiceClientException serviceClientException) {
throw new WebServiceDeleteRequestException("Couldn't execute the HTTP DELETE request! The ServiceRESTClient couldn't be created!", serviceClientException);
}
webResource.path(urlExtension);
try {
if(customHeaders == null) {
return webResource.delete(returnClass);
} else {
WebResource.Builder builder = webResource.getRequestBuilder();
if(customHeaders != null) {
for(Entry<String, String> headerValue : customHeaders.getCustomHeaders().entrySet()) {
builder.header(headerValue.getKey(), headerValue.getValue());
}
}
builder.accept(MediaType.APPLICATION_XML);
return builder.delete(returnClass);
}
} catch (Exception exception) {
throw new WebServiceDeleteRequestException("Couldn't execute the HTTP DELETE request!", exception);
}
}
'builder.delete(returnClass)' ステートメントUniformInterfaceExceptionを実行します。それは問題ではないもの変数(ベースURL、urlExtension、returnClass & customHeaders)が正しいとされているので、
com.sun.jersey.api.client.UniformInterfaceException: DELETE http://localhost:8080/db/ returned a response status of 404 Not Found
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:676)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.delete(WebResource.java:583)
リソースは、私の他の要求と同じである私は、他のテストツールでそれらの値を使用する場合、I正しい応答を得る。
なぜこの404エラーが発生するのですか?
TRACEリクエストをお試しくださいだから私は、代わりにこの線は、...検証した後、推測しています。何がウェブを受け取っているか見るには – ssedano
どうすればいいですか? – ToHe
エラーメッセージに基づいて、このURLのDELETE要求が送信されます。このURLには、http:// localhost:8080/db/'があります。これは本当に削除したいリソースのURIですか?私はそれがないと推測しています。 –