extracted code from JavaXmlRequests. Fixes #2563
Merge pull request #3457 from antonsarov/extract-code-samples

extracted code from JavaXmlRequests. Fixes #2563