• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Variable response throws error but static response fine?

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I am testing a web service and have come across a strange problem,
In a specific method if I return a static result eg: return = "random value here";
it displays the result on the screen without any errors/issues. The moment I set
it to a variable that is returned even if I add a +"" or .toString(); it throws me an error.

Here is my code:



Here is a printout of the server when using a static var:

INFO: Invoking wsimport with http://localhost:8080/SmsService/SmsService?WSDL
INFO: wsimport successful
SEVERE: cell:0835707641
SEVERE: message:testing
SEVERE: confirmdelivery:false
SEVERE: errorlog:false
SEVERE: You still have more then 50 credits
SEVERE: Orig resM7: ID: d44f624a5276e43da51ab85060955c3a
SEVERE: M7:ID: ab98e7c5d8bdf74cd41f96bcab80fdfd

I have attached the screenshots of both the static and dynamic results.

NB*? -- I should add though that when I try to copy and past the the original
printed value from the glassfish server output i get the following resut:

SEVERE: Orig resM7:

I think this may be the reason that I receive a null pointer, but am very confused
as to why it prints out if this is the case, and how I should resolve it.

Any suggestions?
Thanks


errorresult.jpg
[Thumbnail for errorresult.jpg]
Error Result
successresult.jpg
[Thumbnail for successresult.jpg]
Success Result
 
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Linda,

Lila Fowler wrote:





I think that your http request doesn't return the same result...

System.err.println("Orig resM7:" + response); //original dynamic response return by clickatell

This print doesn't print origresponse but your static variable : response
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the error, but I was editing it on Java Ranch just to illustrate the difference better,
and forgot to edit the variable. Sorry about that, I will edit and correct this. Thanks Guillaume Jourdan

But if you look at my result returned, you will notice different variables print out.

SEVERE: Orig resM7: ID: d44f624a5276e43da51ab85060955c3a //dynamic
SEVERE: M7:ID: ab98e7c5d8bdf74cd41f96bcab80fdfd //static

//Correction line 15


My problem is still the same as the above, a result is returned and printed out but
at the end of the method returns nothing.


Thanks for the help
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lila,

Lila Fowler wrote:
SEVERE: cell:0835707641
SEVERE: message:testing
SEVERE: confirmdelivery:false
SEVERE: errorlog:false
SEVERE: You still have more then 50 credits



I think this is not a free API and you must paid to send a SMS to this cellphone.

Clickatell_SMTP.pdf wrote: To use this API, you need to register at (http://www.clickatell.com/register/?product=1). When you sign up for an SMTP account you will be given a username, password and api_id: keep these at hand. Once you have registered and been activated you will receive 10 free credits with which to test our service. Messages sent with these credits contain a canned (pre-populated) message. You can test the API using these credits, and purchase credits to start sending your own, customised messages



You can find the doc here : : Clickatell_SMTP.pdf
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guillaume,

But I am registered with clickatell and have more then 500 credits available.
My messages are sending without a problem and I am picking up the
session id's, which I am printing out as below.

SEVERE: Orig resM7:ID: d7c46b9f048e42411716ed786b427f62

My problem comes in when I try and pass the response back to the original method
that I used to call the compileSmsUrl() it returns a static variable fine but not a dynamic one.

Thanks for the help.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be sure...

In your real code, you don't have :


But :

String staticurl = "http://api.clickatell.com/http/msg?user=YOUR_USER &password=YOUR_PASSWORD &api_id=11111111&to=";
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for that is because I don't want to post my real username
and real password online thereby letting the any unauthorized person
send sms's that I am paying for.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Lila Fowler wrote:The reason for that is because I don't want to post my real username
and real password online thereby letting the any unauthorized person
send sms's that I am paying for.



I understand, it's just to be sure ;p
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Lila Fowler wrote:My problem comes in when I try and pass the response back to the original method
that I used to call the compileSmsUrl() it returns a static variable fine but not a dynamic one.







What do you do in executeHttpRequest and writeLogInfo methods?

and why you have :


and not :
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The log method literally generates a log file. // Not applicable in this case as returnErrors is set to false - same as above changed the variable to better illustrate the different vars.

I will post the code used all three methods to better illustrate. I normally try to keep the code minimal so that there isn't tons of reading to do, so sorry bout this.

First method -- picks up the variables the user enters



Second method -- goes in here to compile the url needed by clickatall



In the next method the HttpRequest is actually sent to clickatell and a session id is returned



Any ideas?
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your output log of your executeHttpRequest method?

Have you a log who start by : "Response in httpp:" or "Exceptions:" ?
 
    Bookmark Topic Watch Topic
  • New Topic