Looked over some of the previous posts that may be related, but unfortunately I have no idea about using webservices and XML. Another developer did this class, and it works great in DE org, but as a managed package I get error below. He can't look at for few weeks, but I feel like this is simple...but I'm not getting it. We are just trying to install into our own org right now and not publish on Appexchange so I don't care if items are hardcoded or ugly to start with.
Line 23 of HitQuestion is bolded below. This is ultimately an AWS WSDL.
Apex script unhandled exception by user/organization: Visualforce
Page: /apex/oneout__GenerateHitAuditSetting caused by:
System.XmlException: Prefix cannot be specified if namespace is not specified Class.OneOut.HitQuestion.getQuestionXml: line 23, column 1
Class.OneOut.AMT.GenerateHit: line 181, column 1
Class.OneOut.Mturk_GenerateHitAuditSettingController.Generate: line 42, column 1
public class HitQuestion {
MTurk__c masterSettings;
public List<String> lstAuditSettingNumber = new List<String>
{'1','2','3','4','5','6','7','8','9','10','11', '12','13','14','15','16','17','18','19','20'};
private String QUESTION = 'Ques_Criteria_'; private String QUESTION_AUDIT = 'Question_';
public String ANSWER = 'Ans_Criteria_';
public String QUESTION_IDENTIFIER = 'Criteria_'; public String QUESTION_AUDIT_IDENTIFIER = 'Response_';
public String REQUIRED = 'Required';
public HitQuestion() {
this.masterSettings = MTurk__c.getInstance(); }
public String getQuestionXml(AuditSetting__c setting){
Dom.Document doc = new Dom.Document();
// **The line below is throwing the exception**
Dom.XmlNode questionForm = doc.createRootElement('QuestionForm',masterSettings.Question_Namespace__c,'');
addInstructions(questionForm,setting);
for(Integer i = 0; i < lstAuditSettingNumber.size(); i++) {
String questionValue = String.valueOf(setting.get(QUESTION_AUDIT + lstAuditSettingNumber[i] + '__c'));
if(questionValue == null || questionValue == '') break;
String answer = String.valueOf(setting.get(getAuditAnswerKey(lstAuditSettingNumber[i])));
String answerType = String.valueOf(setting.get(QUESTION_AUDIT + lstAuditSettingNumber[i] + '_Type__c'));
if(answerType != 'Text' && String.isEmpty(answer)) {
continue;
}
Boolean isRequired = Boolean.valueOf(setting.get(QUESTION_AUDIT + lstAuditSettingNumber[i] + '_Required__c'));
//if(answer == null || answer == '') continue;
Dom.XmlNode question = questionForm.addChildElement('Question',null,null);
String questionIdentifier = QUESTION_AUDIT_IDENTIFIER + lstAuditSettingNumber[i] + '__c';
AddQuestionDetails(question,questionValue,answer,questionIdentifier,answerType,isRequired);
}
return doc.toXmlString(); }
public void addInstructions(Dom.XmlNode questionForm,AuditSetting__c setting){
if(setting.Instructions__c != null) {
Dom.XmlNode ndOverview = questionForm.addChildElement('Overview', null,null);
ndOverview.addChildElement('Text',null,null).addTextNode(setting.Instructions__c);
}