Gson - convert from Json to resourcedescriptor - rest

I am implementing rest webservices client to get list of reports from jasper server repository.
I am trying to parse Jasperreports server rest web services json response to java object. I have tried different solutions but no able to get mapped result to resouce descriptor class. Also tried the solution suggested here but didn't help
Any help is appreciated.Thank you in advance.
My JSON response looks like :
{"resourceLookup":[{"version":0,"permissionMask":1,"creationDate":"2016-03-29T11:04:45","updateDate":"2014-05-27T18:48:25","label":"A4 Landscape","uri":"/public/templates/a4_landscape.510.jrxml","resourceType":"file"},{"version":0,"permissionMask":1,"creationDate":"2016-03-29T11:04:45","updateDate":"2014-05-27T18:48:25","label":"A4 Portrait","uri":"/public/templates/a4_portrait.510.jrxml","resourceType":"file"}]}
My code:
Type type1 = new TypeToken<List<ResourceDescriptor>>(){}.getType();
List<ResourceDescriptor> ttt= gson.fromJson(jasonstring, type1);
Error:com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

Related

how to upload file in Advanced Rest Client

I am trying to use post method in this add Attachment to SAP ODATA service (URL), then I am getting the error
"Key 'file_name' not given".
I used Multippart/form-data and given file_name (with single cotes and with out it) still the error is same.
Any idea where to give file_name?
Thanks.

How can I pass a parameter from XML Response tag in a new GET XML Request in Soap UI?

I have tried to find a solution in this community in different threads but yet to find one that I am looking for.
I am using SoapUI version 5.3.0 My Application have a couple of RESTful APIs. Initially I am sending json request to a WebService and getting back the following XML Response:
<StartDataExtractResult xmlns="http://schemas.datacontract.org/2004/07/AriaTechCore" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<StatusCode>1</StatusCode>
<StatusText>success</StatusText>
<RequestNumber>397</RequestNumber>
</StartDataExtractResult>
As soon as RequestNumber tag is generated. I have to access to 2 more XML EndPoints (where the value of RequestNumber is appended) to know the Status as below:
A. http://quickextract.quickaudit.in/webs/quickextract.svc/GetExtractionDetails/396
B.
http://quickextract.quickaudit.in/webs/quickextract.svc/GetRequestStatus/396
As of now, I have created the 2 seperateTestSteps for the above mentioned XML Endpoints:
A. http://quickextract.quickaudit.in/webs/quickextract.svc/GetExtractionDetails/
B. http://quickextract.quickaudit.in/webs/quickextract.svc/GetRequestStatus/
Now I need to append the value within tag in the GET Request to get back a response from the WebServices.
Update:
I have created a 'Property Transfer' at Testsuite level as "TSreqNum". This 'Property Transfer' is getting updated as per the initial Response. But I am not sure how would I append "TSreqNum" to construct the complete GET Request as:
http://quickextract.quickaudit.in/webs/quickextract.svc/GetExtractionDetails/TSreqNum
Can anyone help me out please?
You can use the property within the URL of the GET request:
http://host:port/path/${#TestSuite#TSreqNum}
The URL gets updated with the property value.

Talend ESB : How to validate XML request against a XSD file

I am using Talend Open Studio 5.4.
I have created a service, which on finish generates all schema required for the same service. I have assigned a new job for the service and trying validate input XML request against the request XSD file.
I followed this link, it worked fine, but when I tried to validate an input XML request, as tESBProviderRequst will receive, it did not work.
How to do it?
I'm not a Talend expert, but the way i do this is by transforming first my payload (which type is a "document") into a string, so that the tXSDValidator could work.
The second conversion is just here to allow me to build a custom response with my input fields.
But in any cases, i think you have to pass a document object to your tESBProviderResponse.
I hope it helps.

Coldfusion Webservice and SOAP

I am using coldfusion and IIS 7.5
Problem is that when the web service has 500 error, it returns HTML instead of XML.
Can anyone help me in fixing this please.
Thanks.
This is an Internal Server Error, may have occurred because of a data type mismatch. The server is expecting one data type but you are sending a different data type for the input parameter. Please check the input format of the web service that you are calling.
For example: If you try to consume a web service method which takes a SOAP object as an input parameter and you call that method with a different parameter other than SOAP the server will throw a 500 error.

Parsing response from the WSDL

I've generated the web service client in eclipse for the OpenCalais WSDL using the "develop" client type. Actually I was following this post so not really going in detail. Now when I get the results this way: new CalaisLocator().getcalaisSoap().enlighten(key, content, requestParams);, I get the String object, containing the response XML. Sure it's possible to parse that XML, but I think there must be some way to do it automatically, e.g. getting the response object in the form of some list whatsoever?
The response from the SOAP interface is already parsed. The englighten() method returns an XML string. When you call it with SOAP, this response is wrapped within even more XML. The SOAP library already parses the outer SOAP XML and returns the result of the enlighten() method, which is also XML.