Ejemplo n.º 1
0
    protected void proceedButton_Click(object sender, EventArgs e)
    {
        try
        {
            /* Create a WSDL Utils Client to access the WSDL services */
            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            /* Extract the URL from the text box */
            string url = webPageUrlTextBox.Text;

            /* Call the service to extract the dictionary of objects which represent the operations */
            /* of the service. */
            string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

            /* If no methods were extracted, print an error message and return */
            if (methodsInfo == null || methodsInfo.Length == 0)
            {
                errorMessageLabel.Text = "Error - Couldn't extract operations from the URL";
                return;
            }

            /* Create operations tree and to the placeholder */
            TreeView operationsTree = new TreeView();
            operationsPlaceHolder.Controls.Add(operationsTree);

            /* Add a servce node to the operations tree */
            TreeNode serviceNode = new TreeNode(methodsInfo[0]);
            operationsTree.Nodes.Add(serviceNode);

            /* Traverse through the list of method information and add them */
            /* to the tree view. */
            int i = 1;
            while (i < methodsInfo.Length)
            {
                if (methodsInfo[i].Length > 11 &&
                    methodsInfo[i].Substring(0, 11).Equals("MethodName:"))
                {
                    string[] methodNameInfo =
                        methodsInfo[i].Split(new string[] { "MethodName:" },
                                             StringSplitOptions.None);
                    string methodName = methodNameInfo[1];

                    if (methodName == "Discover")
                    {
                        break;
                    }

                    TreeNode mNameNode = new TreeNode(methodName);
                    serviceNode.ChildNodes.Add(mNameNode);
                    i++;

                    int j = i;
                    while (true)
                    {
                        if (methodsInfo[j].Length > 11 &&
                            methodsInfo[j].Substring(0, 11).Equals("MethodName:"))
                        {
                            break;
                        }

                        if (methodsInfo[j].Substring(0, 6).Equals("PName:"))
                        {
                            string[] paramNameInfo =
                                methodsInfo[j].Split(new string[] { "PName:" },
                                                     StringSplitOptions.None);
                            string paramName = paramNameInfo[1];

                            TreeNode pNameNode = new TreeNode(paramName);
                            mNameNode.ChildNodes.Add(pNameNode);
                            j++;

                            if (methodsInfo[j].Substring(0, 6).Equals("PType:"))
                            {
                                string[] paramTypeInfo =
                                    methodsInfo[j].Split(new string[] { "PType:" },
                                                         StringSplitOptions.None);
                                string paramType = paramTypeInfo[1];

                                TreeNode pTypeNode = new TreeNode(paramType);
                                pNameNode.ChildNodes.Add(pTypeNode);
                                j++;
                            }
                        }
                    }
                    i = j;
                }
            }

            /* Close the WSDL Utils Client */
            wsdlUtilsClient.Close();
        }
        catch (Exception)
        {
            errorMessageLabel.Text = "Error - Couldn't extract operations from the URL";
        }
    }
