+ Start a Discussion
WilmerWilmer 

How to catch an Apex webservice error message when you call it from a scontrol?

Hi,

 

We have a scontrol that calls an apex webservice by the API an it was working fine until some days ago that it started to retrieve the following error message (not all the time):

 

 

ERROR: ........... {faultcode:'soapenv:Server', faultstring:'Unable to deserialize inputstream', }

 

This is the summary of the scontrol code:

 

 

<script src="/soap/ajax/13.0/connection.js"></script>
<script src="/soap/ajax/13.0/apex.js"></script>
<Script language="JavaScript">
// here goes another code
function callWS(){
var process = sforce.apex.execute('MyApexWebservice', 'Method1',{param1:1, starting: var_mystart, param2: var_for_param2, param3: var_for_param3 },
function(result){
// here is another logic according to the received result.
if(result[0]!='0'){
// If process hasn´t finished yet it is recalled for next iteration
var_mystart = result[0];
settimeout("callWS();",90);
}
});
}
</script>

 

 

 So now,

 

1: I would like to know what does that error message means? It seems to be a Server side problem.

2. Is there any possible way to catch that error? I already tried to add the "try catch" sentence to the scontrol and to the apex webservice but in none place it is catched.

 

I'd like to catch that kind of error message so I could implement a RETRY method.

 

Thanks to all of you who could help me.

 

Regards,

 

Wilmer

china.leafchina.leaf

class code: 

 

global class MyTest{

    WebService static string testReturnValue(){

        string fchrResult = '{success:true, msg : ""}';

        try{//your code

        }

         catch(DmlException ex){

             fchrResult = '{success:false, msg:"' + ex.getMessage() + '"}';
        }

    } 

}

 

javascript&colon;

var _Result = function(result, source){
   eval('r=' + result[0]);
   if(!r.success){
      alert(r.msg);
   }
};

Message Edited by china.leaf on 05-18-2009 12:40 AM
WilmerWilmer

Great, china.

 

I'll try to do it like that and let know as soon as possible the result of the test.

 

Thanks,

 

Wilmer

WilmerWilmer

Hi china.leaf and everybody arround.

 

Look, I developed as you suggested me and get the value the result when the process is successful, but, when the error message I mentioned comes up, the catch part of the code doesn't work properly and it is no possible to handle from the scontrol so the entire process is stopped.

 

Any other ideas?

 

Thanks,

 

Wilmer

china.leafchina.leaf

Try to modify "DMLException" to "Exception"

 

Maybe it is another exception, not a dmlexception

WilmerWilmer

Hi china.leaf,

 

I tried again and unfortunatelly I can´t catch the error. I used the Exception keyword as you suggested but nothing. All I get is the success value, but not when the error message "ERROR: ........... {faultcode:'soapenv:Server', faultstring:'Unable to deserialize inputstream', }" prompts.

 

Thanks for your help. Do you have any other suggestion?

 

Regards,

 

Wilmer 

china.leafchina.leaf

Sorry, I have no idea

 

 

 

Message Edited by china.leaf on 05-20-2009 02:40 AM
Message Edited by china.leaf on 05-20-2009 02:41 AM