IT Process Automation

  • 1.  Parsing SoapResponseBody

    Posted Dec 26, 2018 03:49 PM

    Hello, i need help parsing a SoapResponseBody on a Invoking SOAP method.

    I have this result:

     

    <ns:getTicketResponse xmlns:ns="http://wrappers.webservice.appservices.core.inteqnet.com">
    <ns:return xmlns:ax267="http://beans.webservice.appservices.core.inteqnet.com/xsd" xmlns:ax269="http://beans.webservice.components.inteqnet.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax269:DefaultServiceResponse">
    <ax269:errors/>
    <ax269:notes/>
    <ax269:resourceName/>
    <ax269:responseBean xsi:type="ax269:Bean"/>
    <ax269:responseFormat>JSON</ax269:responseFormat>
    <ax269:responseStatus>OK</ax269:responseStatus>
    <ax269:responseText>[{
    "Action ID When Approved": "",
    "Action ID When Rejected": "",
    "Action When Approved": "",
    "Action When Rejected": "",
    "Affected Service": "",
    "Affected Service ID": "",
    "Approval Phase": "",
    "Approval Status": "",
    "Assigned Group": "Administration",
    "Assigned Group ID": "1",
    "Assigned Individual": "Basoalto, Fabian",
    "Assigned Individual ID": "7",
    "CCTI ID": "76",
    "Case ID": "100",
    "Case#": "100-119",
    "Category": "Reparaciones",
    "Cause": "",
    "Class": "Servicios Generales",
    "Client Viewable": "----",
    "Closed By": "",
    "Closed On": "",
    "Created By": "Perez, Javier",
    "Created On": "12/19/2018 09:39:48 AM",
    "Description": "Reporte de fallas relacionadas los componentes de luminaria, tales como ampolletas y tubos fluorescentes.",
    "Details": "Este es el detalle de ISM \"Description_Long\"",
    "Email": "agustin.avila@tech.com",
    "First Closed On": "",
    "Impact": "Medium",
    "Impact Code": "2",
    "Item": "1121104220",
    "KB Article ID": "",
    "Last Modified": "12/19/2018 09:46:02 AM",
    "Location": "",
    "Modified By": "Morales, Andres",
    "Organization": "",
    "Parent Ticket ID": "",
    "Parent Ticket Identifier": "",
    "Phase": "Submitted",
    "Phone": "123675",
    "Prioritiy": "Medium",
    "Prioritiy Code": "3",
    "Reason Code": "None",
    "Received In Mailbox": "",
    "Requested For": "Avila ., Mario Agustin",
    "Requester Name": "Avila ., Mario Agustin",
    "Requester Phone": "123675",
    "Resolution": "",
    "Resolved Using Case#": "",
    "Resolved Using Item ID": "",
    "Row ID": "215",
    "SLA Start Date": "12/19/2018 09:39:48 AM",
    "Site": "",
    "Source": "Agent",
    "Source Code": "5",
    "Status": "New",
    "Ticket Type": "Service Request",
    "Total Time Spent (HH:MM)": "00:00",
    "Type": "Luminaria",
    "Urgency": "Medium",
    "Urgency Code": "2",
    "anexo o extensión teléfono": "1235",
    "appr_voting_type": "",
    "auto_route_tickets": "",
    "ca_sdm_ticket": "519702",
    "ca_sdm_uuid_user": "",
    "ccti_search": "",
    "closed_by_name": "",
    "closed_date": "",
    "default_template_id": "",
    "defser_message": "",
    "defser_replaced_query": "",
    "edificio": "",
    "esd_com012_var_field_name": "",
    "esd_org018_var_new_contact_name": "",
    "esd_org023_var_field_name": "",
    "esd_srq001_rdb_priority_new": "",
    "filt_case_id": "",
    "filt_compliance_status": "",
    "filt_target_name": "",
    "filt_ticket_type": "",
    "filt_type": "",
    "filt_user": "",
    "hold_ccti_id": "",
    "is_table_refresh_required": "",
    "islogoutaction": "",
    "isworklogadded": "",
    "last_used_action_id": "",
    "last_used_template_id": "",
    "last_worklog": "",
    "last_worklog_date": "",
    "listapprovalphase": "",
    "listapprovertype": "",
    "nombre del usuario": "FCAMIROAGAV",
    "person1_address_id": "",
    "person1_contact_id": "6",
    "person1_hierarchical_path": "TEST",
    "person1_org_id": "1",
    "person1_org_name": "TEST",
    "person1_root_org_name": "",
    "person2_address_id": "",
    "person2_contact_id": "6",
    "person2_hierarchical_path": "TEST",
    "person2_org_id": "1",
    "person2_org_name": "TEST",
    "person2_root_org_name": "",
    "pflow_guid": "",
    "pflow_id": "43",
    "qcktkt_description": "",
    "recent_activity": "",
    "recheckifcontactisvip": "",
    "rel_column_name": "",
    "rel_table": "",
    "related_ci": "",
    "resolved_by_name": "",
    "resolved_date": "",
    "sector": "",
    "send_worklog_email": "",
    "show_related_tkt_activity": "",
    "show_violation_threshold": "",
    "sla_due_by": "",
    "sla_holiday_name": "",
    "sla_tz_name": "",
    "temp_appr_phase": "",
    "temp_appr_status": "",
    "temp_appr_voting_type": "",
    "template_id": "",
    "ticket_againg_range": "",
    "ticket_pending_approval": "0",
    "translated_act_description": "",
    "translated_act_name": "",
    "translated_act_special_function_name": "",
    "translated_attr_default_value": "",
    "translated_attr_list_of_values": "",
    "translated_attr_name": "",
    "translated_categorization": "",
    "translated_form_name": "",
    "translated_sla_compliance_status": "",
    "translated_template_name": "",
    "translated_ticket_type": "",
    "ubicación piso": "8",
    "vip_flag": "",
    "vip_flag_person1": "false",
    "vip_flag_person2": "false",
    "wall_ticket_type": ""
    }]</ax269:responseText>
    <ax269:statusCode>000</ax269:statusCode>
    <ax269:statusMessage>Success: The request was successfully fulfilled by the server; the service returned results of the operation.</ax269:statusMessage>
    <ax269:warnings/>
    </ns:return>
    </ns:getTicketResponse>

    And I need to parse this value into a variable:

     

    "Details": "Este es el detalle de ISM \"Description_Long\"",

     

    Can anybody help me with this ??

     

    Best regards,

    Fabian



  • 2.  Re: Parsing SoapResponseBody

    Posted Dec 28, 2018 09:41 AM

    Hi Bassoalto,

     

    What you have here is an JSON inside an XML.

    With my level of experience I only face one chance to get your variable :

    1. Extract the JSON from the XML:
      1. Using the Call Results folder inside your WebService Request, you need to pick the follow two checkboxes:
        • "Extract SOAP response code to Dataset variable"
        • "Extract SOAP response body first-level elements to individual Dataset variables"
      2. Then, add a new line into Additional Extracted Data with the follow content at XPath expression
        • //*[local-name()='getTicketResponse']/*[local-name()='return']/*[local-name()='responseText']/text()
    2. At this point you will have a variable in your Post-Execution code with your JSON. Now you only need to extract your variable:

    var object = JSON.parse(<your_var_name>);

    var details = object.Details;

     

    I'm almost sure that it will works like this.

    Please give me some feedback if it works

     

    Regards,

    Sérgio Castro



  • 3.  Re: Parsing SoapResponseBody
    Best Answer

    Posted Jan 03, 2019 11:09 AM

    Muchas gracias Sergio. Finalmente encontré la siguiente forma de aislar el atributo deseado:

     

    function ValorEtiqueta(TextoEnDondeBuscar,NombreEtiqueta) {
    var XMLCuerpo=TextoEnDondeBuscar;
    var XMLEtiqueta=NombreEtiqueta;
    var InicioMensaje= XMLCuerpo.indexOf("<"+XMLEtiqueta+">");
    var FinMensaje= XMLCuerpo.indexOf("</"+XMLEtiqueta+">");
    TextoEnDondeBuscar=TextoEnDondeBuscar.substring(InicioMensaje, FinMensaje);
    TextoEnDondeBuscar=TextoEnDondeBuscar.replace("<"+XMLEtiqueta+">","");
    return TextoEnDondeBuscar;
    }

    function myTrim(x) {
    return x.replace(/^\s+|\s+$/gm,'');
    }

    Process.ResponseTextJSON=ValorEtiqueta(Process.GetDesc_Long_1.SoapResponseBody,"ax269:responseText");

    Process.ArrayTextJSON = Process.ResponseTextJSON.split("\n");
    Process.Desc_Long= "";

    for(Process.count=0;Process.count< Process.ArrayTextJSON.length;Process.count++){

    if(Process.ArrayTextJSON[Process.count].indexOf("Details")>= 1){
    Process.Desc_Long+= " " +Process.ArrayTextJSON[Process.count].split(': "').pop().split('",')[0];
    }
    }

    Process.Desc_Long = myTrim(Process.Desc_Long);
    Process.Desc_Long_tmp =Process.Desc_Long.split("\\n");
    Process.Desc_Long_Final= "";

    for(Process.count2=0;Process.count2< Process.Desc_Long_tmp.length;Process.count2++){

    Process.Desc_Long_Final+= Process.Desc_Long_tmp[Process.count2] + "\n";

    }

    Saludos.