2
我試圖在Windows Server 2008上執行卷曲通過命令行下面的命令R2在Tomcat 7捲曲的要求是不正確syntatically
curl -X POST -d "<userList xmlns="urn:user"><user role="ROLE_OPERATOR" loginName="test_login1"></user></userList>" -H "Content-Type: application/xml" --basic --user username:password http://localhost:8080/meolutws/UserList/
運行Apache新澤西州的REST當我發出命令,我獲取帶有消息的HTTP 400:「客戶端發送的請求在合成上不正確」。
上的Web服務的方法簽名看起來是這樣的:
@POST
@CONSUMES({"application/xml"})
public Response createUsers(UserList users){
}
UserList的類定義如下:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserList", namespace = "urn:user", propOrder = {
"users"
})
@XmlRootElement(name = "userList", namespace = "urn:user")
public class UserList
implements Serializable
{
@XmlElement(name = "user")
protected List<User> users;
public List<User> getUsers() {
if (users == null) {
users = new ArrayList<User>();
}
return this.users;
}
}
和用戶定義如下:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "User", namespace = "urn:user")
@XmlRootElement(name = "user", namespace = "urn:user")
public class User
implements Serializable
{
@XmlAttribute(name = "loginName", required = true)
protected String loginName;
@XmlAttribute(name = "role", required = true)
protected String role;
public String getLoginName() {
return loginName;
}
public void setLoginName(String value) {
this.loginName = value;
}
public String getRole() {
return role;
}
public void setRole(String value) {
this.role = value;
}
}
我錯過了什麼?
如果我在身體周圍做單引號,我會得到「<在這個時候是意外的」。 –
我剛剛結束了使用命令「curl -X POST -d @ userList.xml -H」Content-Type:application/xml「--basic --user meo:meo http:// localhost:8080/meolutws/UserList「,其中userList.xml的內容與上面相同。 –