I have mocked up a form that I plan on using to post arbitrary values to arbitrary URLs. I am using this mainly to test web services that I am developing via a browser. The page has <input>s
for form method
and action
and many pairs of input="text"
controls to set the name/value pairs that get posted.
This works wonderfully for my services that require the default querystring encoding, i.e.:
POST http://mysite.com/MyService.svc/CheckUsername HTTP/1.1
User-Agent: Fiddler
Host: mysite.com
Content-Length: 15
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
userName=Tester
However, some web services obviously require the data in other formats. Specifically the service I am trying to accommodate is accepts XML:
POST http://mysite.com/MyService.svc/checkusername HTTP/1.1
User-Agent: Fiddler
Host: mysite.com
Content-Length: 60
Content-type: text/xml
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
<CheckUsername> <username>tester</username> </CheckUsername>
How do I get complete control over the payload of a form POST so I can structure the payload properly? Ideally, the solution will be HTML only, but I am also making heavy use of jQuery on the page so using that is also an option. I know I can fully manipulate the data using $.ajax()
but unless I am mistaken, this is not an option because of the same origin policy - I want this form to be able to post to any of my sites without having to upload it to the web server.