Dealing with JSON data retrieved from a SOAP web service WSDL using JavaScript

How can I extract the PERSON_ID from the JSON response of a SOAP WSDL in order to display it in my HTML file? I am using JavaScript code on IBM MobileFirst platform and would appreciate any assistance.

var str= result;
        alert(str);
        var ID = str.Envelope.Body.processResponse.PERSON_ID;
    alert(ID);

{
   "Envelope": {
      "Body": {
         "processResponse": {
            "ERROR_CODE": "S",
            "ERROR_MSG": "Login Successful",
            "GROUPS_ID": "76721",
            "PERSON_ID": "309236",
            "PERSON_LOGIN": "Y",
            "PERSON_NAME": "Welcome! ashanka",
            "PERSON_ROLE": "Y",
            "PERSON_UID": "1014336",
            "client": "http:\/\/xmlns.oracle.com\/InternetMobile\/AbsManagement\/BPELProcessUserLogin",
            "xmlns": "http:\/\/xmlns.oracle.com\/InternetMobile\/AbsManagement\/BPELProcessUserLogin"
         }
      },
      "Header": {
         "FaultTo": {
            "Address": "http:\/\/www.w3.org\/2005\/08\/addressing\/anonymous"
         },
         "MessageID": "urn:C9C4DB207D5211E5BF9B25E60F40847D",
         "ReplyTo": {
            "Address": "http:\/\/www.w3.org\/2005\/08\/addressing\/anonymous"
         }
      },
      "env": "http:\/\/schemas.xmlsoap.org\/soap\/envelope\/",
      "wsa": "http:\/\/www.w3.org\/2005\/08\/addressing"
   },
   "errors": [
   ],
   "info": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Content-Length": "1017",
      "Content-Type": "text\/xml; charset=utf-8",
      "Date": "Wed, 28 Oct 2015 09:03:42 GMT",
      "SOAPAction": "\"\"",
      "X-ORACLE-DMS-ECID": "9e10a9dcf92c80fa:-8e91c30:150a34b187a:-8000-0000000000053e79",
      "X-Powered-By": "Servlet\/2.5 JSP\/2.1"
   },
   "responseTime": 106,
   "statusCode": 200,
   "statusReason": "OK",
   "totalTime": 122,
   "warnings": [
   ]
}

Answer №1

These are the steps you can take:

const data = //your JSON response... const personID = data.Envelope.Body.processResponse.PERSON_ID;

//if jQuery is being used

jQuery("#elementID").html(personID);

//otherwise

document.querySelectorAll("#elementID").innerHTML = personID;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing a Bootstrap pop-up Model using JavaScript: A Step-by-Step Guide

I am looking to trigger a Bootstrap Pop-Up Model using a JS function, passing values from the function. When the user clicks on update, I want to return to the JS function and update the values; if they press cancel, nothing should happen. @using (Html.Be ...

Developing a table with JavaScript by parsing JSON data

Starting off, I am relatively new to working with JavaScript. Recently, I attempted to generate a table using data from a JSON file. After researching and following some tutorials, I successfully displayed the table on a web browser. However, I noticed tha ...

Is there a way to link a React component with cucumber.js?

I am looking to integrate React with Cucumberjs by creating a Word class that connects the App component. import { setWorldConstructor } from 'cucumber' import {render } from '@testing-library/react' import React from 'rea ...

Learning how to extract subarray values from JSON in Android is determined by the specific item chosen

I've got a JSON file structured like this: [ { "category" : "Category - 1", "table":[ { "id" : 1, "title" : "Sample Title 1" }, { "id" : 2, ...

The drawbacks of using toJS() in React Redux: Is it really necessary in mapStateToProps()?

After reading through the Redux documentation, I came across a recommendation to not use Immutable with Redux. This advice has left me feeling confused. Why should I avoid using toJS() in the mapStateToProps function? It seems that React already uses Dee ...

Issue: Unrecognized element type in next.js while starting development server

Every time I run npm run dev, I encounter the following error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from th ...

Unexpected TypeScript issue: Unable to access the 'flags' property of an undefined entity

Upon creating a new project and running the serve command, I encountered the following error: ERROR in TypeError: Cannot read property 'flags' of undefined Node version: 12.14 NPM version: 6.13 Contents of package.json: { "name": "angular-t ...

Postman seems to be functioning correctly while AXIOS is encountering issues

I've encountered a strange issue with my MERN app. When I use Postman to send a PUT request to my API, it successfully updates both the API and MongoDB. However, when performing the same action on the front-end, the API does not update even though the ...

When I click on the icon, I wish for it to revert back to its original state by spinning

Is there a way to revert the icons back to their original state when clicked again, without losing any of the current functionalities? When an icon is clicked for the first time, it rotates 180 degrees. The icon rotates back if another icon is clicke ...

Combining an HTML file, a D3.js script file, and manually inputting data in the HTML file

I am relatively new to d3.js and currently working on building a simple application. However, I have encountered a roadblock in my progress. I have a separate JavaScript file named jack.js which generates a pie chart when linked with an HTML page. The Iss ...

Only show the directive methods when using "ng-if"

I am facing an issue with the Opentoke Library directive, particularly when I use the ng-if. The reason for implementing the ng-if is that WebRTC is not supported on IOS devices, so it displays an alert after the DOM has loaded. <div class="opentok" ng ...

What are the steps to implement a chart tooltip formatter in react-highcharts?

How do I utilize the chart tooltip formatter in my React Highcharts wrapper setup? Here is how my config looks: const GRAPH_CONFIG = { ... tooltip: { formatter: (tooltip) => { var text = '<b>' + thi ...

What is the best way to manipulate arrays using React hooks?

Struggling with updating arrays using hooks for state management has been quite a challenge for me. I've experimented with various solutions, but the useReducer method paired with dispatch on onClick handlers seems to be the most effective for perform ...

The ExpressJS middleware is executing twice

I'm experiencing an issue with the following code snippet. When I include the middleware logger() as the first argument to app.use(), it is called twice. However, when I place it as the second argument, it doesn't get executed at all. Can anyone ...

Astro3.0 unable to locate images

I'm working on a simple astro project that is structured like this: └── src    ├── assets    │   └── images    │      └── blend.webp    ├── components    │   └── CoffeeCard.astro    ...

Is there a way to verify the status of a radio button without using a submit button?

What's the best way to determine if the radio box value is Pearson or euclidean? Here's what I have so far: if ($_SERVER['REQUEST_METHOD'] === 'POST') { if($_POST['radio'] == 'Euclidean'){ ...

Implementing dynamic entry controls in Xamarin Forms

I need to retrieve the XML Entry Control from an API that is available in JSON format. All the attributes for the Entry control are provided in JSON. My goal is to incorporate them into an .xml page and access their values (once entered by the user in the ...

Arrange JSON elements in ascending order within a for loop before displaying them according to a specific value

I've been dedicating myself to learning JavaScript for the past month, and I'm currently working on a web page project for educational purposes. However, I've hit a roadblock when it comes to displaying data based on the top 10% and bottom 1 ...

Parsing UK Bank holidays data using Pandas

Having trouble reading the JSON file from this link into pandas properly : I attempted to use json_normalize and also tried opening it as a file with the standard python library, converting to dict, and then reading it into pandas. This is the result I&a ...

Tips on navigating back and forth between two arrays

I am currently working on creating a cycling sliding animation for a set of elements using two arrays: var elms = [elm1, elm2, elm3]; var props = [{x,y,width,height,z-index,opacite,....}, {....}, {....}]; Initially, the elms will be positioned in the sam ...