Sitescope

De Mon Wiki
Aller à la navigation Aller à la recherche

Obtenir tout le contenu d'un Sitescope

Creer un fichier xml avec le contenu ci-dessous (Modifier les champs username, password, path_to_sitescope avec vos valeurs) :

<?xml version="1.0" encoding="UTF-8"?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <soapenv:Body>
                        <ns1:search soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://configuration.api.sitescope.mercury.com">
                                <in0 href="#id0"/>
                                <in1 xsi:type="xsd:int">100000</in1>
                                <in2 xsi:type="xsd:string">username</in2>
                                <in3 xsi:type="xsd:string">password</in3>
                                <in4 xsi:type="xsd:string">CMD</in4>
                        </ns1:search>
                        <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Map" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://xml.apache.org/xml-soap">
                                <item>
                                        <key xsi:type="soapenc:string">path</key>
                                        <value xsi:type="soapenc:string">path_to_sitescope</value>
                                </item>
                        </multiRef>
                </soapenv:Body>
        </soapenv:Envelope>

Executez la commande curl suivante (remplacez URL_SITESCOPE, FILE_XML et FILE_RESULT par vos valeurs) :

URL_SITESCOPE="https://localhost:8443"
FILE_XML="/chemin/vers/file.xml"
FILE_RESULT="/chemin/vers/file_resultat.txt"
curl -L -k -m 30 --retry 2 --retry-delay 30 --retry-max-time 120 -sL -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction: ${URL_SITESCOPE}/SiteScope/services/APIConfigurationImpl" -d @${FILE_XML} -X POST ${URL_SITESCOPE}/SiteScope/services/APIConfigurationImpl -o ${FILE_RESULT}

Pour mettre en forme le resultat recu :

awk 'BEGIN{RS = "<"} {if($0 ~ "^key") {key=gensub(".+?>(.+)","\\1",$0); gsub("_sis_path_delimiter_","\\", key); printf "%s\n", key}}' ${FILE_RESULT}