4

誰かが私の問題の解決策を見つけてくれたらとてもありがたいです...

WebサービスからWebメソッドを呼び出しているときに、次のエラーが発生しました。

[com.sun.istack.SAXParseException2; lineNumber:1; columnNumber:223; 予期しない要素(uri: ""、local: "sport")。予想される要素は、<{} mostFavored>、<{} teamA>、<{} teamB>、<{http://sdl.ws.lsep.lskings.com/} scoring>、<{http://sdl.ws .lsep.lskings.com /} sports>、<{} gameId>、<{http://sdl.ws.lsep.lskings.com/} gameScoring>]

メッセージに「sport」要素が含まれているのはなぜですか。また、<{http://sdl.ws.lsep.lskings.com/}sport>と一致しないのはなぜですか。これは名前空間に関連していると思いますが、その問題を解決することができず、これまで2泊しました...

私はJBossWSツールを使用してクライアントWebサービスを生成しており、すべてがJBoss 7.1.1にデプロイされています(ただし、これは適切ではないと思います)。少なくとも手がかりを教えてください:)

GameScoringクラスは次のとおりです。

@Entity
@Table(name = "`GAMESCORING`")
@XmlRootElement
@XmlType(name = "GameScoring", propOrder = { "gameScoringId", "scoring", "finished", "startTime", "stopTime",
    "tiebreak" })
public class GameScoring implements Serializable {
@Id
@GeneratedValue
@Column(name = "game_scoring_id")
private long gameScoringId;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "scoring")
private List<GamePeriod> periods;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "scoring_id")
private Scoring scoring;

private boolean finished;

private Date startTime;

private Date stopTime;

private GamePeriod tiebreak;

public GameScoring() {
    super();
}

クライアント側で生成された同じクラス:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GameScoring", propOrder = {
"gameScoringId",
"scoring",
"finished",
"startTime",
"stopTime",
"tiebreak"
})

public class GameScoring {

protected long gameScoringId;
@XmlElement(namespace = "http://sdl.ws.lsep.lskings.com/")
protected Scoring scoring;
protected boolean finished;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar startTime;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar stopTime;
protected GamePeriod tiebreak;
+ getters/setters

Webサービスメソッドを呼び出す方法:

GameManagerService gm_service = new GameManagerService();
GameManagerPortType gm_port = gm_service.getGameManagerPort();
com.lskings.lsep.ws.sdl.Game game = gm_port.getMostFavored();

ここでWebサービスSEI:

@WebService(name = "GameManagerPortType")
@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public interface GameManagerEndpoint {

@WebMethod
@WebResult(name = "success")
public boolean addGame(
        @WebParam(name = "sportId") String sportId,
        @WebParam(name = "leagueId") String leagueId,
        @WebParam(name = "scoringId") String scoringId,
        @WebParam(name = "participantHomeId") long participantHomeId,
        @WebParam(name = "participantAwayId") long participantAwayId);

@WebMethod
@WebResult(name = "success")
public boolean deleteGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "exists")
public boolean exists(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "game")
public Game getGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForLeague(@WebParam(name = "leagueId") long leagueId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> search(@WebParam(name = "query") String query);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForSport(@WebParam(name = "sportId") long sportId);

@WebMethod
@WebResult(name = "game")
public Game getMostFavored();

@WebMethod
@WebResult(name = "success")
public boolean setMostFavored(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriods")
public List<GamePeriod> getPeriods(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriodsWithTiebreaks")
public List<GamePeriod> getPeriodsWithTiebreaks(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameScore")
public int[] getScore(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "periodActions")
public List<GameAction> getPeriodActions(@WebParam(name = "periodId") long periodId);

@WebMethod
@WebResult(name = "allActions")
public List<GameAction> getAllActions(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameTimer")
public String getGameTimer(@WebParam(name = "gameId") long gameId);

}

フルスタックトレース:

http://pastebin.com/9pfCNFcw

Game.java-サーバー側

 @Entity
 @Table(name = "`GAME`")
 @XmlRootElement
 @XmlType(name = "Game", propOrder = { "gameId", "sport", "mostFavored" })
 public class Game implements Serializable {

private static final long serialVersionUID = -1564911377701558631L;

@Id
@GeneratedValue
@Column(name = "game_id")
private long gameId;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "sport_id")
private Sport sport;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "scoring_id")
private Scoring scoring;

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "game_scoring_id")
private GameScoring gameScoring;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "teamA_id")
private Participant teamA;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "teamB_id")
private Participant teamB;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "league_id")
private League league;

@Column(name = "most_favored")
private boolean mostFavored;

public Game() {
    super();
}

public Game(Sport sport, Scoring scoring, Participant teamA, Participant teamB) {
    this(sport, scoring, teamA, teamB, null);
}

public Game(Sport sport, Scoring scoring, Participant teamA, Participant teamB, League league) {
    super();
    this.sport = sport;
    this.scoring = scoring;
    this.teamA = teamA;
    this.teamB = teamB;
    this.league = league;
    this.mostFavored = false;

    LinkedList<GamePeriod> periods = new LinkedList<GamePeriod>();

    this.gameScoring = new GameScoring();

    Period p = scoring.getPeriods().get(0);
    GamePeriod gp = new GamePeriod(p, gameScoring);
    periods.add(gp);
    gp.generateParents(true);

    gameScoring.setPeriods(periods);
    gameScoring.setScoring(scoring);
}

public Sport getSport() {
    return sport;
}

@XmlTransient
public Scoring getScoring() {
    return scoring;
}

@XmlTransient
public Participant getTeamA() {
    return teamA;
}

@XmlTransient
public Participant getTeamB() {
    return teamB;
}

@XmlTransient
public GameScoring getGameScoring() {
    return gameScoring;
}

public void setSport(Sport sport) {
    this.sport = sport;
}

public void setScoring(Scoring scoring) {
    this.scoring = scoring;
}

public void setGameScoring(GameScoring gameScoring) {
    this.gameScoring = gameScoring;
}

public void setTeamA(Participant teamA) {
    this.teamA = teamA;
}

public void setTeamB(Participant teamB) {
    this.teamB = teamB;
}

public long getGameId() {
    return gameId;
}

public void setGameId(long gameId) {
    this.gameId = gameId;
}

@XmlTransient
public League getLeague() {
    return league;
}

public void setLeague(League league) {
    this.league = league;
}

public boolean isMostFavored() {
    return mostFavored;
}

public void setMostFavored(boolean mostFavored) {
    this.mostFavored = mostFavored;
}

}

Game.java-クライアント側:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Game", propOrder = {
"gameId",
"sport",
"mostFavored"
})
public class Game {

protected long gameId;
 //    @XmlElement(namespace = "http://sdl.ws.lsep.lskings.com/")
protected Sport sport;
protected boolean mostFavored;

/**
 * Gets the value of the gameId property.
 * 
 */
public long getGameId() {
    return gameId;
}

/**
 * Sets the value of the gameId property.
 * 
 */
public void setGameId(long value) {
    this.gameId = value;
}

/**
 * Gets the value of the sport property.
 * 
 * @return
 *     possible object is
 *     {@link Sport }
 *     
 */
public Sport getSport() {
    return sport;
}

/**
 * Sets the value of the sport property.
 * 
 * @param value
 *     allowed object is
 *     {@link Sport }
 *     
 */
public void setSport(Sport value) {
    this.sport = value;
}

/**
 * Gets the value of the mostFavored property.
 * 
 */
public boolean isMostFavored() {
    return mostFavored;
}

/**
 * Sets the value of the mostFavored property.
 * 
 */
public void setMostFavored(boolean value) {
    this.mostFavored = value;
}

}
4

1 に答える 1

0

数日前、@ManyToOneおよび@ManyToManyJPAアノテーションと関係があることがわかりました。ただし、これらのアノテーションの使用中に失敗する理由はわかりません。@XmlTransientアノテーションによって解決されました。その後、idで関連オブジェクトを取得するための追加のコードを作成する必要がありました。

于 2012-07-11T16:08:44.237 に答える