简体   繁体   中英

Javascript/SOAP Error Calling Salesforce Apex Web Service Method

Hoping someone can shed some light on a pesky error that some of my users are seeing in Salesforce. We have a custom button that invokes a VF page containing javascript calls into Apex web services. One particular call is failing with the error message:

faultcode:'soapenv:Client', faultstring:'The content of elements must consist of well-formed character data or markup'

Here is the javascript method making the call:

function copyQPP(quoteResult) 
{
    var qRecords = new sforce.QueryResultIterator(quoteResult);

    if(qRecords.hasNext())
    {
        $('#StatusMessage').html(' Copying Quotes and Products...');        
        var qRecord = qRecords.next();
        var state = {qRecords : qRecords};          
        var callback = {onSuccess: copyQPPs, onFailure: optyFailure, source: state};
        sforce.apex.execute('OpportunityCopyRenewalService2','copyQuoteFromOpty', {copyType:"COPY", NewOptyId:newOpp ,QuoteId:qRecord.Id}, callback);           
    }
    else
    {
        updateProducts('');
    }
}

And here is the Apex webservice method being called:

webservice static Id copyQuoteFromOpty(String CopyType,Id NewOptyId,Id QuoteId ) {

    Id newQuoteId;
    try {
        newQuoteId=copyRenewQuote(CopyType,NewOptyId,QuoteId, true);
        Id[] PPs=new List<Id>();  
        for (Proposed_Product__c aPP :  [Select Id from Proposed_Product__c where Quote__c=:QuoteId Limit 1000] ) {
            PPs.add(aPP.Id);
        }

        List<Id> PPreturn = copyRenewPPs(CopyType,newQuoteId,NewOptyId,PPs);         
    }

    catch (Exception e){
        system.debug(e);
    }

    System.Debug('****************************************************Exiting copyQuoteFromOpty. Returning Quote ID: ' + newQuoteId);
    return newQuoteId;     
}

As you can see from the callback definition, I'm expecting control to move on to the copyQPPs function. Instead, when the service method completes - and it does so successfully, no exception is thrown by the DML - control goes to the optyFailure function.

This is only happening to a subset of users. The QA analyst I'm working with is using the same exact version of IE that I am using: v9.0.8112.16421, but she is getting the error and I am not. Also, the error occurs for her regardless of whether she's in Compatibility View or not. (I know, that's only supposed to affect rendering, but I've seen stranger things.)

I suspect that an exception is occurring within the copyQuoteFromOpty web service and is being handled by the try catch block. As such the newQuoteId is null on return.

Comment out the try and catch to see what the actual error is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM