dsfsda121545 2019-05-24 12:14
浏览 227

通过python zeep通过适当的身份验证调用BMC Remedy SOAP WSDL

I have been given a task to make call to SOAP WSDL data for BMC Remedy in Python. I only have PHP code snippet for reference.

I have below issues, 1: I do not know the exact format of passing data in the New_GetList_Operation_0 method via Python as well as manually(say via SOAP UI) as I only dealth with json REST APIs before 2: I tried below python code just randomly, but I am getting below error: ARERR [149] A user name must be supplied in the control record

Request to assist on above 2 concerns.

PHP Code:

public function getRemedyData($params) {
    $client     = new SoapClient($this->_Wsdl, $this->soapOptions);
    $authvalues = new SoapVar($this->_bmcAuth, SOAP_ENC_OBJECT);
    $header     = new SoapHeader("New_GetList_Operation_0", "AuthenticationInfo", $authvalues, false);
    $client->__setSoapHeaders(array($header));
    try {
        $result                = $client->__soapCall("New_GetList_Operation_0", array($params));
        $resultArray           = array('code' => "0", 'message' => "successful");
        $resultArray["result"] = $result;
    } catch (Exception $e) {
        $errMsg = $e->getMessage();

        $resultArray = array('code' => "1", 'message' => $errMsg);
    }
    return $resultArray;
}

$params = array(
    'Qualification' => '\'Modified Date\' >= "' . $dateTimeValue . '" and \'Categorization Tier 2\' = "<<xx Scan>>" and \'Submitter\' = "validusername"'
);
$result = $this->Remedy->getRemedyData($params);

Python Code:

import zeep
from zeep.wsse.username import UsernameToken
from requests import Session
from requests.auth import HTTPBasicAuth  # or HTTPDigestAuth, or OAuth1, etc.
from zeep import Client
session = Session()
session.auth = HTTPBasicAuth('<<valid_username>>', '<<valid_password>>')
client = Client("url:8080/arsys/WSDL/public/xx/xx:xx:QueryWebService",
                wsse = UsernameToken('<<valid_username>>', '<<valid_password>>'))
header = zeep.xsd.Element(
    'Security',
    zeep.xsd.ComplexType([
        zeep.xsd.Element(
            'UsernameToken',
            zeep.xsd.ComplexType([
                zeep.xsd.Element('Username',zeep.xsd.String()),
                zeep.xsd.Element('Password',zeep.xsd.String()),
            ])
        ),
    ])
)
header_value = header(UsernameToken={'Username': '<<valid_username>>', 'Password': '<<valid_password>>'})
with client.settings(raw_response=True):
    response = client.service.New_GetList_Operation_0(
        _soapheaders=[header_value],
        Qualification='\'Modified Date\' >= "05/14/2017" and \'Categorization Tier 2\' = "<<xx Scan>>" and \'Submitter\' = "<<valid_username>>"'
    )
print(response.content)
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
    • ¥15 vs2019中数据导出问题
    • ¥20 云服务Linux系统TCP-MSS值修改?
    • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
    • ¥20 怎么在stm32门禁成品上增加查询记录功能
    • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
    • ¥50 NT4.0系统 STOP:0X0000007B
    • ¥15 想问一下stata17中这段代码哪里有问题呀
    • ¥15 flink cdc无法实时同步mysql数据
    • ¥100 有人会搭建GPT-J-6B框架吗?有偿