2015-10-16 52 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语法错误。