http://www.jsonschema2pojo.org/を使用して JSON テンプレートからクラスを作成し、Gensonを使用して JSON を Jersey ベースの WS にマップします。これは私の「jsonクラス」の最初の行です:
@JsonPropertyOrder({
"public_key",
"template",
"signature",
"due_date",
"fulfillment_date",
"template_lang_code",
"clients_id",
"electronic_invoice",
"is_draft",
"recurring_time",
"comment",
"currency",
"items",
"payment_method",
"ts"
})
public class CreateInvoiceBean {
...
...
クラスにもゲッターとセッターがいます。
投稿リクエストを処理するための restfull Ws を作成し、firefox RESTClinent プラグインを使用して jsons オブジェクトを送信しようとしました。
これは、送信しようとした json オブジェクトの最初の行です。
{
"public_key": "7f566499549fc9e6d9cc69ca3b10d5f5",
"template": "billingo",
"signature": "9273882e8b3bc7f57e1ef3bc10041bc4bf9d835c152a1e0b810b77b3d51864ad",
"due_date": "2015-10-30",
...
...}
私の WS Post ハンドラー メソッドは次のようになります。
@POST
@Path("/invoice")
@Consumes("application/json")
@Produces("application/json")
public String createInvoice(CreateInvoiceBean newBillingoInvoice) {
LOG.info("invoicenum:. " + newBillingoInvoice.getDueDate());
return newBillingoInvoice.getDueDate();
}
リクエストが到着し、createInvoice()
メソッドが呼び出されますが、それを呼び出すnewBillingoInvoice.getDueDate()
とnullが返されますが、呼び出すと、リクエストjsonで送信した値が返されます..などnewBillingoInvoice.getSignature()
.. returnを呼び出すと、 returnを値で呼び出す場合..など.. newBillingoInvoice.getXY();
null
newBillingoInvoice.getOtherSomething();
null
私の質問は、1 つのプロパティが同じオブジェクトにあり、もう1 つのプロパティが同じオブジェクトにないということはどのように起こり得るnull
のでしょうか? リクエストを作成するときに、すべてのプロパティを設定しましたnull
。
私を助けてください!ありがとうございました!