This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Services and the fly likes How to store mal-formed XML sent from the client in server database in webservices? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "How to store mal-formed XML sent from the client in server database in webservices?" Watch "How to store mal-formed XML sent from the client in server database in webservices?" New topic
Author

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

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
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

Joined: Jan 29, 2002
Posts: 76
This works for me :



Meghana Reddy
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
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

Joined: Jan 29, 2002
Posts: 76
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

Joined: Dec 05, 2008
Posts: 212
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
 
GeeCON Prague 2014
 
subject: How to store mal-formed XML sent from the client in server database in webservices?