The adapter worked before and now the adapter does not work. Mobile Foundation 8.0 beta on my local machine and did a migration to MobileFirst Foundation 8.0 GA release.
The .java server send the image to alchemy and just returns the alchemy xml result to MobileFirst adapter.
The Debug information from Android and iOS are different, so I list both.
a) iOS MobileClient:
The information on the iOS is different from android. It seems there could be a bug in the cordova mfp-pluging implementation for XML adapter:
Because it seems the adapter expects a "responseJSON" in the response json structure, this is what I think, based on the debug information.. The response, with is show by xCode debugger automatically, does NOT contain "responseJSON", but it contains all valid values from the alchemy result.
Just take a look here in the xCode Debug output:
Reason the it sames
016-07-14 11:37:54.021 Check[5996:5470887] >>> Image to get Tags formParams : [object Object]
2016-07-14 11:37:54.021 Check[5996:5470887] >>> Image to get Tags formParams : [object Object]
2016-07-14 11:37:54.810 Check[5996:5470887] >>> Failure, getTags is : [object Object]
2016-07-14 11:37:54.810 Check[5996:5470887] >>> Failure, getTags is : {"responseHeaders":{"Connection":"Keep-Alive","Content-Type":"application/json","X-Powered-By":"Servlet/3.1","X-Backside-Transport":"FAIL FAIL","X-Global-Transaction-ID":"610291743","Date":"Thu, 14 Jul 2016 09:37:54 GMT","Transfer-Encoding":"Identity"},"status":500,"responseText":"{\"statusReason\":\"Internal Server Error\",\"responseHeaders\":{\"Transfer-Encoding\":\"chunked\",\"X-Backside-Transport\":\"FAIL FAIL\",\"Connection\":\"Keep-Alive\",\"X-Global-Transaction-ID\":\"78953555\",\"Content-Language\":\"en-US\",\"Date\":\"Thu, 14 Jul 2016 09:37:54 GMT\",\"Content-Type\":\"text/html;charset=UTF-8\",\"X-Powered-By\":\"Servlet/3.1\"},\"isSuccessful\":false,\"responseTime\":164,\"totalTime\":174,\"warnings\":[],\"errors\":[\"org.xml.sax.SAXParseException: The element type \\\"meta\\\" must be terminated by the matching end-tag \\\"</meta>\\\".\",\"Failed to parse the payload from backend (procedure: getTagsForPicture)\"],\"info\":[],\"statusCode\":500}","responseJSON":{"statusReason":"Internal Server Error","responseHeaders":{"Transfer-Encoding":"chunked","X-Backside-Transport":"FAIL FAIL","Connection":"Keep-Alive","X-Global-Transaction-ID":"78953555","Content-Language":"en-US","Date":"Thu, 14 Jul 2016 09:37:54 GMT","Content-Type":"text/html;charset=UTF-8","X-Powered-By":"Servlet/3.1"},"isSuccessful":false,"responseTime":164,"totalTime":174,"warnings":[],"errors":["org.xml.sax.SAXParseException: The element type \"meta\" must be terminated by the matching end-tag \"</meta>\".","Failed to parse the payload from backend (procedure: getTagsForPicture)"],"info":[],"statusCode":500},"errorCode":500,"errorMsg":"Request failed: internal server error (500)","invocationContext":null}
2016-07-14 11:37:54.814 Check[5996:5470887] ERROR GET TAGS***** [object Object]
2016-07-14 11:38:09.341 Check[5996:5470887] Response Content : {"statusReason":"OK","responseHeaders":{"Transfer-Encoding":"chunked","X-Backside-Transport":"OK OK","Connection":"Keep-Alive","X-Global-Transaction-ID":"336117367","Content-Language":"en-US","Date":"Thu, 14 Jul 2016 09:38:09 GMT","Content-Type":"text/xml;charset=ISO-8859-1","X-Powered-By":"Servlet/3.1"},"isSuccessful":true,"responseTime":2055,"totalTime":2057,"warnings":[],"results":{"totalTransactions":"4","NOTICE":"THIS API FUNCTIONALITY IS DEPRECATED AND HAS BEEN MIGRATED TO WATSON VISUAL RECOGNITION. THIS API WILL BE DISABLED ON MAY 19, 2017.","usage":"By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html","imageKeywords":{"keyword":[{"score":"0.574443","text":"large"},{"score":"0.5","text":"building"}]},"url":"","status":"OK"},"errors":[],"info":[],"statusCode":200}
b) Android MobileClient:
I get following error when I execute the javascript adapter XML from a cordova mobile android client.
1. Array[2]
1. 0:"org.xml.sax.SAXParseException: The element type "meta" must be terminated by the matching end-tag "</meta>"."
2. 1:"Failed to parse the payload from backend (procedure: getTagsForPicture)"
The full error information in the chrome console for the android app:
When I inspect the XML on the server log or in a poster, I don’t see any information.
a) poster xml result:
b) .java server logs in bluemix:
The implementation of the Apdater and the MobileClient:
a) The adapter code:
function getTagsForPicture(urlimage) {
var value = "image=" + urlimage;
var requestStructure = {
method : 'post',
returnedContentType : 'xml',
path : 'GetImageKeywords',
parameters: {'image': urlimage },
headers: {"Accept":"application\/plain"}
};
MFP.Logger.warn("Preparing request structure " + JSON.stringify(requestStructure));
return MFP.Server.invokeHttp(requestStructure);
}
b) The cordova client code:
var formParams = {"params":"['"+ image + "']"};
var getTagsRequest = new WLResourceRequest(
"/adapters/UploadPic/getTagsForPicture",
WLResourceRequest.POST);
console.log('>>> Image to get Tags formParams : ', formParams);
getTagsRequest.sendFormParameters(formParams);
getTagsRequest.send().then(
getTagsSuccess,
getTagsFailure
);