Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi! it might be a weird question but I never really worked with services and endpoints, and here I have a big doubt. We have an app that gets data from some readers and has to validate it with another app (iVadday) not related to us... so the guys requested us to send the parameters in the url like "someurl.aspx?param1=123¶m2=3567564656..." and they will send the return parameters the same way through that url "someurl.aspx?param3=0¶m4=54354" so my question is how to send and then retrieve the return values from that url??? so far, I tried with a dummy that sends parameters like this:
<code>
//I create he request and send the parameters read from the app
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:49198/Default.aspx?anden=" + anden + "&tag=" + tag + "&timeStamp=" + timeStamp);

request.Method = "POST";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

//I can get the stream as a string later
//How can I then get the parameters as they return?</code>


The response to this is the whole stream containing the tags with the html page if I'm correct but what if I want to use the query string to retrieve the return values? or is it not possible here? I'm quite confused with this requirement and with vadday as well.
I've tried with my page dummy named Default which I wrote, that gets the values from the Webrequest.Create and then redirects to the same page but with the new params that I'll retrieve and are right now simulated. I'm wondering if they'll do a response.write with the params and then I'll have to parse the stream or how will they call the page with the new params so I can query the strings??? If anyone can share some light I'll deeply appreciate it! thanks a lot guys you're great
Posted
Updated 30-Mar-11 13:04pm
v2
Comments
JOAT-MON 30-Mar-11 19:05pm    
Fixed code block
mario_silent 30-Mar-11 19:07pm    
thanks, it was my first :/

1 solution

your approach to send the request to other application is correct...
what i understand is u want to read the response too on same URL (Assuming They will send the response in same URL query string). If this is the case then make sure u go step by step on this page.
1.
A.Freeze the Query-string parameter name Like "param1,param2" for sending information from ur app to other. and then
B. Freeze Query-string parameter that u want to received on same url from ur other application ( the data that other application going to send on same url )
2. it is assume that the above code for sending request is called on some event say Button click.
3. For reading the response u need to write the code on "page load" on same page in ur case on someurl.aspx
while writing the code to read the query-string data check whether that parameter ( freezed parameter in step 1.B is exist in the url..u will easily get the code on net how to check paramet in url. that will ensure ur page load code will excute only when the page is hit with some predefined parameter.

i will try to explain it in some sample code.

Consider u fixed the parameter name to send are Param1 and Param2.
So ur request sending will be like "someurl.aspx?param1=123&param2=356756465"
and u fixed the parameter that u will get from response as Param3 and Param4

so ur page load code will look like

Page_load()
{
if(!ispostback)
{
if(querystring contain("Param3 and Param4")
{
write ur parameter reading code
}
}
}
Note : Above is just example. it is not the proper syntax. u need to write it the correct way.

I hope this will full fill you requirement.
 
Share this answer
 
Comments
mario_silent 5-Apr-11 11:19am    
Thanks for the answer, it was sort of what I already did, now all that's left is do some real testing, I've done some dummy testing and it's all good but I hope it works the same with the other guys' way. Thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900