标签: suds

我如何使用python的sharepoint(通过soap?)?

我想用python(C-Python)使用Sharepoint

有人曾尝试过这个吗?

python sharepoint soap ntlm suds

9
推荐指数
2
解决办法
1万
查看次数

如何使用Python Suds(版本0.3.6)导入XSD架构SOAP库:TypeNotFound异常?

我正在尝试使用带有Python Suds的SABRE旅行网络服务,但是一个XSD似乎没有格式良好(可能在此模式中缺少名称空间).


from suds.client import Client
wsdl = 'http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl'
client = Client(wsdl, cache=None)
Run Code Online (Sandbox Code Playgroud)

调试跟踪返回:


.DEBUG:suds.wsdl:reading wsdl at: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl ...
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl) duration: 406 (ms)
DEBUG:suds.xsd.sxbasic:Import:0x7f90196fd5f0, importing ns="http://webservices.sabre.com/sabreXML/2003/07", location="OTA_AirPriceLLSRQRS.xsd"
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQRS.xsd)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQRS.xsd) duration: 504 (ms)
DEBUG:suds.xsd.sxbasic:Include:0x7f90196fdf80, importing ns="None", location="OTA_AirPriceLLSRQ.xsd"
DEBUG:suds.transport.http:opening (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd)
DEBUG:suds.metrics:sax (http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.xsd) duration: 1.363 (seconds)
DEBUG:suds.xsd.schema:built:
Schema:0x7f9019708e60
(...)
DEBUG:suds.xsd.query:(u'MessageHeader', http://www.ebxml.org/namespaces/messageHeader), found as: 
DEBUG:suds.xsd.query:(u'Security', http://schemas.xmlsoap.org/ws/2002/12/secext), found as: 
DEBUG:suds.xsd.query:(u'OTA_AirPriceRQ', http://webservices.sabre.com/sabreXML/2003/07), not-found
.
----------------------------------------------------------------------
Ran 2 tests in 11.669s

Type not found: '(OTA_AirPriceRQ, http://webservices.sabre.com/sabreXML/2003/07, )'
Run Code Online (Sandbox Code Playgroud)

这是逻辑:Python Suds在"无"命名空间中加载OTA_AirPriceRQ.我读了"修复破坏的模式"Python Suds文档(https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs): …

python soap wsdl suds

9
推荐指数
1
解决办法
9036
查看次数

如何在python中使用suds转储我的请求的原始XML和服务器的响应

我正在使用suds 0.4和python 2.6来与远程服务器通信.

它的WSDL加载完美,但任何函数调用都会返回错误.该服务器出了点问题.

现在我需要获得一个肥皂结构的转储,它被发送到服务器,它的响应,在纯肥皂.

我怎样才能做到这一点?

python soap suds

9
推荐指数
1
解决办法
7540
查看次数

Python SOAP客户端,使用suds的WSDL调用为HTTP基本身份验证提供了传输错误401未授权

背景

我正在使用python 2.7.3构建一个SOAP客户端,并使用Canonical提供的suds 0.4.1库.服务器正在使用HTTPS进行基本身份验证.

问题

无法在服务器上传递身份验证,甚至无法获取WSDL.我收到以下错误:

suds.transport.TransportError:HTTP错误401:未经授权

尝试解决方案和代码

我已经尝试了suds文档中描述的两种身份验证方法,但仍然client = Client(url, ...)在行上面得到了错误.我已经确认了在Web浏览器中连接的凭据和功能,这很好.

声明之后wsdl_url,usernamepassword,我想:

client = Client(url=wsdl_url, username=username, password=password)

# as well as:

t = HttpAuthenticated(username=username, password=password)
client = Client(url=wsdl_url, transport=t)

# and even:

t = HttpAuthenticated(username=username, password=password)
t.handler = urllib2.HTTPBasicAuthHandler(t.pm)
t.urlopener = urllib2.build_opener(t.handler)
client = Client(url=wsdl_url, transport=t)
Run Code Online (Sandbox Code Playgroud)

最后一个似乎至少在另一个关于使用suds进行HTTP身份验证的问题中从WSDL URL获得响应.

其他说明

这个问题与这个类似的问题截然不同,因为我正在使用:

from suds.transport.https import HttpAuthenticated
# not:
# from suds.transport.http import HttpAuthenticated
Run Code Online (Sandbox Code Playgroud)

从Traceback中,这个client = Client(url, …

python soap wsdl suds basic-authentication

9
推荐指数
1
解决办法
2万
查看次数

Python:用suds发出请求

我正在测试SUDS库,我正在尝试向端点发出一个简单的请求,但我得到了不寻常的输出.为什么?

from suds.client import Client
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)

url = "http://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway"

client = Client(url)
print client
Run Code Online (Sandbox Code Playgroud)

输出:

Martynass-MacBook-Air:CH martynas$ python ch.py
DEBUG:suds.xsd.schema:loaded:

schema collection
   Schema:0x109a7db90
   (raw)
      <schema/>
   (model)

DEBUG:suds.xsd.schema:MERGED:
Schema:0x109a7db90
(raw)
   <schema/>
(model)
Run Code Online (Sandbox Code Playgroud)

python soap suds

9
推荐指数
1
解决办法
1万
查看次数

通过SUDS发送xml

我想使用WSDL通过SUDS发送我的hand build xml.我发现,我可以这样做:

xml = Raw("""
<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <myData>
                something
            </myData>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>
    """)

print client.service.GetAccountBalance(xml)
Run Code Online (Sandbox Code Playgroud)

但是使用这种方法SUDS发送:

<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetAccountBalance>
         <ns0:Document>
            <myData>
                something
            </myData>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>
</ns0:Document>
      </ns0:GetAccountBalance>
   </ns1:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何在不添加任何SUDS的情况下发送我的XML?

python web-services suds

9
推荐指数
1
解决办法
4992
查看次数

我怎样才能泡泡沫?

为了避免在开发过程中反复访问SOAP服务器,我正在尝试缓存结果,这样我就可以运行其余的代码,而无需每次都查询服务器.

使用下面的代码,我得到一个PicklingError: Can't pickle <class suds.sudsobject.AdvertiserSearchResponse at 0x03424060>: it's not found as suds.sudsobject.AdvertiserSearchResponse当我尝试挑选肥皂水果的结果.我想这是因为这些类是动态创建的.

import pickle
from suds.client import Client

client = Client(...)
result = client.service.search(...)

file = open('test_pickle.dat', 'wb')
pickle.dump(result, file, -1)
file.close()
Run Code Online (Sandbox Code Playgroud)

如果我删除-1协议版本 pickle.dump(result, file, -1),我会得到一个不同的错误:

TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled
Run Code Online (Sandbox Code Playgroud)

酸洗是正确的吗?我可以让它运作吗?有没有更好的办法?

python soap pickle suds

8
推荐指数
1
解决办法
4196
查看次数

在运行时更改suds客户端的Web服务URL(保留wsdl)

首先,我的问题与类似

但它有点不同.我们拥有的是一系列具有相同服务的环境.对于某些环境(本地环境),我们可以访问wsdl,从而生成suds客户端.对于外部环境,我们无法访问wsdl.但同样,我希望我可以只更改URL而不重新生成客户端.我试过克隆客户端,但它不起作用.


编辑:添加代码:

    host='http://.../MyService.svc'
    wsdl_file = 'file://..../wsdl/MyService.wsdl'

    client = suds.client.Client(wsdl_file, location=host, cache=None)

    #client = baseclient.clone()

    #client.options.location = otherhost

    client.set_options(port='BasicHttpBinding_IMyService')

    result = client.service.IsHealthy()
Run Code Online (Sandbox Code Playgroud)

这给了我这个例外:

由于EndpointDispatcher上的ContractFilter不匹配,因此无法在接收方处理带有Action'http://tempuri.org/IMyService/IsHealthy ' 的消息.这可能是由于合同不匹配(发送方与接收方之间的操作不匹配)或发送方与接收方之间的绑定/安全性不匹配.检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无).

问题是,如果我将客户端直接设置为主机,它可以正常工作:client = suds.client.Client(host)

正如您所看到的,我已尝试克隆客户端,但具有相同的异常.我甚至试过这个:

    baseclient = suds.client.Client(host)

    client = baseclient.clone()

    client.options.location = otherhost
    ....
Run Code Online (Sandbox Code Playgroud)

并得到了同样的例外.

有人可以帮帮我吗?

python wsdl suds

8
推荐指数
2
解决办法
9485
查看次数

Python和suds - 如何获取有关方法参数类型的信息?

我使用suds从我的Python代码调用SOAP API中的方法.我试图以编程方式确定将哪些信息作为参数发送到API中的方法.我正在看的其中一个WSDL就在这里.

该WSDL中定义了一个具有以下签名的方法:

GetActiveDirectoryObjects(FilterOptions filterOptions)
Run Code Online (Sandbox Code Playgroud)

我可以使用suds为这个WSDL创建一个客户端,然后我可以使用client.factory.create()方法,如下所示:

from suds.client import Client
client = Client('https://controlpanel.msoutlookonline.net/WebServices/ActiveDirectory/ActiveDirectoryService.asmx?WSDL')
client.factory.create('FilterOptions')
Run Code Online (Sandbox Code Playgroud)

输出是:

(FilterOptions){
   AttributesToRead =
      (ArrayOfString){
         string[] = <empty>
      }
   SortBy = None
   SortDirection =
      (SortDirection){
         value = None
      }
   ResultSize = None
   Filter =
      (AndOperation){
         ExtensionData = None
      }
   SearchBase = None
 }
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚我是如何使用suds确定'SortBy'是否想要分配字符串或int或布尔值,或者是什么.我知道'AttributesToRead'想要被赋予'ArrayOfString'.我知道'SortDirection'想要被赋予一个'SortDirection'类型的对象.但是SearchBase怎么样?ResultSize?我的程序如何确定自动生成的表单是否应包含将验证int或布尔值或字符串的字段?

查看WSDL XML,我看到以下内容:

<s:complexType name="FilterOptions">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="AttributesToRead" type="tns:ArrayOfString"/>
        <s:element minOccurs="0" maxOccurs="1" name="SortBy" type="s:string"/>
        <s:element minOccurs="1" maxOccurs="1" name="SortDirection" type="tns:SortDirection"/>
        <s:element minOccurs="0" maxOccurs="1" name="ResultSize" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="Filter" type="tns:AndOperation"/> …
Run Code Online (Sandbox Code Playgroud)

python soap suds

8
推荐指数
0
解决办法
2426
查看次数

如何在"sudo 0.4.1 jurko 5"及更新版本中检查SUD产生/接收的内容?

这个问题类似于这个问题:

如何输出suds正在生成/接收的内容?

问题是我正在使用Jurko的suds fork并且在版本"0.4.1 jurko 5"之后Client.last_sent(),Client.last_received()方法已被删除.所以问题是我们如何在新的suds版本上替换它们的功能?

PS.我知道我可以降低调试级别,但我希望能够以编程方式检查输入/输出.

python soap suds

8
推荐指数
1
解决办法
1595
查看次数

标签 统计

python ×10

suds ×10

soap ×8

wsdl ×3

basic-authentication ×1

ntlm ×1

pickle ×1

sharepoint ×1

web-services ×1