Ejemplo n.º 2
0
    /* 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();
    }
Ejemplo n.º 3
0
    /* 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;
        }
    }
Ejemplo n.º 4
0
    /* This method gets triggered when a node is selected in the operations tree */
    protected void operationsTree_SelectedNodeChanged(object sender, EventArgs e)
    {
        if (invokeTypeButtonList.SelectedItem == null)
        {
            errorMessageLabel.Text = "You need to select an invocation type to proceed.";
            return;
        }

        /* Create a WSDL Utils Client to access the WSDL services */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        if (invokeTypeButtonList.SelectedItem.Value == "SingleInvoke")
        {
            try
            {
                groupInvokeParametersLabel.Text            = "";
                groupInvokeParametersInstructionLabel.Text = "";
                groupInvokeParametersInputLabel.Text       = "";
                groupInvokeParametersOutputLabel.Text      = "";
                groupInvokeParametersHintLabel.Text        = "";
                groupInvokeList.DataSource = null;
                groupInvokeList.DataBind();
                groupInvokeResultsLabel.Text = "";
                groupInvokeResultsPanel.Controls.Clear();
                resultsLabel.Text = "";
                resultsPanel.Controls.Clear();

                /* Get the selected operation */
                string selectedOperationName = operationsTree.SelectedNode.Text;
                operationsTree.SelectedNode.Selected = false;

                /* Extract the URL from the text box */
                string url = serviceUrlTextBox.Text;

                /* Call the service to extract the dictionary of objects which represent the operations */
                /* of the service. */
                string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

                wsdlUtilsClient.Close();

                /* If no methods were extracted, print an error message and return */
                if (methodsInfo == null || methodsInfo.Length == 0)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                /* Extract method and parameter information from the obtained array */
                extractMethodParamInfo(methodsInfo);

                /* Get parameter information for the selected operation */
                wsdlUtilsService.MethodDetails[] methodDetails = currentServiceMethodDetails.ToArray();

                if (methodDetails == null)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                int i;
                for (i = 0; i < methodDetails.Length; i++)
                {
                    if (methodDetails[i].methodName == selectedOperationName)
                    {
                        break;
                    }
                }

                if (i == methodDetails.Length)
                {
                    errorMessageLabel.Text = "Couldn't find the requested operation";
                    return;
                }

                wsdlUtilsService.ParameterDetails[] parameters = methodDetails[i].inputParameters;

                /* Built in types to look for */
                string[] builtInTypes = new string[] { "System.Boolean", "System.Char", "System.Decimal",
                                                       "System.Double", "System.Single", "System.Int32",
                                                       "System.UInt32", "System.Int64", "System.UInt64",
                                                       "System.Int16", "System.UInt16", "System.String" };

                /* Check if any of the parameters have a type that is not a built-in type */
                for (i = 0; i < parameters.Length; i++)
                {
                    int j;
                    for (j = 0; j < builtInTypes.Length; j++)
                    {
                        if (parameters[i].parameterType == builtInTypes[j])
                        {
                            break;
                        }
                    }

                    if (j == builtInTypes.Length)
                    {
                        /* Method contains an input parameter of type that is not built-in, return */
                        /* Display error message and return */
                        errorMessageLabel.Text = "The system doesn't support invocation of operations with complex input parameters";
                        return;
                    }
                }

                List <wsdlUtilsService.ParameterDetails> parameterList = new List <wsdlUtilsService.ParameterDetails>();
                for (i = 0; i < parameters.Length; i++)
                {
                    parameterList.Add(parameters[i]);
                }

                parameterValueDataList.DataSource = parameterList;
                parameterValueDataList.DataBind();

                parametersLabel.Text = selectedOperationName;
                invokeButton.Visible = true;
                invokeButton.Enabled = true;
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                wsdlUtilsClient.Close();
            }
        }
        else
        {
            try
            {
                operationsTree.SelectedNode.Selected = false;
                parametersLabel.Text = "";
                parameterValueDataList.DataSource = null;
                parameterValueDataList.DataBind();
                resultsLabel.Text = "";
                resultsPanel.Controls.Clear();

                /* Extract the URL from the text box */
                string url = serviceUrlTextBox.Text;

                /* Call the service to extract the dictionary of objects which represent the operations */
                /* of the service. */
                string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

                wsdlUtilsClient.Close();

                /* If no methods were extracted, print an error message and return */
                if (methodsInfo == null || methodsInfo.Length == 0)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                /* Extract method and parameter information from the obtained array */
                extractMethodParamInfo(methodsInfo);

                /* Get parameter information for the selected operation */
                wsdlUtilsService.MethodDetails[] methodDetails = currentServiceMethodDetails.ToArray();

                if (methodDetails == null)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                int i;


                /* Built in types to look for */
                string[] builtInTypes = new string[] { "System.Boolean", "System.Char", "System.Decimal",
                                                       "System.Double", "System.Single", "System.Int32",
                                                       "System.UInt32", "System.Int64", "System.UInt64",
                                                       "System.Int16", "System.UInt16", "System.String" };

                List <wsdlUtilsService.ParameterDetails> parameterList = new List <wsdlUtilsService.ParameterDetails>();

                /* Check if any of the parameters have a type that is not a built-in type */
                for (int k = 0; k < methodDetails.Length; k++)
                {
                    wsdlUtilsService.ParameterDetails[] parameters = methodDetails[k].inputParameters;

                    for (i = 0; i < parameters.Length; i++)
                    {
                        int j;
                        for (j = 0; j < builtInTypes.Length; j++)
                        {
                            if (parameters[i].parameterType == builtInTypes[j])
                            {
                                break;
                            }
                        }

                        if (j == builtInTypes.Length)
                        {
                            /* Method contains an input parameter of type that is not built-in, return */
                            /* Display error message and return */
                            errorMessageLabel.Text = "The system doesn't support invocation of operations with complex input parameters.<br/>" +
                                                     " One of the operations requires complex input parameters. Please try Single Invoke.";
                            return;
                        }

                        parameterList.Add(parameters[i]);
                    }
                }

                groupInvokeList.DataSource = methodDetails;
                groupInvokeList.DataBind();

                groupInvokeParametersLabel.Text            = currentServiceName + " - Group Invoke Test Service ";
                groupInvokeParametersInstructionLabel.Text =
                    "Enter inputs and outputs to each and every input parameters and return " +
                    "types of each and every operation for the service chosen.";
                groupInvokeParametersInputLabel.Text =
                    "Input parameter format - Needs to be as expected by the operation chosen.";
                groupInvokeParametersOutputLabel.Text =
                    "Output parameter format - Needs to be in XML format";
                groupInvokeParametersHintLabel.Text =
                    "Hint - To enter sample inputs and outputs, one can use the single invoke" +
                    "operation before proceeding to group invoke";
                invokeButton.Visible = true;
                invokeButton.Enabled = true;
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                wsdlUtilsClient.Close();
            }
        }
    }
