我试图将XML对象发送到在WebLogic服务器上发布的WebService,但是即使我执行此对象,也总是将其接收为null。
这是WebService的代码以及我发送XML的方式。 有什么想法吗?
代码JAVA 服务方式:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(@WebParam( name = "oReq")
ConsultarRecibosPendientesReq objeto) {
ConsultarRecibosPendientesRes recibosRes = new ConsultarRecibosPendientesRes();
String LlaveAcceso = objeto.getStrLlaveAcceso();
recibosRes.setStrIdentificacion(LlaveAcceso);
return recibosRes;
}
参数所接收的对象的类:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ConsultarRecibosPendientesReq")
public class ConsultarRecibosPendientesReq {
@XmlElement(name = "strLlaveAcceso")
protected String strLlaveAcceso;
public ConsultarRecibosPendientesReq(){ }
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String strLlaveAcceso) {
this.strLlaveAcceso = strLlaveAcceso;
}
}
对象QueryReceivePendientesReq始终为null。有人知道如何解决吗?
答案 0 :(得分:0)
首先,我对通过参数接收的对象的类进行了一些更改:
public class Action {
@SerializedName("uuid")
private String uuid;
@SerializedName("type")
private String type;
@SerializedName("celebrity_base")
private CelebrityBase celebrity_base;
@SerializedName("topic")
private Topic topic;
@SerializedName("profession")
private Profession profession;
@SerializedName("movie")
private Movie movie;
@SerializedName("album")
private Album album;
@SerializedName("track")
private Track track;
@SerializedName("tournament")
private Tournament tournament;
@SerializedName("match")
private Match match;
@SerializedName("book")
private Book book;
@SerializedName("hashtags")
private List<HashTag> hashTags;
@SerializedName("target_persons")
@Expose
private List<TargetPersons> targetPersons;
@SerializedName("top_comments")
private List<TopComment> actionComments;
@SerializedName("title")
private String title;
@SerializedName("subtitle")
private String subtitle;
@SerializedName("description")
private String description;
@SerializedName("from_date")
private String from_date;
@SerializedName("to_date")
private String to_date;
@SerializedName("rate")
private double rate;
@SerializedName("rate_count")
private int rate_count;
@SerializedName("persian_rate")
private String persian_rate;
@SerializedName("persian_rate_count")
private String persian_rate_count;
@SerializedName("image_link")
private String image_link;
@SerializedName("picture")
private String picture;
@SerializedName("relation_type")
private String relation_type;
@SerializedName("persian_user_rate")
private int persian_user_rate;
@NonNull
public String getUuid() {
return uuid;
}
public void setUuid(@NonNull String uuid) {
this.uuid = uuid;
}
@NonNull
public String getType() {
return type;
}
public void setType(@NonNull String type) {
this.type = type;
}
@Nullable
public CelebrityBase getCelebrity_base() {
return celebrity_base;
}
public void setCelebrity_base(@Nullable CelebrityBase celebrity_base) {
this.celebrity_base = celebrity_base;
}
@Nullable
public Topic getTopic() {
return topic;
}
public void setTopic(@Nullable Topic topic) {
this.topic = topic;
}
@Nullable
public Profession getProfession() {
return profession;
}
public void setProfession(@Nullable Profession profession) {
this.profession = profession;
}
@Nullable
public Movie getMovie() {
return movie;
}
public void setMovie(@Nullable Movie movie) {
this.movie = movie;
}
@Nullable
public Album getAlbum() {
return album;
}
public void setAlbum(@Nullable Album album) {
this.album = album;
}
@Nullable
public Track getTrack() {
return track;
}
public void setTrack(@Nullable Track track) {
this.track = track;
}
@Nullable
public Tournament getTournament() {
return tournament;
}
public void setTournament(@Nullable Tournament tournament) {
this.tournament = tournament;
}
@Nullable
public Match getMatch() {
return match;
}
public void setMatch(@Nullable Match match) {
this.match = match;
}
@Nullable
public Book getBook() {
return book;
}
public void setBook(@Nullable Book book) {
this.book = book;
}
@Nullable
public List<HashTag> getHashTags() {
return hashTags;
}
public void setHashTags(@Nullable List<HashTag> hashTags) {
this.hashTags = hashTags;
}
@Nullable
public List<TopComment> getActionComments() {
return actionComments;
}
public void setActionComments(@Nullable List<TopComment> actionComments) {
this.actionComments = actionComments;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Nullable
public String getSubtitle() {
return subtitle;
}
public void setSubtitle(@Nullable String subtitle) {
this.subtitle = subtitle;
}
@Nullable
public String getDescription() {
return description;
}
public void setDescription(@Nullable String description) {
this.description = description;
}
@Nullable
public String getFrom_date() {
return from_date;
}
public void setFrom_date(@Nullable String from_date) {
this.from_date = from_date;
}
@Nullable
public String getTo_date() {
return to_date;
}
public void setTo_date(@Nullable String to_date) {
this.to_date = to_date;
}
@Nullable
public double getRate() {
return rate;
}
public void setRate(@Nullable double rate) {
this.rate = rate;
}
@Nullable
public int getRate_count() {
return rate_count;
}
public void setRate_count(@Nullable int rate_count) {
this.rate_count = rate_count;
}
@Nullable
public String getPersian_rate() {
return persian_rate;
}
public void setPersian_rate(@Nullable String persian_rate) {
this.persian_rate = persian_rate;
}
@Nullable
public String getPersian_rate_count() {
return persian_rate_count;
}
public void setPersian_rate_count(@Nullable String persian_rate_count) {
this.persian_rate_count = persian_rate_count;
}
@Nullable
public String getImage_link() {
return image_link;
}
public void setImage_link(@Nullable String image_link) {
this.image_link = image_link;
}
@Nullable
public String getPicture() {
return picture;
}
public void setPicture(@Nullable String picture) {
this.picture = picture;
}
@Nullable
public String getRelation_type() {
return relation_type;
}
public void setRelation_type(@Nullable String relation_type) {
this.relation_type = relation_type;
}
@Nullable
public int getPersian_user_rate() {
return persian_user_rate;
}
public void setPersian_user_rate(@Nullable int persian_user_rate) {
this.persian_user_rate = persian_user_rate;
}
public List<TargetPersons> getTargetPersons() {
return targetPersons;
}
public void setTargetPersons(List<TargetPersons> targetPersons) {
this.targetPersons = targetPersons;
}
}
我对WebService方法进行了更改:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "consultarRecibosPendientesReq", propOrder = {
"strLlaveAcceso"
})
public class ConsultarRecibosPendientesReq {
protected String strLlaveAcceso;
public String getStrLlaveAcceso() {
return strLlaveAcceso;
}
public void setStrLlaveAcceso(String value) {
this.strLlaveAcceso = value;
}
}
最后,我对发送的XML进行了更改,在“方法”和“目标名称空间”标记中添加了“ web”子句,例如:
@WebMethod(operationName = "ConsultarRecibosPendientes")
@WebResult(name = "ConsultarRecibosPendientesResult")
public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(
@WebParam(name = "oReq", targetNamespace = "")
ConsultarRecibosPendientesReq oReq) {...}