Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Netsuite命名空间问题_Python_Web Services_Netsuite - Fatal编程技术网

Python Netsuite命名空间问题

Python Netsuite命名空间问题,python,web-services,netsuite,Python,Web Services,Netsuite,我目前正在使用python和NetSuite Web服务进行一个附带项目。我已经成功发送了数据中心请求。我使用元素树导入来解析xml请求和响应。无论我试图抓取下面的一个URL,我最终都没有得到任何值,我假设这与我非常讨厌的名称间距有关 <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs

我目前正在使用python和NetSuite Web服务进行一个附带项目。我已经成功发送了数据中心请求。我使用元素树导入来解析xml请求和响应。无论我试图抓取下面的一个URL,我最终都没有得到任何值,我假设这与我非常讨厌的名称间距有关

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2016_1.platform.webservices.netsuite.com">
            <platformMsgs:nsId>WEBSERVICES__XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</platformMsgs:nsId>
        </platformMsgs:documentInfo>
    </soapenv:Header>
    <soapenv:Body>
        <getDataCenterUrlsResponse xmlns="">
            <platformCore:getDataCenterUrlsResult xmlns:platformCore="urn:core_2016_1.platform.webservices.netsuite.com">
                <platformCore:status isSuccess="true" />
                <platformCore:dataCenterUrls>
                    <platformCore:restDomain>https://rest.na1.netsuite.com</platformCore:restDomain>
                    <platformCore:webservicesDomain>https://webservices.na1.netsuite.com</platformCore:webservicesDomain>
                    <platformCore:systemDomain>https://system.na1.netsuite.com</platformCore:systemDomain>
                </platformCore:dataCenterUrls>
            </platformCore:getDataCenterUrlsResult>
        </getDataCenterUrlsResponse>
    </soapenv:Body>
</soapenv:Envelope>

import xml.etree.ElementTree as ET
ns = {'platformCore': 'urn:messages_2016_1.platform.webservices.netsuite.com'}
xml.find('platformCore:webservicesDomain', ns)

Web服务\uuuuxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://rest.na1.netsuite.com
https://webservices.na1.netsuite.com
https://system.na1.netsuite.com
将xml.etree.ElementTree作为ET导入
ns={'platformCore':'urn:messages_2016_1.platform.webservices.netsuite.com'}
find('platformCore:webservicesDomain',ns)
无论选择器或名称空间如何,xml.find()都只返回空值。如果有人能告诉我正确的方法是什么,这样我就能从这些回复中获得这个url和其他数据,我将不胜感激


如果你想知道为什么我这么辛苦,而不是使用客户机或更好的工具。我正在尝试在sublime text 3中嵌入一些Web服务功能,它使用特定版本的python 3(3.3.6),这使得导入库不是不可能,而是一件麻烦事。

看起来您可能应该尝试:

xml.find('{urn:messages_2016_1.platform.webservices.netsuite.com}webservicesDomain')


对不起,我最近太忙了。我试试看它是否管用
ns = {'nsp': 'urn:messages_2016_1.platform.webservices.netsuite.com'}
xml.find('nsp:webservicesDomain', ns)