Ejemplo n.º 5
0
    /* This method gets triggered when invoke button is clicked on */
    protected void invokeButton_Click(object sender, EventArgs e)
    {
        if (invokeTypeButtonList.SelectedItem == null)
        {
            errorMessageLabel.Text = "You need to select an invocation type to proceed.";
            return;
        }

        if (invokeTypeButtonList.SelectedItem.Value == "SingleInvoke")
        {
            groupInvokeParametersLabel.Text            = "";
            groupInvokeParametersInstructionLabel.Text = "";
            groupInvokeParametersInputLabel.Text       = "";
            groupInvokeParametersOutputLabel.Text      = "";
            groupInvokeParametersHintLabel.Text        = "";
            groupInvokeList.DataSource = null;
            groupInvokeList.DataBind();
            groupInvokeResultsLabel.Text = "";
            groupInvokeResultsPanel.Controls.Clear();

            List <string> parameters = new List <string>();

            /* Traverse through all the parameterValues and add them to a list */
            foreach (DataListItem item in parameterValueDataList.Items)
            {
                string parameterValue = ((TextBox)item.FindControl("parameterValue")).Text;

                /* If you find that the parameter value is empty, return */
                if (parameterValue == "")
                {
                    errorMessageLabel.Text = "You need to enter all the input parameters to invoke an operation";
                    return;
                }

                parameters.Add(parameterValue);
            }

            string url = serviceUrlTextBox.Text;

            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            try
            {
                /* Invoke the web service method */
                wsdlUtilsService.ReturnData returnData =
                    wsdlUtilsClient.InvokeWebServiceMethod(url, parametersLabel.Text,
                                                           parameters.ToArray());

                /* If return data is null, return */
                if (returnData == null)
                {
                    errorMessageLabel.Text = "The invocation didn't yield any result.";
                    return;
                }

                /* Display the result */
                TextBox resultXmlTextBox = new TextBox();
                resultXmlTextBox.Text     = returnData.objectXML;
                resultXmlTextBox.Rows     = 15;
                resultXmlTextBox.Columns  = 70;
                resultXmlTextBox.TextMode = TextBoxMode.MultiLine;

                resultsLabel.Text = "Results";
                resultsPanel.Controls.Add(resultXmlTextBox);
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Invocation didn't succeed. Try again later.";
            }
        }
        else
        {
            parametersLabel.Text = "";
            parameterValueDataList.DataSource = null;
            parameterValueDataList.DataBind();
            resultsLabel.Text = "";
            resultsPanel.Controls.Clear();

            List <string> inputParameters  = new List <string>();
            List <string> outputParameters = new List <string>();

            foreach (DataListItem item in groupInvokeList.Items)
            {
                DataList inputParameterDataList  = (DataList)item.FindControl("groupInvokeInputParameterList");
                DataList outputParameterDataList = (DataList)item.FindControl("groupInvokeOutputParameterList");

                /* Traverse through all the parameterValues and add them to a list */
                foreach (DataListItem inputItem in inputParameterDataList.Items)
                {
                    TextBox textBox             = (TextBox)inputItem.FindControl("groupInvokeInputParameterValue");
                    string  inputParameterValue = ((TextBox)inputItem.FindControl("groupInvokeInputParameterValue")).Text;

                    /* If you find that the parameter value is empty, return */
                    if (inputParameterValue == "")
                    {
                        errorMessageLabel.Text = "You need to enter all the input parameters to invoke an operation";
                        return;
                    }

                    inputParameters.Add(inputParameterValue);
                }

                /* Traverse through all the parameterValues and add them to a list */
                foreach (DataListItem outputItem in outputParameterDataList.Items)
                {
                    TextBox textBox = (TextBox)outputItem.FindControl("groupInvokeOutputParameterValue");
                    string  outputParameterValue = ((TextBox)outputItem.FindControl("groupInvokeOutputParameterValue")).Text;

                    /* If you find that the parameter value is empty, return */
                    if (outputParameterValue == "")
                    {
                        errorMessageLabel.Text = "You need to enter all the output parameters to invoke an operation";
                        return;
                    }

                    outputParameters.Add(outputParameterValue);
                }
            }

            string url = serviceUrlTextBox.Text;

            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            try
            {
                /* Invoke the web service method */
                wsdlUtilsService.InvokeResult invokeResult =
                    wsdlUtilsClient.InvokeWebServiceOperationsGroup(url, inputParameters.ToArray(),
                                                                    outputParameters.ToArray());

                /* If return data is null, return */
                if (invokeResult == null)
                {
                    errorMessageLabel.Text = "The invocation didn't yield any result.";
                    return;
                }

                Table           resultsTable  = new Table();
                TableHeaderRow  resultsHeader = new TableHeaderRow();
                TableHeaderCell methodHeader  = new TableHeaderCell();
                methodHeader.Text = "Method Name";
                TableHeaderCell statusHeader = new TableHeaderCell();
                statusHeader.Text = "Invoke Status";
                resultsHeader.Cells.Add(methodHeader);
                resultsHeader.Cells.Add(statusHeader);
                resultsTable.Rows.Add(resultsHeader);

                for (int i = 0; i < invokeResult.MethodName.Length; i++)
                {
                    TableRow  row        = new TableRow();
                    TableCell methodCell = new TableCell();
                    TableCell statusCell = new TableCell();
                    methodCell.Text = invokeResult.MethodName[i];

                    if (invokeResult.InvokeStatus[i] == true)
                    {
                        statusCell.Text = "Success";
                    }
                    else
                    {
                        statusCell.Text = "Failure";
                    }

                    row.Cells.Add(methodCell);
                    row.Cells.Add(statusCell);
                    resultsTable.Rows.Add(row);
                }

                groupInvokeResultsPanel.Controls.Add(resultsTable);
                groupInvokeResultsLabel.Text = "Results";
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Invocation didn't succeed. Try again later.";
            }
        }
    }
