PureConnect

 View Only

Discussion Thread View
  • 1.  Secure Input

    Posted 06-05-2020 14:50


    In order to use Secure Input ( https://help.genesys.com/pureconnect/mergedprojects/wh_tr/desktop/pdfs/secure_input_tr.pdf ),
    we created a custom handler, which is using a  web service we built  to validate the secure session input values.  The handler is able to connect to our web  service, and we are receiving the correct  information from the secure form  but   "Secure Session Info Validate"  tool cannot return output variable and always goes to the fail state.

    According to the documentation, the output of our web service should looks like the below:

    <?xml version="1.0" encoding="UTF-8"?>

    <outcome value="accepted" details="That number was good" />

     

    Our web service creates the response in what looks like the correct format, but it doesn't work.   Not sure if it's helpful, but here's our C# code for that method:

     

            public IActionResult Validate([FromBody]SubmissionParams requestMessage)

            {

                Request.Headers.Add("Accept", "application/xml");

                var response = new Outcome

                {

                    value = "accepted",

                    details = "That number was good"

                };

               

                var validateResult = $"<outcome value='{response.value}' details='{response.details}'/>";

     

                XmlDocument result = new XmlDocument();

                result.LoadXml(validateResult);

     

                // Create an XML declaration.

                XmlDeclaration xmldecl;

                xmldecl = result.CreateXmlDeclaration("1.0", null, null);

                xmldecl.Encoding = "UTF-8";

     

                // Add the new node to the document.

                XmlElement root = result.DocumentElement;

                result.InsertBefore(xmldecl, root);

                return Ok(result);

            }

     

    When we call the POST method using the Postman app ( Postman | The Collaboration Platform for API Development  )  we are not seeing the xml declaration even thought it's defined it in the method.



    When we use Fiddler to capture the actual response from the web service, it looks like the following:

    HTTP/1.1 200 OK
    Content-Type: application/xml; charset=utf-8
    Server: Microsoft-IIS/10.0
    X-Powered-By: ASP.NET
    Date: Fri, 05 Jun 2020 15:55:57 GMT
    Content-Length: 59
    <outcome value="accepted" details="That number was good" />
    
    




    Handler looks like:







    Can anybody tell me what the issue with my response in the method? And why handler tool fails?

    thank you!







    #Handlers

    ------------------------------
    Mike Abramovitch
    Affinity Global
    ------------------------------


  • 2.  RE: Secure Input

    Posted 06-08-2020 09:49
    Didn't take the time to look at what's wrong with your method, but here's what worked for me:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Xml.Serialization;
    
    namespace _MiddlewareWebService.Models
    {
        public class SecureHandler_Response
        {
            /// <remarks/>
            [System.SerializableAttribute()]
            [System.ComponentModel.DesignerCategoryAttribute("code")]
            [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
            [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
            public partial class outcome
            {
    
                private outcomeValue valueField;
    
                /// <remarks/>
                [System.Xml.Serialization.XmlAttributeAttribute()]
                public outcomeValue value
                {
                    get
                    {
                        return this.valueField;
                    }
                    set
                    {
                        this.valueField = value;
                    }
                }
    
                private string detailsField;
    
                /// <remarks/>
                [System.Xml.Serialization.XmlAttributeAttribute()]
                public string details
                {
                    get
                    {
                        return this.detailsField;
                    }
                    set
                    {
                        this.detailsField = value;
                    }
                }
    
                public override string ToString()
                {
                    using (SecureHandler_Response.StringWriterUTF8 sw = new SecureHandler_Response.StringWriterUTF8())
                    {
                        serializer.Serialize(sw, this, ns);
                        return sw.ToString();
                    }
                }
    
            }
    
            private static XmlSerializer _serializer = null;
    
            private static XmlSerializerNamespaces ns = null;
    
            private static XmlSerializer serializer
            {
                get
                {
                    if (_serializer == null)
                    {
                        _serializer = new XmlSerializer(typeof(outcome));
                        ns = new XmlSerializerNamespaces();
                        ns.Add(String.Empty, String.Empty);
                    }
                    return _serializer;
                }
            }
    
            public class StringWriterUTF8 : StringWriter
            {
                public override Encoding Encoding
                {
                    get { return Encoding.UTF8; }
                }
            }
    
            public enum outcomeValue
            {
                accepted,
                declined
            }
    
        }
    }
    then in your controller respond to the post like this: 
    public async Task<HttpResponseMessage> Post()
            {
                Logging.LogEnter("Post Request");
    
                HttpResponseMessage responseMessage = null;
                SecureHandler_Response.outcome response = null;
    //Do stuff here
    
                response = new SecureHandler_Response.outcome { value = SecureHandler_Response.outcomeValue.declined, details = String.Format("'{0}' does not exist as a valid requestType.", obj.Value("requestType")) };
                Logging.LogExit("Post Request", response.value);
                return responseMessage;
            }


    Hopefully this can help you get started.

    ------------------------------
    Jason Loucks
    Agon Consulting Services
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources