0
パラメータに到達し、3つの異なるパラメータを返す単純なWebサービスをコーディングしようとしています。複数の値を返すJAX-WS
私は以下のコードでこれを達成できます。しかし、問題は、setterメソッドもWebサービスに含まれていることです。たとえば、私は "setTransactionID"をwebserviceメソッドから除外して保護したいと思っています。コードを変更するにはどうすればよいですか?
package OKS;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public class CheckCredit {
@WebMethod
public Result GetResult(@WebParam(name="username") String username,@WebParam(name="password") String password) {
Result res= new Result();
if ((username!=null)&&(password!=null)) {
if ((username.equals("xyz"))&&(password.equals("123"))) {
res.setResultType(1);
res.setTransactionID("tr12128");
res.setCredit(1220);
} else {
res.setResultType(0);
res.setTransactionID("cr12128");
res.setCredit(0);
}
} else {
res.setResultType(0);
res.setTransactionID("er12128");
res.setCredit(0);
}
return res;
}
}
結果クラス
package OKS;
public class Result {
int resultType;
String TransactionID;
int Credit;
public void setResultType(int resultType) {
this.resultType = resultType;
}
public void setTransactionID(String transactionID) {
TransactionID = transactionID;
}
public void setCredit(int credit) {
Credit = credit;
}
public int getResultType() {
return resultType;
}
public String getTransactionID() {
return TransactionID;
}
public int getCredit() {
return Credit;
}
}
このサービスは、コンパイルし、正常に動作します。しかし、WebServiceにはsetterメソッドも含まれています。 セッターメソッドを除外するにはどうすればよいですか?
setTransactionID()の名前をsetTransactionID_please_dont_export_that_method()などの名前に変更できますか? –
または単にsetTransactionID()パッケージをプライベートな仕事にすることはできますか? –
Aaah、私はあなたが本当にインターフェイスについては気にしないと思ったが、セキュリティについては、そうだよね?その場合、ステートフルなBeanを探しているはずです。http://jax-ws.java.net/nonav/2.2.5/docs/statefulWebservice.htmlプレーンテキストのXMLデータを少しでも安全にすることはできませんあなたは今それをやろうとしています。 –