Ejemplo n.º 6
0
    /* 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();
    }
Ejemplo n.º 7
0
    /* This method is triggered when the explore operations button is clicked on */
    protected void exploreOperationsButton_Click(object sender, EventArgs e)
    {
        /* Create a WSDL Utils Client to access the WSDL services */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        try
        {
            /* Clear previously created inputs */
            operationsLabel.Text = "";
            operationsTree.Nodes.Clear();
            parametersLabel.Text = "";
            parameterValueDataList.DataSource = null;
            parameterValueDataList.DataBind();
            invokeButton.Visible = false;
            invokeButton.Enabled = false;
            resultsLabel.Text    = "";

            groupInvokeParametersLabel.Text            = "";
            groupInvokeParametersInstructionLabel.Text = "";
            groupInvokeParametersInputLabel.Text       = "";
            groupInvokeParametersOutputLabel.Text      = "";
            groupInvokeParametersHintLabel.Text        = "";
            groupInvokeList.DataSource = null;
            groupInvokeList.DataBind();
            groupInvokeResultsLabel.Text = "";
            groupInvokeResultsPanel.Controls.Clear();

            /* Extract the URL from the text box */
            string url = serviceUrlTextBox.Text;

            /* Call the service to extract the dictionary of objects which represent the operations */
            /* of the service. */
            string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

            /* If no methods were extracted, print an error message and return */
            if (methodsInfo == null || methodsInfo.Length == 0)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                return;
            }

            /* Extract method and parameter information from the obtained array */
            extractMethodParamInfo(methodsInfo);

            /* Add a servce node to the operations tree */
            TreeNode serviceNode = new TreeNode(currentServiceName);
            serviceNode.SelectAction = TreeNodeSelectAction.Select;
            operationsTree.Nodes.Add(serviceNode);

            wsdlUtilsService.MethodDetails[] methodDetails =
                currentServiceMethodDetails.ToArray();

            /* Traverse through the method details list and add them to the operations tree */
            for (int i = 0; i < methodDetails.Length; i++)
            {
                TreeNode methodNode = new TreeNode(methodDetails[i].methodName);
                methodNode.SelectAction = TreeNodeSelectAction.Select;
                serviceNode.ChildNodes.Add(methodNode);
            }

            operationsLabel.Text = "Operations Available";
            operationsTree.ExpandAll();

            instructionMessageLabel.Visible = true;
            invokeTypeButtonList.Visible    = true;

            /* Close the WSDL Utils Client */
            wsdlUtilsClient.Close();
        }
        catch (Exception ec)
        {
            errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
            wsdlUtilsClient.Close();
        }
    }
Ejemplo n.º 8
0
    /* This method is triggered when the explore operations button is clicked on */
    protected void exploreOperationsButton_Click(object sender, EventArgs e)
    {
        /* Create a WSDL Utils Client to access the WSDL services */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        try
        {
            /* Clear previously created inputs */
            operationsLabel.Text = "";
            operationsTree.Nodes.Clear();
            parametersLabel.Text = "";
            parameterValueDataList.DataSource = null;
            parameterValueDataList.DataBind();
            invokeButton.Visible = false;
            invokeButton.Enabled = false;
            resultsLabel.Text = "";

            groupInvokeParametersLabel.Text = "";
            groupInvokeParametersInstructionLabel.Text = "";
            groupInvokeParametersInputLabel.Text = "";
            groupInvokeParametersOutputLabel.Text = "";
            groupInvokeParametersHintLabel.Text = "";
            groupInvokeList.DataSource = null;
            groupInvokeList.DataBind();
            groupInvokeResultsLabel.Text = "";
            groupInvokeResultsPanel.Controls.Clear();

            /* Extract the URL from the text box */
            string url = serviceUrlTextBox.Text;

            /* Call the service to extract the dictionary of objects which represent the operations */
            /* of the service. */
            string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

            /* If no methods were extracted, print an error message and return */
            if (methodsInfo == null || methodsInfo.Length == 0)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                return;
            }

            /* Extract method and parameter information from the obtained array */
            extractMethodParamInfo(methodsInfo);

            /* Add a servce node to the operations tree */
            TreeNode serviceNode = new TreeNode(currentServiceName);
            serviceNode.SelectAction = TreeNodeSelectAction.Select;
            operationsTree.Nodes.Add(serviceNode);

            wsdlUtilsService.MethodDetails[] methodDetails =
                                            currentServiceMethodDetails.ToArray();

            /* Traverse through the method details list and add them to the operations tree */
            for (int i = 0; i < methodDetails.Length; i++)
            {
                TreeNode methodNode = new TreeNode(methodDetails[i].methodName);
                methodNode.SelectAction = TreeNodeSelectAction.Select;
                serviceNode.ChildNodes.Add(methodNode);
            }

            operationsLabel.Text = "Operations Available";
            operationsTree.ExpandAll();

            instructionMessageLabel.Visible = true;
            invokeTypeButtonList.Visible = true;

            /* Close the WSDL Utils Client */
            wsdlUtilsClient.Close();
        }
        catch (Exception ec)
        {
            errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
            wsdlUtilsClient.Close();
        }
    }
Ejemplo n.º 9
0
    /* This method gets triggered when a node is selected in the operations tree */
    protected void operationsTree_SelectedNodeChanged(object sender, EventArgs e)
    {
        if (invokeTypeButtonList.SelectedItem == null)
        {
            errorMessageLabel.Text = "You need to select an invocation type to proceed.";
            return;
        }

        /* Create a WSDL Utils Client to access the WSDL services */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        if (invokeTypeButtonList.SelectedItem.Value == "SingleInvoke")
        {
            try
            {
                groupInvokeParametersLabel.Text = "";
                groupInvokeParametersInstructionLabel.Text = "";
                groupInvokeParametersInputLabel.Text = "";
                groupInvokeParametersOutputLabel.Text = "";
                groupInvokeParametersHintLabel.Text = "";
                groupInvokeList.DataSource = null;
                groupInvokeList.DataBind();
                groupInvokeResultsLabel.Text = "";
                groupInvokeResultsPanel.Controls.Clear();
                resultsLabel.Text = "";
                resultsPanel.Controls.Clear();

                /* Get the selected operation */
                string selectedOperationName = operationsTree.SelectedNode.Text;
                operationsTree.SelectedNode.Selected = false;

                /* Extract the URL from the text box */
                string url = serviceUrlTextBox.Text;

                /* Call the service to extract the dictionary of objects which represent the operations */
                /* of the service. */
                string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

                wsdlUtilsClient.Close();

                /* If no methods were extracted, print an error message and return */
                if (methodsInfo == null || methodsInfo.Length == 0)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                /* Extract method and parameter information from the obtained array */
                extractMethodParamInfo(methodsInfo);

                /* Get parameter information for the selected operation */
                wsdlUtilsService.MethodDetails[] methodDetails = currentServiceMethodDetails.ToArray();

                if (methodDetails == null)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                int i;
                for (i = 0; i < methodDetails.Length; i++)
                {
                    if (methodDetails[i].methodName == selectedOperationName)
                        break;
                }

                if (i == methodDetails.Length)
                {
                    errorMessageLabel.Text = "Couldn't find the requested operation";
                    return;
                }

                wsdlUtilsService.ParameterDetails[] parameters = methodDetails[i].inputParameters;

                /* Built in types to look for */
                string[] builtInTypes = new string[] { "System.Boolean", "System.Char", "System.Decimal",
                                                       "System.Double", "System.Single", "System.Int32",
                                                       "System.UInt32", "System.Int64", "System.UInt64",
                                                       "System.Int16", "System.UInt16", "System.String" };

                /* Check if any of the parameters have a type that is not a built-in type */
                for (i = 0; i < parameters.Length; i++)
                {
                    int j;
                    for (j = 0; j < builtInTypes.Length; j++)
                    {
                        if (parameters[i].parameterType == builtInTypes[j])
                            break;
                    }

                    if (j == builtInTypes.Length)
                    {
                        /* Method contains an input parameter of type that is not built-in, return */
                        /* Display error message and return */
                        errorMessageLabel.Text = "The system doesn't support invocation of operations with complex input parameters";
                        return;
                    }
                }

                List<wsdlUtilsService.ParameterDetails> parameterList = new List<wsdlUtilsService.ParameterDetails>();
                for (i = 0; i < parameters.Length; i++)
                    parameterList.Add(parameters[i]);

                parameterValueDataList.DataSource = parameterList;
                parameterValueDataList.DataBind();

                parametersLabel.Text = selectedOperationName;
                invokeButton.Visible = true;
                invokeButton.Enabled = true;
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                wsdlUtilsClient.Close();
            }
        }
        else
        {
            try
            {
                operationsTree.SelectedNode.Selected = false;
                parametersLabel.Text = "";
                parameterValueDataList.DataSource = null;
                parameterValueDataList.DataBind();
                resultsLabel.Text = "";
                resultsPanel.Controls.Clear();

                /* Extract the URL from the text box */
                string url = serviceUrlTextBox.Text;

                /* Call the service to extract the dictionary of objects which represent the operations */
                /* of the service. */
                string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

                wsdlUtilsClient.Close();

                /* If no methods were extracted, print an error message and return */
                if (methodsInfo == null || methodsInfo.Length == 0)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                /* Extract method and parameter information from the obtained array */
                extractMethodParamInfo(methodsInfo);

                /* Get parameter information for the selected operation */
                wsdlUtilsService.MethodDetails[] methodDetails = currentServiceMethodDetails.ToArray();

                if (methodDetails == null)
                {
                    errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                    return;
                }

                int i;

                /* Built in types to look for */
                string[] builtInTypes = new string[] { "System.Boolean", "System.Char", "System.Decimal",
                                                       "System.Double", "System.Single", "System.Int32",
                                                       "System.UInt32", "System.Int64", "System.UInt64",
                                                       "System.Int16", "System.UInt16", "System.String" };

                List<wsdlUtilsService.ParameterDetails> parameterList = new List<wsdlUtilsService.ParameterDetails>();

                /* Check if any of the parameters have a type that is not a built-in type */
                for (int k = 0; k < methodDetails.Length; k++)
                {
                    wsdlUtilsService.ParameterDetails[] parameters = methodDetails[k].inputParameters;

                    for (i = 0; i < parameters.Length; i++)
                    {
                        int j;
                        for (j = 0; j < builtInTypes.Length; j++)
                        {
                            if (parameters[i].parameterType == builtInTypes[j])
                                break;
                        }

                        if (j == builtInTypes.Length)
                        {
                            /* Method contains an input parameter of type that is not built-in, return */
                            /* Display error message and return */
                            errorMessageLabel.Text = "The system doesn't support invocation of operations with complex input parameters.<br/>" +
                                                     " One of the operations requires complex input parameters. Please try Single Invoke.";
                            return;
                        }

                        parameterList.Add(parameters[i]);
                    }
                }

                groupInvokeList.DataSource = methodDetails;
                groupInvokeList.DataBind();

                groupInvokeParametersLabel.Text = currentServiceName + " - Group Invoke Test Service ";
                groupInvokeParametersInstructionLabel.Text =
                                                  "Enter inputs and outputs to each and every input parameters and return " +
                                                  "types of each and every operation for the service chosen.";
                groupInvokeParametersInputLabel.Text =
                                                  "Input parameter format - Needs to be as expected by the operation chosen.";
                groupInvokeParametersOutputLabel.Text =
                                                  "Output parameter format - Needs to be in XML format";
                groupInvokeParametersHintLabel.Text =
                                                  "Hint - To enter sample inputs and outputs, one can use the single invoke" +
                                                  "operation before proceeding to group invoke";
                invokeButton.Visible = true;
                invokeButton.Enabled = true;
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Couldn't extract operations from the provided URL. Please check the link.";
                wsdlUtilsClient.Close();
            }
        }
    }
