• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store mal-formed XML sent from the client in server database in webservices?

 
Yogesh Gandhi
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am hosting a web service. I wanted to handle the scenario, in case the client sends a mal-formed XML

Here is the handler I have created




I get to land into the catch(Throwable t) block where I have no information about the XML that was sent.
What I can log into the error log table is just that a mal-formed XML has been sent by client.

Actual Requirement:

To log and store the malformed XML for tracking purposes.

Regards
Yogesh
 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works for me :

 
Yogesh Gandhi
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Meghana,

At line number 3, it throws an exceptiona and lands in throwable block.
Now I don't understand how and why it is working for you,...because the variable msg is null at that time and I won't be able to invoke writeTo method on it, as it'll definitely give me a null pointer exception.

Are you sure that the XML that you have sent is mal-formed?
Would it be possible for you to post the XML that was sent?

Regards
Yogesh
 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad. I thought, you had the exception on line 4. Can you post the malformed XML , so I can try ?
 
Yogesh Gandhi
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the delayed response.

You can remove any one closing tag from the XML that you are sending (that way the XML will be mal-formed).

I desperately need this, because client will be sending thousands of requests in a day. And at the end of the day he may come up and ask, which and how many requests failed.
I will be able to answer him, only when I will have the XML recorded somewhere (when it was malformed, so that he can recognize and send it again).

Appreciate your help !!!

Regards
Yogesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic