JAX-WS を使用して Web サービスを構築しています。@XmlElement(required=true)
注釈が一部のクラスでは@WebParam
機能するが、他の一部のクラスでは機能しないという奇妙な問題があり@WebService
ます。
@WebService
私は2つのクラスで非常によく似たコードを持っています。この問題の原因は何ですか? パラメータタイプまたはエンティティクラス?
編集:サンプルコードを追加
2 つの Web サービスがあります。
@WebService(name = "ClubMemberPortType", serviceName = "ClubMemberService", portName = "ClubMemberSoapPort", targetNamespace = "http://club.com/api/ws")
public class ClubMemberWS {
@WebMethod(operationName = "findClubMembersByClubId", action = "urn:findClubMembersByClubId")
@WebResult(name = "club_membership")
public List<ClubMembership> findClubMembershipsByClubId(@XmlElement(required=true)
@WebParam(name = "club_id") String clubId,
@WebParam(name = "status") StatusEnum status){
...
}}
と
@WebService(name = "ClubPortType", serviceName = "ClubService", portName = "ClubSoapPort", targetNamespace = "http://club.com/api/ws")
public class ClubWS {
@WebMethod(operationName = "findClubByClubId", action = "urn:findClubByClubId")
@WebResult(name = "club")
public Club findClubByClubId(@XmlElement(required=true)
@WebParam(name = "club_id") String clubId) {
...
}}
最初の Web メソッド用に生成されたスキーマは次のとおりです。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://club.com/api/ws">
<soapenv:Header/>
<soapenv:Body>
<ws:findClubMembersByClubId>
<club_id>?</club_id>
<!--Optional:-->
<status>?</status>
</ws:findClubMembersByClubId>
</soapenv:Body>
</soapenv:Envelope>
2 番目の Web メソッド用に生成されたスキーマは次のとおりです。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://club.com/api/ws">
<soapenv:Header/>
<soapenv:Body>
<ws:findClubByClubId>
<!--Optional:-->
<club_id>?</club_id>
</ws:findClubByClubId>
</soapenv:Body>
</soapenv:Envelope>
したがって、最初のものは正常に機能しますが、2 番目のものは機能しません。それはどのように可能ですか?:(