Ejemplo n.º 10
0
    /* This method gets triggered when invoke button is clicked on */
    protected void invokeButton_Click(object sender, EventArgs e)
    {
        if (invokeTypeButtonList.SelectedItem == null)
        {
            errorMessageLabel.Text = "You need to select an invocation type to proceed.";
            return;
        }

        if (invokeTypeButtonList.SelectedItem.Value == "SingleInvoke")
        {
            groupInvokeParametersLabel.Text = "";
            groupInvokeParametersInstructionLabel.Text = "";
            groupInvokeParametersInputLabel.Text = "";
            groupInvokeParametersOutputLabel.Text = "";
            groupInvokeParametersHintLabel.Text = "";
            groupInvokeList.DataSource = null;
            groupInvokeList.DataBind();
            groupInvokeResultsLabel.Text = "";
            groupInvokeResultsPanel.Controls.Clear();

            List<string> parameters = new List<string>();

            /* Traverse through all the parameterValues and add them to a list */
            foreach (DataListItem item in parameterValueDataList.Items)
            {
                string parameterValue = ((TextBox)item.FindControl("parameterValue")).Text;

                /* If you find that the parameter value is empty, return */
                if (parameterValue == "")
                {
                    errorMessageLabel.Text = "You need to enter all the input parameters to invoke an operation";
                    return;
                }

                parameters.Add(parameterValue);
            }

            string url = serviceUrlTextBox.Text;

            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            try
            {
                /* Invoke the web service method */
                wsdlUtilsService.ReturnData returnData =
                        wsdlUtilsClient.InvokeWebServiceMethod(url, parametersLabel.Text,
                                                               parameters.ToArray());

                /* If return data is null, return */
                if (returnData == null)
                {
                    errorMessageLabel.Text = "The invocation didn't yield any result.";
                    return;
                }

                /* Display the result */
                TextBox resultXmlTextBox = new TextBox();
                resultXmlTextBox.Text = returnData.objectXML;
                resultXmlTextBox.Rows = 15;
                resultXmlTextBox.Columns = 70;
                resultXmlTextBox.TextMode = TextBoxMode.MultiLine;

                resultsLabel.Text = "Results";
                resultsPanel.Controls.Add(resultXmlTextBox);
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Invocation didn't succeed. Try again later.";
            }
        }
        else
        {
            parametersLabel.Text = "";
            parameterValueDataList.DataSource = null;
            parameterValueDataList.DataBind();
            resultsLabel.Text = "";
            resultsPanel.Controls.Clear();

            List<string> inputParameters = new List<string>();
            List<string> outputParameters = new List<string>();

            foreach (DataListItem item in groupInvokeList.Items)
            {
                DataList inputParameterDataList = (DataList)item.FindControl("groupInvokeInputParameterList");
                DataList outputParameterDataList = (DataList)item.FindControl("groupInvokeOutputParameterList");

                /* Traverse through all the parameterValues and add them to a list */
                foreach (DataListItem inputItem in inputParameterDataList.Items)
                {
                    TextBox textBox = (TextBox)inputItem.FindControl("groupInvokeInputParameterValue");
                    string inputParameterValue = ((TextBox)inputItem.FindControl("groupInvokeInputParameterValue")).Text;

                    /* If you find that the parameter value is empty, return */
                    if (inputParameterValue == "")
                    {
                        errorMessageLabel.Text = "You need to enter all the input parameters to invoke an operation";
                        return;
                    }

                    inputParameters.Add(inputParameterValue);
                }

                /* Traverse through all the parameterValues and add them to a list */
                foreach (DataListItem outputItem in outputParameterDataList.Items)
                {
                    TextBox textBox = (TextBox)outputItem.FindControl("groupInvokeOutputParameterValue");
                    string outputParameterValue = ((TextBox)outputItem.FindControl("groupInvokeOutputParameterValue")).Text;

                    /* If you find that the parameter value is empty, return */
                    if (outputParameterValue == "")
                    {
                        errorMessageLabel.Text = "You need to enter all the output parameters to invoke an operation";
                        return;
                    }

                    outputParameters.Add(outputParameterValue);
                }
            }

            string url = serviceUrlTextBox.Text;

            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            try
            {
                /* Invoke the web service method */
                wsdlUtilsService.InvokeResult invokeResult =
                        wsdlUtilsClient.InvokeWebServiceOperationsGroup(url, inputParameters.ToArray(),
                                                                        outputParameters.ToArray());

                /* If return data is null, return */
                if (invokeResult == null)
                {
                    errorMessageLabel.Text = "The invocation didn't yield any result.";
                    return;
                }

                Table resultsTable = new Table();
                TableHeaderRow resultsHeader = new TableHeaderRow();
                TableHeaderCell methodHeader = new TableHeaderCell();
                methodHeader.Text = "Method Name";
                TableHeaderCell statusHeader = new TableHeaderCell();
                statusHeader.Text = "Invoke Status";
                resultsHeader.Cells.Add(methodHeader);
                resultsHeader.Cells.Add(statusHeader);
                resultsTable.Rows.Add(resultsHeader);

                for (int i = 0; i < invokeResult.MethodName.Length; i++)
                {
                    TableRow row = new TableRow();
                    TableCell methodCell = new TableCell();
                    TableCell statusCell = new TableCell();
                    methodCell.Text = invokeResult.MethodName[i];

                    if (invokeResult.InvokeStatus[i] == true)
                        statusCell.Text = "Success";
                    else
                        statusCell.Text = "Failure";

                    row.Cells.Add(methodCell);
                    row.Cells.Add(statusCell);
                    resultsTable.Rows.Add(row);
                }

                groupInvokeResultsPanel.Controls.Add(resultsTable);
                groupInvokeResultsLabel.Text = "Results";
            }
            catch (Exception ec)
            {
                errorMessageLabel.Text = "Invocation didn't succeed. Try again later.";
            }

        }
    }
