Topic
  • 2 replies
  • Latest Post - ‏2013-01-11T07:47:45Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic TypeError: Cannot find default value for object. Caused by: null

‏2013-01-11T07:42:58Z |
Hi everyone,

This problem confuse me for a long time. I want somebody to help me.

Description:
<form><input type="file" id="files" name="file" onchange="upload()" /></form>,
when I upload a file, it trigger the upload function. The function content as follows:

function upload() {
var files = document.getElementById('files').files;
if (!files.length) {
alert('Please select a file!');
return;
}
var file = files[0];
var reader = new FileReader();

// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
process(evt.target.result);
}
};
reader.readAsText(file);
}
The upload function calls the process function as follows:

function process (result) {
var bytes = stringToBytes(result);
alert(bytes);
var data = {
adapter: 'AAAdapter',
procedure: 'upload',
parameters:
};
alert("bytes:" + bytes);
WL.Client.invokeProcedure(data, {
onSuccess: uploadSuccess,
onFailure: uploadFailure,
timeout: 30000
});
}

And in the adapter, impl.js as follows:

function upload(serviceNo, fileContent, fileName, isLimited) {
var request =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.analyticanswers.spss.ibm.com/">' +
'<soapenv:Header/>'+
'<soapenv:Body>'+
'<web:upload>'+
'<arg0>' + serviceNo + '</arg0>'+
'<arg1>' + fileContent + '</arg1>'+
'<arg2>' + fileName + '</arg2>'+
'<arg3>' + isLimited + '</arg3>'+
'</web:upload>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
var input = {
method : 'post',
returnedContentType : 'text/html',
path : '/aaservice/AAWebServiceService?wsdl',
headers: {Username: 'demo', Password: 'password'},
body: {
content: request.toString(),
contentType: 'text/xml; charset=utf-8'
}
};
var response = WL.Server.invokeHttp(input);
var type = typeof(response);
if ("object" == type) {
if (true == response) {
var dataNodeName = null;
for(var o in response.html.body){
if(o.indexOf("apache.org")>-1){
dataNodeName = o;
}
}
return response.html.bodydataNodeName;
}
else {
// Returning null. Web request was not successful.
return null;
}
}
else {
// Returning null. Response is not an object.
return null;
}
}

All the above is the description.

But when I upload the file, it execute the onFailure: uploadFailure. And I found the error info:

2013-01-11 10:13:00 An error occurred while invoking procedure AAAdapter/upload parameters: {
"arr": [
"10001",
[
65,67,67,79,78,84,95,73,68,44,65,71,69, 44
],
"test1",
true
]
}
*TypeError: Cannot find default value for object.*(D%3A%5CWork%5CIBM%5CAA%5Cworklight%5CworklightWorkspace%5CAnalyticAnswers%5Cadapters%5CAAAdapter/AAAdapter-impl.js#137)
Caused by: null

Can u help me? THX!!!!!!!!!!!!!!!!!!!!!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: TypeError: Cannot find default value for object. Caused by: null

    ‏2013-01-11T07:45:17Z  
    The function process as follows:

    function process (result) {
    var bytes = stringToBytes(result);
    alert("!!" + bytes);
    var data = {
    adapter: 'AAAdapter',
    procedure: 'upload',
    parameters:
    };
    alert("enter data:" + bytes);
    WL.Client.invokeProcedure(data, {
    onSuccess: uploadSuccess,
    onFailure: uploadFailure,
    timeout: 30000
    });
    }

    I miss the parameters just now. Sorry!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: TypeError: Cannot find default value for object. Caused by: null

    ‏2013-01-11T07:47:45Z  
    The function process as follows:

    function process (result) {
    var bytes = stringToBytes(result);
    alert("!!" + bytes);
    var data = {
    adapter: 'AAAdapter',
    procedure: 'upload',
    parameters:
    };
    alert("enter data:" + bytes);
    WL.Client.invokeProcedure(data, {
    onSuccess: uploadSuccess,
    onFailure: uploadFailure,
    timeout: 30000
    });
    }

    I miss the parameters just now. Sorry!
    The paras as follows:
    '10001', bytes, 'test1', true(I cannot input a bracket[])