2015-10-16 62 views
1

我需要使用bash shell從icCube調用管理API。發送SOAP命令最簡單的方法是什麼:來自bash shell的XMLA/SOAP命令

<?xml version="1.0" encoding="UTF-8"?> 
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <Execute xmlns="urn:schemas-microsoft-com:xml-analysis"> 
     <Command> 
      <Statement xsi:type="xsd:string">'"$command"'</Statement> 
     </Command> 
     </Execute> 
    </soap:Body> 
    </soap:Envelope> 

最後,如何處理基本身份驗證(user/pwd)?

回答

1

Perl樣本可在文檔中找到:http://www.iccube.com/support/documentation/user_guide/using/cube_management.php(在文檔末尾)。使用「--user」的說法

捲曲基本身份驗證處理

猛砸樣本:

#!/bin/bash 

    URL="http://localhost:8282/icCube/xmla" 
    COMMAND="LIST_SCHEMA" 

    echo ${COMMAND} 

    curl --header "Content-Type: text/xml;charset=UTF-8" \ 
    --header "SOAPAction:urn:schemas-microsoft-com:xml-analysis#Execute" \ 
    --user admin:admin --data @- ${URL} <<EOF 
    <?xml version="1.0" encoding="UTF-8"?> 
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
     <soap:Body> 
    <Execute xmlns="urn:schemas-microsoft-com:xml-analysis"> 
     <Command> 
      <Statement xsi:type="xsd:string">${COMMAND}</Statement> 
     </Command> 
    </Execute> 
     </soap:Body> 
    </soap:Envelope> 
    EOF 

注:確保沒有收EOF之後的任何空白或API將返回一個SOAP語法錯誤。