Ejemplo n.º 11
0
    protected void proceedButton_Click(object sender, EventArgs e)
    {
        addressResultsPlaceHolder.Controls.Clear();
        errorMessageLabel.Text = "";

        /* Create a WSDL utilities client */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        /* Create an array to store all the URLs */
        string[] urls;

        try
        {
            /* Extract the URLs by calling the WSDL Utilities service */
            urls = wsdlUtilsClient.ExtractWsdlAddresses(webPageUrlTextBox.Text);
        }
        catch (Exception)
        {
            errorMessageLabel.Text = "Could not find any WSDL URLs";
            return;
        }

        /* If no URLs were found, return an error message */
        if (urls == null || urls.Length == 0)
        {
            errorMessageLabel.Text = "Could not find any WSDL URLs";
            return;
        }

        /* Create a Table to store the URL results */
        Table urlResultsTable = new Table();

        addressResultsPlaceHolder.Controls.Add(urlResultsTable);

        /* Create the Header row and the appropriate label to it */
        TableHeaderRow th = new TableHeaderRow();
        Label          linkHeaderLabel = new Label();

        linkHeaderLabel.Text = "Link";
        TableHeaderCell linkHeaderCell = new TableHeaderCell();

        linkHeaderCell.Controls.Add(linkHeaderLabel);
        th.Cells.Add(linkHeaderCell);

        urlResultsTable.Rows.Add(th);

        /* Parse through the list of URLs and add one row per result to the table */
        for (int i = 0; i < urls.Length; i++)
        {
            /* Break, if you find a Null pointer */
            if (urls[i] == null)
            {
                break;
            }

            /* Add a new row for each URL */
            TableRow tr = new TableRow();

            HyperLink link = new HyperLink();
            link.Text        = urls[i];
            link.NavigateUrl = urls[i];
            TableCell linkCell = new TableCell();
            linkCell.Controls.Add(link);
            tr.Cells.Add(linkCell);

            urlResultsTable.Rows.Add(tr);
        }

        /* Close the WSDL Utils client */
        wsdlUtilsClient.Close();
    }
