Link to home
Start Free TrialLog in
Avatar of Dnx_7
Dnx_7Flag for Belgium

asked on

Receive stream from post http

Hi experts

i need to create a function in my webservice that can receive a stream from a post http

how can i manage that?

also the content-type of the post http is text/xml and the webservice only accept application/x-www-form-urlencoder
do i have to change something in my webservice?

please help

regards
Avatar of naveenkohli
naveenkohli

1. If you are sending the data as XML then you need to set "Conteny-Type" to "text/xml"
2. When response comes, you need to check the content type to make sure it is set to "text/xml" if thats what are expecting
3. When response comes back, the stream is already in ResponseStream property of "HttpResponse" object. You just need to read all the bytes and save them as XML document.
Avatar of Dnx_7

ASKER

hi naveenkohli

i'm a little bit constrained to ask this but if you can show me an example of :

- how to set content type to text/xml? web.config?
- how can you check that the "post" that arrive into the webservice is text/xml content type?
- an example of using responsestream with httpresponse?

thank you in advance

regards
1. Look at the code in following link. See how it is setting the content type to "application/x-www-form-urlencoder". You need to replace that with "text/xml".
http://www.netomatix.com/HttpPostData.aspx

2. Response has property "ContentType". Its a string type. Check for "text/xml" substring in it.

3. Download HTMLParser library from following link. In HttpResponseManager class you will find all the code that checks content type and reads the content stream in byte arrays.

http://www.netomatix.com/Products/DocumentManagement/HTMLParserNet.aspx
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dnx_7

ASKER

great, thank you very much