473,394 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

webResponse returns nothing? Consuming a WS from aspx page

3
OK all

I have a webservice utilizing API's in to an application.
I want to call this service and load the returned information onto my aspx page.

right now i am not getting any errors in my code...
but i am not getting any results either.

So
1. How to i implement an alert type function in my code to see what values are coming in?
2. Can anyone see what i am doing wrong in the code?

Thanks in advance,

Expand|Select|Wrap|Line Numbers
  1. <%@ Import Namespace="CFE_SW" %>
  2. <%@ Import Namespace="System.Web" %>
  3. <%@ Import Namespace="System.Xml" %>
  4. <%@ Import Namespace="System.Web.Services" %>
  5. <%@ Import Namespace="System.Net" %>
  6. <%@ Import Namespace="System.IO" %>
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <script language="C#" runat="server">
  9.  
  10. CFE_SW.SW_API sw = new SW_API();
  11. public string app;
  12. public string sQuery;
  13. public string client;
  14. public string screenID;
  15. public string searchTxt;
  16. public string res = "notWorking";
  17.  
  18. public void writeMe(string str)
  19. {
  20.     Response.Write(str);
  21. }
  22. public string startXMLGet(string goUrl){
  23.     HttpWebResponse webScraper = getWebResponse(goUrl);
  24.     string xResponse = getWebSource(webScraper);
  25.     return xResponse;
  26. }
  27.   private HttpWebResponse getWebResponse(string url)
  28.         {
  29.             HttpWebRequest webSender = (HttpWebRequest)System.Net.HttpWebRequest.Create(url);
  30.             webSender.Method = "GET";
  31.  
  32.             HttpWebResponse webScraper;
  33.             try
  34.             {
  35.                 webScraper = (HttpWebResponse)webSender.GetResponse();
  36.             }
  37.             catch (Exception e)
  38.             {
  39.                 webScraper = null;
  40.             }
  41.             return (webScraper);
  42.         } //end getWebResponse 
  43.  private string getWebSource(HttpWebResponse webResource)
  44.         {
  45.             string webPage = "";
  46.             if (webResource != null)  //if there was an earlier error then this value could be null..
  47.             {
  48.                 StreamReader webResults = new StreamReader(webResource.GetResponseStream());
  49.                 webPage = webResults.ReadToEnd();
  50.  
  51.                 webResults.Close();
  52.                 webResource.Close();
  53.             }
  54.             return (webPage);
  55.         }//end getWebSource   
  56.  
  57. protected void Page_Load()
  58. {
  59.     app  = Request.QueryString["app"];
  60.     sQuery = Request.QueryString["sQuery"];
  61.     client  = Request.QueryString["client"];
  62.     screenID = Request.QueryString["screenID"];
  63.  
  64.     searchTxt = client + " " + sQuery + " " + screenID;
  65.     search.Text = searchTxt;
  66.  
  67.     res = startXMLGet("http://<servername>/sw_api.asmx/getSearchResultsClient?app=" + app + "&sQuery=" +sQuery+ "&client=" + client + "&screenID=" + screenID);
  68.     //res = sw.getSearchResultsClient(app, sQuery, client, screenID);
  69. }
  70. </script>
  71.  
  72. <head>
  73. <meta http-equiv="Content-Language" content="en-us"/>
  74. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
  75. <title>KM Results</title>
  76. </head>
  77.  
  78. <!-- <body id="webServiceCallerBody" style="behavior:url(webservice.htc)" > -->
  79. <body>
  80. <form id="Form1" runat="server"> 
  81. <table border="0" width="100%">
  82.     <tr>
  83.         <td height="43" valign="top"><font size="4" face="Arial">Knova Search 
  84.         Results</font></td>
  85.         <td align="right" valign="top"><font face="Arial">Search Text</font>
  86.         <asp:TextBox TextMode="SingleLine" id="search" Runat="server" size="50"></asp:TextBox></td>
  87.     </tr>
  88. </table>
  89. <table>
  90.     <tr>
  91.         <td><% Response.Write(res); %></td>
  92.     </tr>
  93. </table>
  94. </form>
  95. </body>
</html>
Aug 31 '07 #1
1 1708
kenobewan
4,871 Expert 4TB
First thing that I suggest is writing the error in catch to see if there is a problem to this point.
Sep 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jonax | last post by:
Hi guys, I have the following code that retrieves a webpage. My problem is getting it to use the right encoding. I've tested it against a danish page, but it won't show the danish characters....
1
by: Jacob | last post by:
Please help figure what I am doing wrong in this code. All I am trying to do is send come data to an aspx page and get some data back. I watched my variable in debug mode and can tell that I am...
2
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url);...
6
by: Brent | last post by:
I'm having odd problems with the WebResponse class. Some servers are speedy, while others don't play along at all. Consider the following pages*: ...
1
by: John | last post by:
I am in need to find a way to get the HTML from an internal URL. For example: I have page : default.aspx?page=Test, I need to get HTML of that page after rendering. At first thought, I would...
9
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
1
by: vito16 | last post by:
Hi, I have some C# code for a console application that was correctly grabbing pages until recently were the data is now incomplete. I am needing to grab all information including sponsored links...
4
by: CindyH | last post by:
Hi I'm trying to use webrequest - webresponse to post a stream. I have set up a simple test with one aspx form holding the post code and trying to get another aspx form to receive the post on...
4
by: CindyH | last post by:
Hi - hope someone can help with this - this code was working for a while in the 'real' code and then suddenly stopped - not sure what happen. I made two simple forms on localhost to try to test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.