Ejemplo n.º 12
0
    protected void proceedButton_Click(object sender, EventArgs e)
    {
        addressResultsPlaceHolder.Controls.Clear();
        errorMessageLabel.Text = "";

        /* Create a WSDL utilities client */
        wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
            new wsdlUtilsService.WSDLServiceClient();

        /* Create an array to store all the URLs */
        string[] urls;

        try
        {
            /* Extract the URLs by calling the WSDL Utilities service */
            urls = wsdlUtilsClient.ExtractWsdlAddresses(webPageUrlTextBox.Text);
        }
        catch (Exception)
        {
            errorMessageLabel.Text = "Could not find any WSDL URLs";
            return;
        }

        /* If no URLs were found, return an error message */
        if (urls == null || urls.Length == 0)
        {
            errorMessageLabel.Text = "Could not find any WSDL URLs";
            return;
        }

        /* Create a Table to store the URL results */
        Table urlResultsTable = new Table();
        addressResultsPlaceHolder.Controls.Add(urlResultsTable);

        /* Create the Header row and the appropriate label to it */
        TableHeaderRow th = new TableHeaderRow();
        Label linkHeaderLabel = new Label();
        linkHeaderLabel.Text = "Link";
        TableHeaderCell linkHeaderCell = new TableHeaderCell();
        linkHeaderCell.Controls.Add(linkHeaderLabel);
        th.Cells.Add(linkHeaderCell);

        urlResultsTable.Rows.Add(th);

        /* Parse through the list of URLs and add one row per result to the table */
        for (int i = 0; i < urls.Length; i++)
        {
            /* Break, if you find a Null pointer */
            if (urls[i] == null)
                break;

            /* Add a new row for each URL */
            TableRow tr = new TableRow();

            HyperLink link = new HyperLink();
            link.Text = urls[i];
            link.NavigateUrl = urls[i];
            TableCell linkCell = new TableCell();
            linkCell.Controls.Add(link);
            tr.Cells.Add(linkCell);

            urlResultsTable.Rows.Add(tr);
        }

        /* Close the WSDL Utils client */
        wsdlUtilsClient.Close();
    }
Ejemplo n.º 13
0
    /* 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;
        }
    }
Ejemplo n.º 14
0
    protected void proceedButton_Click(object sender, EventArgs e)
    {
        try
        {
            /* Create a WSDL Utils Client to access the WSDL services */
            wsdlUtilsService.WSDLServiceClient wsdlUtilsClient =
                new wsdlUtilsService.WSDLServiceClient();

            /* Extract the URL from the text box */
            string url = webPageUrlTextBox.Text;

            /* Call the service to extract the dictionary of objects which represent the operations */
            /* of the service. */
            string[] methodsInfo = wsdlUtilsClient.GetWebServiceMethodsInfo(url);

            /* If no methods were extracted, print an error message and return */
            if (methodsInfo == null || methodsInfo.Length == 0)
            {
                errorMessageLabel.Text = "Error - Couldn't extract operations from the URL";
                return;
            }

            /* Create operations tree and to the placeholder */
            TreeView operationsTree = new TreeView();
            operationsPlaceHolder.Controls.Add(operationsTree);

            /* Add a servce node to the operations tree */
            TreeNode serviceNode = new TreeNode(methodsInfo[0]);
            operationsTree.Nodes.Add(serviceNode);

            /* Traverse through the list of method information and add them */
            /* to the tree view. */
            int i = 1;
            while (i < methodsInfo.Length)
            {
                if (methodsInfo[i].Length > 11 &&
                    methodsInfo[i].Substring(0, 11).Equals("MethodName:"))
                {
                    string[] methodNameInfo =
                        methodsInfo[i].Split(new string[] { "MethodName:" },
                        StringSplitOptions.None);
                    string methodName = methodNameInfo[1];

                    if (methodName == "Discover")
                        break;

                    TreeNode mNameNode = new TreeNode(methodName);
                    serviceNode.ChildNodes.Add(mNameNode);
                    i++;

                    int j = i;
                    while (true)
                    {
                        if (methodsInfo[j].Length > 11 &&
                            methodsInfo[j].Substring(0, 11).Equals("MethodName:"))
                            break;

                        if (methodsInfo[j].Substring(0, 6).Equals("PName:"))
                        {
                            string[] paramNameInfo =
                                methodsInfo[j].Split(new string[] { "PName:" },
                                StringSplitOptions.None);
                            string paramName = paramNameInfo[1];

                            TreeNode pNameNode = new TreeNode(paramName);
                            mNameNode.ChildNodes.Add(pNameNode);
                            j++;

                            if (methodsInfo[j].Substring(0, 6).Equals("PType:"))
                            {
                                string[] paramTypeInfo =
                                    methodsInfo[j].Split(new string[] { "PType:" },
                                    StringSplitOptions.None);
                                string paramType = paramTypeInfo[1];

                                TreeNode pTypeNode = new TreeNode(paramType);
                                pNameNode.ChildNodes.Add(pTypeNode);
                                j++;
                            }
                        }
                    }
                    i = j;
                }
            }

            /* Close the WSDL Utils Client */
            wsdlUtilsClient.Close();
        }
        catch(Exception)
        {
            errorMessageLabel.Text = "Error - Couldn't extract operations from the URL";
        }
    }