我在从基于soap的Web服务中解密响应时遇到了一些困难。。有一个user(基于wsdl自动生成)对象,其中包含一个列表,它的列表中似乎有问题,我得到以下错误: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.ws.soap.client.SoapFaultClientException: Unmarshalling Error: unexpected element (uri:"", local:"affiliations"). Expected elements are (none)
我能得到的任何帮助对我来说都是微不足道的
代码如下:
var userRequest = new GetUser();
var wrappedUserRequest = objectFactory.createGetUser(userRequest);
userRequest.setArg0((long) id);
var response = (JAXBElement<GetUserResponse>) getWebServiceTemplate()
.marshalSendAndReceive(nissyUri, wrappedUserRequest);
return response.getValue().getReturn();
它在.marshalsendandreceive方法上失败。下面是使用的java类:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "user", propOrder = {
"affiliations",
"comment",
"currentAffiliations",
"currentRoles",
"disabled",
"domain",
"email",
"firstName",
"id",
"lastModifiedBy",
"lastName",
"middleName",
"password",
"passwordDate",
"passwordHistory",
"phone",
"position",
"region",
"roles",
"treatmentCenterName",
"username"
})
public class User {
@XmlElement(nillable = true)
protected List<Affiliation> affiliations;
protected String comment;
protected String currentAffiliations;
protected String currentRoles;
protected boolean disabled;
protected String domain;
protected String email;
protected String firstName;
protected Long id;
protected String lastModifiedBy;
protected String lastName;
protected String middleName;
protected String password;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar passwordDate;
protected String passwordHistory;
protected String phone;
protected String position;
protected Integer region;
@XmlElement(nillable = true)
protected List<Role> roles;
protected String treatmentCenterName;
protected String username;
}
public List<Affiliation> getAffiliations() {
if (affiliations == null) {
affiliations = new ArrayList<Affiliation>();
}
return this.affiliations;
}
// More setters and getters..
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getUserResponse", propOrder = {
"_return"
})
public class GetUserResponse {
@XmlElement(name = "return")
protected User _return;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "affiliation", propOrder = {
"account",
"attributes",
"id",
"organizationId",
"primary",
"type"
})
public class Affiliation {
@XmlElementRef(name = "account", type = JAXBElement.class, required = false)
protected JAXBElement<String> account;
@XmlElementRef(name = "attributes", type = JAXBElement.class, required = false)
protected JAXBElement<String> attributes;
protected Long id;
protected Long organizationId;
protected boolean primary;
protected String type;
public JAXBElement<String> getAccount() {
return account;
}
// Getters and setters etc..
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getUserResponse", propOrder = {
"_return"
})
public class GetUserResponse {
@XmlElement(name = "return")
protected User _return;
}
暂无答案!
目前还没有任何答案,快来回答吧!