0

I have referred How to read and write XML document node values? to write code to set Attribute of standalone-full.xml. Here is the code.

procedure SaveAttributeToXML(const AFileName, APath, AAttribute, 
  AValue: string);
var
  XMLNode: Variant;
  XMLDocument: Variant;  
begin
  XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0');
  try
    XMLDocument.async := False;
    MsgBox(AFileName, mbConfirmation, MB_OK);
    MsgBox(APath, mbConfirmation, MB_OK);    
    XMLDocument.load(AFileName);
    if (XMLDocument.parseError.errorCode <> 0) then
      MsgBox('The XML file could not be parsed. ' + 
        XMLDocument.parseError.reason, mbError, MB_OK)
    else
    begin
      XMLDocument.setProperty('SelectionLanguage', 'XPath');
      XMLNode := XMLDocument.selectSingleNode(APath);
      XMLNode.setAttribute(AAttribute, AValue); 
      XMLDocument.save(AFileName);
    end;
  except
    MsgBox('An error occured!' + #13#10 + GetExceptionMessage, 
      mbError, MB_OK);  
  end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if(CurStep=ssPostInstall) then begin
   SaveAttributeToXML(ExpandConstant('{app}') + '\jboss\standalone\configuration\standalone-full.xml','/server/profile/subsystem[@xmlns=''urn:jboss:domain:web:1.1'']/connector[@name=''http'']','enabled',HttpEnable);
  end
end;

Here is the xml

<server xmlns="urn:jboss:domain:1.2">
...
<profile>
 <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" executor="http-executor" enabled="true"/>
            <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true" executor="http-executor" enabled="true">
                <ssl name="ssl" password="changeit" certificate-key-file="${jboss.server.config.dir}/wfa.keystore" cipher-suite="TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" verify-client="false"/>
            </connector>
            <virtual-server name="default-host" enable-welcome-root="false">
                <alias name="localhost"/>
                <sso reauthenticate="true"/>
            </virtual-server>
        </subsystem>
<profile>
</server>

But i am getting Nil interface exception.

Community
  • 1
  • 1
Anuk
  • 1
  • 4
  • I assume you got *"Variant is null, cannot invoke"* error message, did you ? You need to be precise in the problem description... Also, your code won't even compile. But well, my guess is that problem is with the XPath you used. Could you post **only relevant** XML node tree that you're modifying ? – TLama May 14 '14 at 10:10
  • Sure.Here is the xml. – Anuk May 14 '14 at 10:15
  • It is compiling. But during execution i am getting Nill interface exception. Here HttpEnable is the variable evaluated during install. – Anuk May 14 '14 at 10:25
  • *Nill interface* doesn't seem to be verbose error message you got. But the problem in your code is at least with the XPath and the used namespace in your XML. Due to no feedback and missing crucial information I'm voting to close your question. – TLama May 20 '14 at 07:18

0 Answers0