Java question on GetLetterStatus

Hi,

I am trying to integrate the PostalMethods API with our Java/J2EE web application. I am able to successfully send a letter and get a response (i.e, the letter id).

But, when I try to get the Status of the Letter, I am getting a null pointer exception. I looked into your samples which you provided to try my test case.

This problem occurs when the previously sent letter has an error (in this case the Address is invalid). The code I am trying is below

GetLetterStatusResponse response = client.getLetterStatus(1234); (note: number 1234 is not the real one)
returnCode = response.getResult().getCode();
System.out.println("Result Code: " + response.getResult().getCode());

The result code is fine. I am getting -3000.
But, when I try
System.out.println(response.getLetterStatus().toString());
I am getting a null pointer exception.

Could you please help me with this.

Also I see in the resources for GetLetterStatus API, the
Output: GetLetterStatusResponse
Structure: GetLetterStatusResult

How can I get the GetLetterStatusResult object from GetLetterStatusResponse.

Thanks,
Nixon

Comments

Hi Nixon, thanks for your

Hi Nixon, thanks for your post.

This sounds like it could be a bug in LetterStatus.toString(). Can you please post the stack trace you're getting the NullPointerException in?

thanks...
Hernan

Hi Hernan, This is the code

Hi Hernan,

This is the code I am using to check(get) status.

GetLetterStatusResponse response = client.getLetterStatus(1022543);
LetterStatus letterStatus = response.getLetterStatus();

int letterId = letterStatus.getLetterId();
LetterStatusCode code = letterStatus.getStatusCode();
returnCode = response.getResult().getCode();

System.out.println("Letter ID : " + letterId);
--- ERROR LINE System.out.println("Letter Status code: " + code.getCode());
System.out.println("Letter Status desc: " + code.getDescription());
System.out.println("result code : " + returnCode);

This is the Ouput
-----------------
Letter ID : 1022543
java.lang.NullPointerException
at com.northstar.postoffice.ejb.MessageManagerBusiness.getWelcomeLetterStatus(MessageManagerBusiness.java:466)
at TestPostOffice.main(TestPostOffice.java:22)

Thanks for your help.
Like I said in my earlier emails...it happends (i.e, the Status code is null) only for those letters which failed the address verification
Let me know if you need further info.

Nixon

Thanks for the feedback,

Thanks for the feedback, Nixon. You should never have to check those values and this is a bug in the client build you're using. The service is returning a few new error messages that the client doesn't know about.

I'll roll an updated build that knows how to deal with these errors and it should solve this issue for you. Thanks for your patience and for posting details. I'll post again when a new build is available with instructions on how you cat fetch it.

hernan

A new build is available for

A new build is available for download from the Java samples section.

Hi David, I did download the

Hi David,

I did download the updated build from the Java samples section. And I am still getting a Null pointer exception when I am trying to get the Status Code.

Could you send me instructions on how to get the status code?

BTW, I am getting the

BTW, I am getting the resultCode (Web service code) as -3000, Its the StatusCode of the document which I am not able to get.

Hi David/Hernan, The new

Hi David/Hernan,

The new Java build worked. Now I am able to get the StatusCode for failed letters. Thanks for your help.

Nixon