/* This method gets triggered when search button gets clicked */ protected void searchButton_Click(object sender, EventArgs e) { wsdlUtilsService.WSDLServiceClient wsdlUtilsClient = new wsdlUtilsService.WSDLServiceClient(); try { /* Clear previously rendered results */ errorMessageLabel.Text = ""; searchResultsList.DataSource = null; searchResultsList.DataBind(); /* Extract keywords from the keyword text box */ string keyword = searchKeywordTextBox.Text; /* Create the URL string */ string url = "http://webstrar45.fulton.asu.edu/Page0/WSDLSearchService.svc/DiscoverWsdlServices?keywords=" + keyword; //string url = "http://localhost:52677/WSDLSearchService.svc/DiscoverWsdlServices?keywords=" + keyword; /* Create a HTTP web request and extract the response */ HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse response; response = request.GetResponse() as HttpWebResponse; /* Load the response stream into an XML DOM object */ XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(response.GetResponseStream()); XmlNode nodeRef = xmlDoc.DocumentElement; /* Parse the XML DOM to obtain all the URL Infos */ parseResponseXML(nodeRef); List <UrlInfo> urlInfoStructures = new List <UrlInfo>(); int p = 0; /* Traverse through the entire list of URLs obtained, and create a list */ /* of URLs and their titles. */ foreach (var urlInfo in urlInfos) { p++; if (urlInfo == null || urlInfo == "") { break; } string[] urlInfoDecoded = urlInfo.Split(new String[] { "-[TL-LNK-SEP]-" }, StringSplitOptions.None); if (urlInfoDecoded[1].Contains(".pdf") || urlInfoDecoded[1].Contains(".PDF")) { continue; } /* If link is a WSDL link, add it to the table. If the link is not a WSDL link */ /* look for WSDL addresses in the link. */ if (urlInfoDecoded[1].EndsWith(".wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".svc?wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".asmx?wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".php?wsdl", StringComparison.OrdinalIgnoreCase)) { UrlInfo urlInfoStructure = new UrlInfo(); if (urlInfoDecoded[0].Length > 20) { urlInfoDecoded[0] = urlInfoDecoded[0].Substring(0, 20) + " ..."; } if (urlInfoDecoded[0] == "") { urlInfoDecoded[0] = "No-Title"; } urlInfoStructure.title = urlInfoDecoded[0]; urlInfoStructure.link = urlInfoDecoded[1]; urlInfoStructure.methodDetails = ""; try { wsdlUtilsService.MethodDetails[] methodDetails = wsdlUtilsClient.ExtractWsdlOperation(urlInfoDecoded[1]); for (int j = 0; j < methodDetails.Length; j++) { if (urlInfoStructure.methodDetails.Length <= 50) { urlInfoStructure.methodDetails += methodDetails[j].methodName + ", "; } } } catch (Exception) { // Do nothing } urlInfoStructure.methodDetails += "..."; if (urlInfoDecoded[1].Length > 25) { urlInfoDecoded[1] = urlInfoDecoded[1].Substring(0, 25) + " ..."; } urlInfoStructure.shortenedLink = urlInfoDecoded[1]; urlInfoStructures.Add(urlInfoStructure); } /* If not, extract all the addresses from the link. */ else { try { string[] extractedAddresses = wsdlUtilsClient.ExtractWsdlAddresses(urlInfoDecoded[1]); for (int i = 0; i < extractedAddresses.Length; i++) { UrlInfo urlInfoStructure = new UrlInfo(); urlInfoStructure.title = "No-Title"; urlInfoStructure.link = extractedAddresses[i]; urlInfoStructure.methodDetails = ""; try { wsdlUtilsService.MethodDetails[] methodDetails = wsdlUtilsClient.ExtractWsdlOperation(extractedAddresses[i]); for (int j = 0; j < methodDetails.Length; j++) { if (urlInfoStructure.methodDetails.Length <= 50) { urlInfoStructure.methodDetails += methodDetails[j].methodName + ", "; } } } catch (Exception) { // Do nothing } urlInfoStructure.methodDetails += "..."; if (extractedAddresses[i].Length > 25) { extractedAddresses[i] = extractedAddresses[i].Substring(0, 25) + " ..."; } urlInfoStructure.shortenedLink = extractedAddresses[i]; urlInfoStructures.Add(urlInfoStructure); } } catch (Exception) { // Do nothing } } } wsdlUtilsClient.Close(); searchResultsList.DataSource = urlInfoStructures.ToArray(); searchResultsList.DataBind(); urlInfos = null; count = 0; } catch (Exception) { /* Display an error message in case of an exception */ errorMessageLabel.Text = "Error - Reached Google Search API Max limit"; urlInfos = null; count = 0; List <UrlInfo> urlInfoStructures = new List <UrlInfo>(); UrlInfo urlInfo1 = new UrlInfo(); urlInfo1.title = "Title 1"; urlInfo1.link = "http://api.bing.net/search.wsdl"; urlInfo1.shortenedLink = "http://api.bing.net/..."; urlInfoStructures.Add(urlInfo1); UrlInfo urlInfo2 = new UrlInfo(); urlInfo2.title = "Title 2"; urlInfo2.link = "http://www.webservicex.com/globalweather.asmx?WSDL"; urlInfo2.shortenedLink = "http://www.webservic.."; urlInfoStructures.Add(urlInfo2); searchResultsList.DataSource = urlInfoStructures.ToArray(); searchResultsList.DataBind(); wsdlUtilsClient.Close(); return; } }
/* This method gets called when the user clicks the proceed button */ protected void proceedButton_Click(object sender, EventArgs e) { parseResultPlaceHolder.Controls.Clear(); errorMessageLabel.Text = ""; /* Create the WSDL utils proxy */ wsdlUtilsService.WSDLServiceClient wsdlUtils = new wsdlUtilsService.WSDLServiceClient(); /* Extract the URL from the URL box */ string url = urlTextBox.Text; wsdlUtilsService.MethodDetails[] methodsList; try { /* Call the service to extract methods and parameters */ methodsList = wsdlUtils.ExtractWsdlOperation(url); } catch (Exception) { errorMessageLabel.Text = "Couldn't extract details. Check the link provided"; return; } Table parseResultsTable = new Table(); parseResultPlaceHolder.Controls.Add(parseResultsTable); TableHeaderRow th = new TableHeaderRow(); Label methodNameHeaderLabel = new Label(); methodNameHeaderLabel.Text = "Method Name"; TableHeaderCell methodNameHeaderCell = new TableHeaderCell(); methodNameHeaderCell.Controls.Add(methodNameHeaderLabel); th.Cells.Add(methodNameHeaderCell); Label inputParamsHeaderLabel = new Label(); inputParamsHeaderLabel.Text = "Input Params"; TableHeaderCell inputParamsHeaderCell = new TableHeaderCell(); inputParamsHeaderCell.Controls.Add(inputParamsHeaderLabel); th.Cells.Add(inputParamsHeaderCell); Label outputParamsHeaderLabel = new Label(); outputParamsHeaderLabel.Text = "Output Params"; TableHeaderCell outputParamsHeaderCell = new TableHeaderCell(); outputParamsHeaderCell.Controls.Add(outputParamsHeaderLabel); th.Cells.Add(outputParamsHeaderCell); parseResultsTable.Rows.Add(th); /* Parse through the result obtained by calling the service and create a list to be displayed */ foreach (wsdlUtilsService.MethodDetails method in methodsList) { string ipParamString; string opParamString; string methodName = method.methodName + "<br/>"; wsdlUtilsService.ParameterDetails[] ipParams = method.inputParameters; wsdlUtilsService.ParameterDetails[] opParams = method.outputParameters; if (ipParams.Length == 0) { ipParamString = "No input Params<br/>"; } else { ipParamString = "Names: "; foreach (wsdlUtilsService.ParameterDetails parameter in ipParams) { ipParamString += parameter.parameterName + ","; } ipParamString += "<br/>Types: "; foreach (wsdlUtilsService.ParameterDetails parameter in ipParams) { ipParamString += parameter.parameterType + ","; } ipParamString += "<br/>"; } if (opParams.Length == 0) { opParamString = "No output Params<br/>"; } else { opParamString = "Names: "; foreach (wsdlUtilsService.ParameterDetails parameter in opParams) { ipParamString += parameter.parameterName + ","; } opParamString += "<br/>Types: "; foreach (wsdlUtilsService.ParameterDetails parameter in opParams) { opParamString += parameter.parameterType + ","; } opParamString += "<br/>"; } TableRow tr = new TableRow(); Label methodNameLabel = new Label(); methodNameLabel.Text = methodName; TableCell methodNameCell = new TableCell(); methodNameCell.Controls.Add(methodNameLabel); tr.Cells.Add(methodNameCell); Label inputParamsLabel = new Label(); inputParamsLabel.Text = ipParamString; TableCell inputParamsCell = new TableCell(); inputParamsCell.Controls.Add(inputParamsLabel); tr.Cells.Add(inputParamsCell); Label outputParamsLabel = new Label(); outputParamsLabel.Text = opParamString; TableCell outputParamsCell = new TableCell(); outputParamsCell.Controls.Add(outputParamsLabel); tr.Cells.Add(outputParamsCell); parseResultsTable.Rows.Add(tr); } wsdlUtils.Close(); }
/* This method gets called when the user clicks the proceed button */ protected void proceedButton_Click(object sender, EventArgs e) { parseResultPlaceHolder.Controls.Clear(); errorMessageLabel.Text = ""; /* Create the WSDL utils proxy */ wsdlUtilsService.WSDLServiceClient wsdlUtils = new wsdlUtilsService.WSDLServiceClient(); /* Extract the URL from the URL box */ string url = urlTextBox.Text; wsdlUtilsService.MethodDetails[] methodsList; try { /* Call the service to extract methods and parameters */ methodsList = wsdlUtils.ExtractWsdlOperation(url); } catch(Exception) { errorMessageLabel.Text = "Couldn't extract details. Check the link provided"; return; } Table parseResultsTable = new Table(); parseResultPlaceHolder.Controls.Add(parseResultsTable); TableHeaderRow th = new TableHeaderRow(); Label methodNameHeaderLabel = new Label(); methodNameHeaderLabel.Text = "Method Name"; TableHeaderCell methodNameHeaderCell = new TableHeaderCell(); methodNameHeaderCell.Controls.Add(methodNameHeaderLabel); th.Cells.Add(methodNameHeaderCell); Label inputParamsHeaderLabel = new Label(); inputParamsHeaderLabel.Text = "Input Params"; TableHeaderCell inputParamsHeaderCell = new TableHeaderCell(); inputParamsHeaderCell.Controls.Add(inputParamsHeaderLabel); th.Cells.Add(inputParamsHeaderCell); Label outputParamsHeaderLabel = new Label(); outputParamsHeaderLabel.Text = "Output Params"; TableHeaderCell outputParamsHeaderCell = new TableHeaderCell(); outputParamsHeaderCell.Controls.Add(outputParamsHeaderLabel); th.Cells.Add(outputParamsHeaderCell); parseResultsTable.Rows.Add(th); /* Parse through the result obtained by calling the service and create a list to be displayed */ foreach (wsdlUtilsService.MethodDetails method in methodsList) { string ipParamString; string opParamString; string methodName = method.methodName + "<br/>"; wsdlUtilsService.ParameterDetails[] ipParams = method.inputParameters; wsdlUtilsService.ParameterDetails[] opParams = method.outputParameters; if(ipParams.Length == 0) { ipParamString = "No input Params<br/>"; } else { ipParamString = "Names: "; foreach (wsdlUtilsService.ParameterDetails parameter in ipParams) { ipParamString += parameter.parameterName + ","; } ipParamString += "<br/>Types: "; foreach (wsdlUtilsService.ParameterDetails parameter in ipParams) { ipParamString += parameter.parameterType + ","; } ipParamString += "<br/>"; } if (opParams.Length == 0) { opParamString = "No output Params<br/>"; } else { opParamString = "Names: "; foreach (wsdlUtilsService.ParameterDetails parameter in opParams) { ipParamString += parameter.parameterName + ","; } opParamString += "<br/>Types: "; foreach (wsdlUtilsService.ParameterDetails parameter in opParams) { opParamString += parameter.parameterType + ","; } opParamString += "<br/>"; } TableRow tr = new TableRow(); Label methodNameLabel = new Label(); methodNameLabel.Text = methodName; TableCell methodNameCell = new TableCell(); methodNameCell.Controls.Add(methodNameLabel); tr.Cells.Add(methodNameCell); Label inputParamsLabel = new Label(); inputParamsLabel.Text = ipParamString; TableCell inputParamsCell = new TableCell(); inputParamsCell.Controls.Add(inputParamsLabel); tr.Cells.Add(inputParamsCell); Label outputParamsLabel = new Label(); outputParamsLabel.Text = opParamString; TableCell outputParamsCell = new TableCell(); outputParamsCell.Controls.Add(outputParamsLabel); tr.Cells.Add(outputParamsCell); parseResultsTable.Rows.Add(tr); } wsdlUtils.Close(); }
/* This method gets triggered when search button gets clicked */ protected void searchButton_Click(object sender, EventArgs e) { wsdlUtilsService.WSDLServiceClient wsdlUtilsClient = new wsdlUtilsService.WSDLServiceClient(); try { /* Clear previously rendered results */ errorMessageLabel.Text = ""; searchResultsList.DataSource = null; searchResultsList.DataBind(); /* Extract keywords from the keyword text box */ string keyword = searchKeywordTextBox.Text; /* Create the URL string */ string url = "http://webstrar45.fulton.asu.edu/Page0/WSDLSearchService.svc/DiscoverWsdlServices?keywords=" + keyword; //string url = "http://localhost:52677/WSDLSearchService.svc/DiscoverWsdlServices?keywords=" + keyword; /* Create a HTTP web request and extract the response */ HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse response; response = request.GetResponse() as HttpWebResponse; /* Load the response stream into an XML DOM object */ XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(response.GetResponseStream()); XmlNode nodeRef = xmlDoc.DocumentElement; /* Parse the XML DOM to obtain all the URL Infos */ parseResponseXML(nodeRef); List<UrlInfo> urlInfoStructures = new List<UrlInfo>(); int p = 0; /* Traverse through the entire list of URLs obtained, and create a list */ /* of URLs and their titles. */ foreach (var urlInfo in urlInfos) { p++; if (urlInfo == null || urlInfo == "") break; string[] urlInfoDecoded = urlInfo.Split(new String[] { "-[TL-LNK-SEP]-" }, StringSplitOptions.None); if (urlInfoDecoded[1].Contains(".pdf") || urlInfoDecoded[1].Contains(".PDF")) continue; /* If link is a WSDL link, add it to the table. If the link is not a WSDL link */ /* look for WSDL addresses in the link. */ if (urlInfoDecoded[1].EndsWith(".wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".svc?wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".asmx?wsdl", StringComparison.OrdinalIgnoreCase) || urlInfoDecoded[1].EndsWith(".php?wsdl", StringComparison.OrdinalIgnoreCase)) { UrlInfo urlInfoStructure = new UrlInfo(); if (urlInfoDecoded[0].Length > 20) urlInfoDecoded[0] = urlInfoDecoded[0].Substring(0, 20) + " ..."; if (urlInfoDecoded[0] == "") urlInfoDecoded[0] = "No-Title"; urlInfoStructure.title = urlInfoDecoded[0]; urlInfoStructure.link = urlInfoDecoded[1]; urlInfoStructure.methodDetails = ""; try { wsdlUtilsService.MethodDetails[] methodDetails = wsdlUtilsClient.ExtractWsdlOperation(urlInfoDecoded[1]); for (int j = 0; j < methodDetails.Length; j++) { if (urlInfoStructure.methodDetails.Length <= 50) urlInfoStructure.methodDetails += methodDetails[j].methodName + ", "; } } catch (Exception) { // Do nothing } urlInfoStructure.methodDetails += "..."; if (urlInfoDecoded[1].Length > 25) urlInfoDecoded[1] = urlInfoDecoded[1].Substring(0, 25) + " ..."; urlInfoStructure.shortenedLink = urlInfoDecoded[1]; urlInfoStructures.Add(urlInfoStructure); } /* If not, extract all the addresses from the link. */ else { try { string[] extractedAddresses = wsdlUtilsClient.ExtractWsdlAddresses(urlInfoDecoded[1]); for (int i = 0; i < extractedAddresses.Length; i++) { UrlInfo urlInfoStructure = new UrlInfo(); urlInfoStructure.title = "No-Title"; urlInfoStructure.link = extractedAddresses[i]; urlInfoStructure.methodDetails = ""; try { wsdlUtilsService.MethodDetails[] methodDetails = wsdlUtilsClient.ExtractWsdlOperation(extractedAddresses[i]); for (int j = 0; j < methodDetails.Length; j++) { if (urlInfoStructure.methodDetails.Length <= 50) urlInfoStructure.methodDetails += methodDetails[j].methodName + ", "; } } catch (Exception) { // Do nothing } urlInfoStructure.methodDetails += "..."; if (extractedAddresses[i].Length > 25) extractedAddresses[i] = extractedAddresses[i].Substring(0, 25) + " ..."; urlInfoStructure.shortenedLink = extractedAddresses[i]; urlInfoStructures.Add(urlInfoStructure); } } catch(Exception) { // Do nothing } } } wsdlUtilsClient.Close(); searchResultsList.DataSource = urlInfoStructures.ToArray(); searchResultsList.DataBind(); urlInfos = null; count = 0; } catch (Exception) { /* Display an error message in case of an exception */ errorMessageLabel.Text = "Error - Reached Google Search API Max limit"; urlInfos = null; count = 0; List<UrlInfo> urlInfoStructures = new List<UrlInfo>(); UrlInfo urlInfo1 = new UrlInfo(); urlInfo1.title = "Title 1"; urlInfo1.link = "http://api.bing.net/search.wsdl"; urlInfo1.shortenedLink = "http://api.bing.net/..."; urlInfoStructures.Add(urlInfo1); UrlInfo urlInfo2 = new UrlInfo(); urlInfo2.title = "Title 2"; urlInfo2.link = "http://www.webservicex.com/globalweather.asmx?WSDL"; urlInfo2.shortenedLink = "http://www.webservic.."; urlInfoStructures.Add(urlInfo2); searchResultsList.DataSource = urlInfoStructures.ToArray(); searchResultsList.DataBind(); wsdlUtilsClient.Close(); return; } }