我需要从 bash shell 中调用 icCube 的管理 API。发送 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>
最重要的是,如何处理基本身份验证(用户/密码)?
文档中提供了 Perl 示例:http://www.iccube.com/support/documentation/user_guide/using/cube_management.php(在文档末尾)。
使用“--user”参数处理 Curl 基本身份验证
重击示例:
#!/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
Note:确保结束 EOF 后没有任何空格,否则 API 将返回 SOAP 语法错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)