cancel
Showing results for 
Search instead for 
Did you mean: 

unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

Highlighted
Contributor

unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

unable to resolve class "import net.sf.json.xml.XMLSerializer;" while trying to convert json to xml in 2.3.0

6 REPLIES 6
Highlighted
Moderator

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

Hi Harry, 

 

Can you please provide more details about the issue? 

How do you convert? Did it happen to a specific JSON? etc.



Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Contributor

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

i was converting json response to xml. Once i get response from the api. I try parsing it using jsonslupher upon i use xml serialixer to parse json to xml

Highlighted
Contributor

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

//Importing Packages.
import groovy.json.JsonSlurper;
import java.sql.*;
import com.eviware.soapui.SoapUI.*;
import net.sf.json.JSONSerializer;
import net.sf.json.xml.XMLSerializer;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import java.math.*;
import java.util.List;

def tC = testRunner.getTestCase();
def tS = tC.getTestSuite();
def tP = tS.getProject();
def tStep = tC.getTestStepByName('get-ConfigEndpointDetails');
def dbUsername = context.expand( '${#Project#dbUsername}' );
def dbPassword = context.expand( '${#Project#dbPassword}' );
def dbHost = context.expand( '${#Project#targetSystem}' );
def siteType = context.expand( '${#TestCase#siteType}' );
def endpointId = context.expand( '${#TestCase#endpointId}' );

def httpContentType = context.expand( '${#TestCase#httpContentType}' )

//Extracting http status from testCase.
def httpStatus = context.expand( '${#TestCase#httpStatus}' )
log.info "httpStatus is: ----> "+ httpStatus;


if(httpStatus == "HTTP/1.1 500 Internal Server Error")
{

if ( httpContentType == "application/json;charset=UTF-8")
{

//Extracting response.
def responseAsJson = tStep.httpRequest.response.getResponseContent();
log.info responseAsJson


//Conversion from json to xml
def jsontoxml;
XMLSerializer xmlSerializer = new XMLSerializer();
JSON json = JSONSerializer.toJSON(responseAsJson);
xmlSerializer.setTypeHintsEnabled(false);
jsontoxml = xmlSerializer.write( json );
log.info "JSON Response converted to XML Response Result:" + jsontoxml;


//Parsing response by XmlSlurper.
def parsed_xml = new XmlSlurper().parseText(jsontoxml);
log.info "parsed_json Details : " + parsed_xml;

 

this causing failure

Highlighted
Moderator

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

Hi harry,

 

Is it still an issue for you?

 

I've found some articles which could help you if the issue still persists:

https://community.smartbear.com/t5/SoapUI-Pro/Resolved-JSON-conversion-to-XML-does-not-work/m-p/4148...

https://community.smartbear.com/t5/SoapUI-Pro/Conversion-from-JSON-to-XML/m-p/41868



Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Contributor

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

Issue is still reproduciable. The links that are shared doesnot have usefull information.

unable to resolve class net.sf.json.xml.XMLSerializer

Highlighted
Community Manager

Re: unable to resolve class "import net.sf.json.xml.XMLSerializer in Ready APi 2.3.0

Nastya, thank you for your help!

 

Hi @harry , as far as I can see, you might be on the way to solve your issue in this thread with some help from Alexey Karas! Please share the solution with the Community when you find it. Thank you.


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors