来自bash shell的XMLA/SOAP命令 [英] XMLA/SOAP command from a bash shell

查看:91
本文介绍了来自bash shell的XMLA/SOAP命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从bash shell中调用icCube的管理API.发送SOAP命令的最简单方法是什么:

I need to call the management API from icCube from withing a bash shell. What is the easiest way for sending a SOAP command like :

    <?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)?

On top, how to handle Basic Authentication ( user / pwd ) ?

推荐答案

Perl示例可在文档中找到: http://www.iccube.com/support/documentation/user_guide/using/cube_management.php (在文档末尾).

Perl sample available in documentation : http://www.iccube.com/support/documentation/user_guide/using/cube_management.php (in the end of document).

使用'--user'参数处理卷毛基本身份验证

Curl basic auth handled using '--user' argument

重击示例:

  #!/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语法错误.

Note: Make sure there isn't any whitespace after the closing EOF or the API will return a SOAP syntax error.

这篇关于来自bash shell的XMLA/SOAP命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