title: How to convert XML SOAP String to JSONObject (com.ibm.json.java.JSONObject)
body: <p>Good Day, </p>
  
  <p>I have created a java class in Adapter IBM Mobilefirst Platform that will get response from the Jax-ws service.</p>
  
  <pre>
  
       // read direct to soap service - 4/4/2017
          protected JSONObject createJsonObjectFrmSOAPRequest(Map mapsData) throws IOException, SOAPException {
              JSONObject jsonObj = new JSONObject();
              String responseSoap="";
              // Create SOAP Connection
              SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
              SOAPConnection soapConnection = soapConnectionFactory.createConnection();
              try {
              // Send SOAP Message to SOAP Server
              String url = "http://XXXXX:001/test-pvr-ws/empl_get";
              SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(mapsData), url);
  
              // Process the SOAP Response
              responseSoap = printSOAPResponse(soapResponse);
  
              // how to convert to jsonobject, the output is in xml string
              //  XMLToJSONTransformer.transform(responseSoap); - don't know how to use XMLToJSONTransformer
              //JSONObject.parse(responseSoap); // convert String to JSONObject
  
  
              logger.info("jsonObject : " + jsonObj);
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
              return jsonObj;
          }
  
  
          protected String printSOAPResponse(SOAPMessage soapResponse) throws Exception {
              String finalstringEnv = "";
  
              try {
  
                  TransformerFactory transformerFactory = TransformerFactory.newInstance();
                  Transformer transformer = transformerFactory.newTransformer();
                  Source sourceContent = soapResponse.getSOAPPart().getContent();
                  System.out.print("\nResponse SOAP Message = ");
                  //create a StringWriter for the output
                  StringWriter outWriter = new StringWriter();
               // StreamResult result = new StreamResult(System.out); // this is for print line output
                  StreamResult result = new StreamResult(outWriter);
                  transformer.transform(sourceContent, result);
               // how to convert Transformer.transform() to String java
                  StringBuffer sb = outWriter.getBuffer(); 
                  finalstringEnv = sb.toString();
  
  
              } catch (Exception e) {
                  // TODO: handle exception
                  e.printStackTrace();
              }
  
  
  
          return finalstringEnv;
          }
  
  </pre>
  
  <p>2 . This code will get the Response in XML string, but I don't know how to use library com.ibm.json.*. Which I wanted to convert the String Response to JSONObject.</p>
  
  <p>2.1. Result Response in XML Soap Envelope (example successful Result i got).</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;soapenv:Body&gt;
      &lt;a:getTheResponse xmlns:a="http://XXXXX:001/test-pvr-ws/empl_get/"&gt;
      &lt;getTheRecord&gt;
      &lt;statusCode&gt;0&lt;/statusCode&gt;
      &lt;getTheRecord&gt;
      &lt;userid&gt;1212&lt;/userid&gt;
      &lt;/a:getTheResponse&gt;
      &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>2.2. responseSoap String variable i need to convert String XML Soap response To  JSONObject</p>
  
  <pre>
  
      // Process the SOAP Response
        responseSoap = printSOAPResponse(soapResponse);
      //.............. code to convert String XML Soap response To  JSONObject
  
  </pre>