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: 219
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: 219
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: 219
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
 
Have you checked out Aspose?
 
subject: How to store mal-formed XML sent from the client in server database in webservices?
 
It's not a secret anymore!