jsbx
asked on
Grab data from remote page
Hello,
I'm using HTTPWebRequest to grab data from this remote page:
http://www.interchile.com/empty_page.asp that is absolutly empty with just the word Hello *as you can see if you connect directly to it and view source*.
<WebMethod()> _
Public Function GENERADOR(ByVal StringPrimario As String)
Dim uri As New Uri("http://think/magic/SpGetPost.asp")
Dim data As String = "Texto_Plano=" & StringPrimario & "&go=si"
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Pos t
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-ur lencoded"
Dim writer As New StreamWriter(request.GetRe questStrea m())
writer.Write(data)
writer.Close()
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetR esponseStr eam())
Dim tmp As String = reader.ReadToEnd()
response.Close()
Return tmp '<- here
End If
End Function
Something in this code modify the data so I grab all this XML code instead of just the data "hello":
<?xml version="1.0" encoding="utf-8"?><soap:En velope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><G ENERADORRe sponse xmlns="http://dtebank.cl/"><GENERADORResult xsi:type="xsd:string">Hell o</GENERAD ORResult>< /GENERADOR Response>< /soap:Body ></soap:En velope>
What I need is that "tmp" (look at the code) returns just the value: hello
Thank You.
band
I'm using HTTPWebRequest to grab data from this remote page:
http://www.interchile.com/empty_page.asp that is absolutly empty with just the word Hello *as you can see if you connect directly to it and view source*.
<WebMethod()> _
Public Function GENERADOR(ByVal StringPrimario As String)
Dim uri As New Uri("http://think/magic/SpGetPost.asp")
Dim data As String = "Texto_Plano=" & StringPrimario & "&go=si"
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Pos
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-ur
Dim writer As New StreamWriter(request.GetRe
writer.Write(data)
writer.Close()
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetR
Dim tmp As String = reader.ReadToEnd()
response.Close()
Return tmp '<- here
End If
End Function
Something in this code modify the data so I grab all this XML code instead of just the data "hello":
<?xml version="1.0" encoding="utf-8"?><soap:En
What I need is that "tmp" (look at the code) returns just the value: hello
Thank You.
band
ASKER
It is, i pasted and old code, sorry:
think is my laptop.
<WebMethod()> _
Public Function GENERADOR(ByVal StringPrimario As String)
Dim uri As New Uri("http://www.interchile.com/empty_page.asp")
Dim data As String = "Texto_Plano=" & StringPrimario & "&go=si"
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Pos t
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-ur lencoded"
Dim writer As New StreamWriter(request.GetRe questStrea m())
writer.Write(data)
writer.Close()
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetR esponseStr eam())
Dim tmp As String = reader.ReadToEnd()
response.Close()
Return tmp
End If
End Function
think is my laptop.
<WebMethod()> _
Public Function GENERADOR(ByVal StringPrimario As String)
Dim uri As New Uri("http://www.interchile.com/empty_page.asp")
Dim data As String = "Texto_Plano=" & StringPrimario & "&go=si"
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Pos
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-ur
Dim writer As New StreamWriter(request.GetRe
writer.Write(data)
writer.Close()
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetR
Dim tmp As String = reader.ReadToEnd()
response.Close()
Return tmp
End If
End Function
Hi,
Code you written to get work 'Hello' is correct. Variable tmp has value 'Hello' on last line at return statement.
You have addedWebMethod() attribute for this method. Assuming that, you are calling GENERADOR method through ajax. Soap Envelop related code is added due to that.
Regards,
Rajul
Code you written to get work 'Hello' is correct. Variable tmp has value 'Hello' on last line at return statement.
You have addedWebMethod() attribute for this method. Assuming that, you are calling GENERADOR method through ajax. Soap Envelop related code is added due to that.
Regards,
Rajul
ASKER
I'm using <WebMethod()> _ since this is a webservce
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So how to get rid of all the soap evnelope? this is a public webservce, i can't delete <WebMethod()> is there a native parser or something?
ASKER
Snarf0001:
I can't (or don't know how) since it is a webservce it won't show on the browser if I omit <WebMethod()>
I'm not a .net developer so i'm totaly lost
I can't (or don't know how) since it is a webservce it won't show on the browser if I omit <WebMethod()>
I'm not a .net developer so i'm totaly lost
ASKER
Update: The data is arriving Ok to the VB
It changes in the after Return tmp
It changes in the after Return tmp
ASKER
Thank you
Great, sorry for the delay, had to step into meetings.
Glad you got it working.
Glad you got it working.
Can you explain the relationship between these urls:
http://www.interchile.com/empty_page.asp
http://think/magic/SpGetPost.asp
Which one has the blank source, where "think" is getting called from, which one has the function in the provided source?
Depending on how you're calling it, could be the "WebMethod" declaration, this is usually used from inside an aspx to mark a function as callable from javascript, which often wraps it in a SOAP response as you've shown.
But need more info.