我正在尝试将方法PUT用于REST服务,但我收到错误:
curl -v -H“Content-Type:application / xml”-X PUT --data-binary“@ putUsers.xml”http://localhost:8080/RestDB/webresources/User/5
The response is:
Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> PUT /RestDB/webresources/User/5 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.46.0
> Accept: */*
> Content-Type: application/xml
> Content-Length: 409
>
* upload completely sent off: 409 out of 409 bytes
< HTTP/1.1 400 Bad Request
< Server: GlassFish Server Open Source Edition 4.1.1
< X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition 4.1.1 Java/Oracle Corporation/1.8)
< Content-Language:
< Content-Type: text/html
< Date: Thu, 03 Aug 2017 09:55:13 GMT
< Connection: close
< Content-Length: 1109
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition 4.1.1 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - Bad Request</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>Bad Request</p><p><b>description</b>The request sent by the client was syntactically incorrect.</p><hr/><h3>GlassFish Server Open Source Edition 4.1.1 </h3></body></html>* Closing connection 0
服务器日志:
部署应用程序[RestDB]时出现异常:异常[EclipseLink-4002](Eclipse Persistence Services - 2.6.1.v20150605-31e8258):org.eclipse.persistence.exceptions.DatabaseException 内部异常:java.sql.SQLException:分配连接时出错。原因:无法分配连接,因为:从网络读取时数据不足 - 预计至少6个字节,仅接收0个字节。连接已终止。 错误代码:0
我正在尝试在数据库中进行更新。
非常感谢!
答案 0 :(得分:1)
你要混合很多东西,请集中精力并提出正确的问题。
显然你的应用程序甚至没有部署,因此你不需要尝试使用curl发送请求,这不起作用。
逐步修复您的问题(如果需要,请提出几个具体问题),第一步应该是正确部署应用程序。