Python 我如何在zeep中使用wsdl的每个方法发送头?
我不太会用zeep。并尝试实现wsdl: 我必须发送如下请求:Python 我如何在zeep中使用wsdl的每个方法发送头?,python,python-3.x,header,wsdl,zeep,Python,Python 3.x,Header,Wsdl,Zeep,我不太会用zeep。并尝试实现wsdl: 我必须发送如下请求: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <Search xmlns="http://tempuri.org/"> <Header> <AgentId>agentid</AgentId> <Pas
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Search xmlns="http://tempuri.org/">
<Header>
<AgentId>agentid</AgentId>
<Password>password</Password>
<Username>username</Username>
</Header>
<Search>
<CheckIn>2017-06-10</CheckIn>
<CheckOut>2017-06-12</CheckOut>
<CityId>4339</CityId>
<CurrencyId>2</CurrencyId>
<HotelId>122079</HotelId>
<PaxCountryId>2</PaxCountryId>
<DefaultPhotoInclude>false</DefaultPhotoInclude>
<GeoCoordinatesInclude>false</GeoCoordinatesInclude>
<HotelAddressInclude>false</HotelAddressInclude>
<HotelDescriptionInclude>false</HotelDescriptionInclude>
<HotelNameInclude>true</HotelNameInclude>
<MaxResponseTime>0</MaxResponseTime>
<SearchRooms>
<SearchRoom>
<Adult>1</Adult>
<Child1Age>0</Child1Age>
<Child2Age>0</Child2Age>
<Child3Age>0</Child3Age>
<Quantity>1</Quantity>
</SearchRoom>
</SearchRooms>
</Search>
</Search>
</s:Body>
</s:Envelope>
阿根蒂德
密码
用户名
2017-06-10
2017-06-12
4339
2.
122079
2.
假的
假的
假的
假的
真的
0
1.
0
0
0
1.
当我想使用此wsdl的每个方法时,我应该发送头。
你能帮我吗 既然谷歌引领我来到这里,我将发布我的发现 为了在客户机进行的每次调用中发送相同的SOAP头,我做了以下操作,为一般消费使用了一些愚蠢的替换:
from zeep import Client, xsd
client = Client(
wsdl_url,
transport=transport,
)
header = xsd.ComplexType(
xsd.Sequence([
xsd.Element('SomeString', xsd.String()),
xsd.Element('SomeBoolean', xsd.Boolean()),
])
)
headers = [ header(SomeString='Hello', SomeBoolean=True) ]
client.set_default_soapheaders(headers)
client.service.MakeTheMagic(Stuff=stuff)
你想做什么还不清楚。我想用pythonDid实现一个wsdl。你想试试吗?显示您正在处理的一些代码。使用zeep中的插件可以在每个请求中发送头。见文件