如何使用泡沫添加新对象?
我正在尝试使用泡沫,但到目前为止还没有成功地解决这个问题。
这应该是我需要实现的原始肥皂消息:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:api="http://api.service.apimember.soapservice.com/">
<soapenv:Header/>
<soapenv:Body>
<api:insertOrUpdateMemberByObj>
<token>t67GFCygjhkjyUy8y9hkjhlkjhuii</token>
<member>
<dynContent>
<entry>
<key>FIRSTNAME</key>
<value>hhhhbbbbb</value>
</entry>
</dynContent>
<email>[email protected]</email>
</member>
</api:insertOrUpdateMemberByObj>
</soapenv:Body>
</soapenv:Envelope>
所以我使用 suds 来创建成员对象:
member = client.factory.create('member')
产生:
(apiMember){
attributes =
(attributes){
entry[] = <empty>
}
}
如何准确地附加一个“条目”?
我尝试了这个:
member.attributes.entry.append({'key':'FIRSTNAME','value':'test'})
它产生this:
(apiMember){
attributes =
(attributes){
entry[] =
{
value = "test"
key = "FIRSTNAME"
},
}
}
但是,我真正需要的是:
(apiMember){
attributes =
(attributes){
entry[] =
(entry) {
value = "test"
key = "FIRSTNAME"
},
}
}
我如何实现这一点?
I'm trying to use suds but have so far been unsuccessful at figuring this out.
This is supposed to be the raw soap message that I need to achieve:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:api="http://api.service.apimember.soapservice.com/">
<soapenv:Header/>
<soapenv:Body>
<api:insertOrUpdateMemberByObj>
<token>t67GFCygjhkjyUy8y9hkjhlkjhuii</token>
<member>
<dynContent>
<entry>
<key>FIRSTNAME</key>
<value>hhhhbbbbb</value>
</entry>
</dynContent>
<email>[email protected]</email>
</member>
</api:insertOrUpdateMemberByObj>
</soapenv:Body>
</soapenv:Envelope>
So I use suds to create the member object:
member = client.factory.create('member')
produces:
(apiMember){
attributes =
(attributes){
entry[] = <empty>
}
}
How exactly do I append an 'entry'?
I tried this:
member.attributes.entry.append({'key':'FIRSTNAME','value':'test'})
which produces this:
(apiMember){
attributes =
(attributes){
entry[] =
{
value = "test"
key = "FIRSTNAME"
},
}
}
However, what I actually need is:
(apiMember){
attributes =
(attributes){
entry[] =
(entry) {
value = "test"
key = "FIRSTNAME"
},
}
}
How do I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您仍然需要使用工厂创建对象:
you still need to create object with factory:
。
这确实取决于定义 SOAP 连接的 WSDL,但
attributes
也应该是 WSDL 中定义的结构Off the top of my head (all the suds stuff is at work at the moment)
This does depend on the WSDL that defines your SOAP connection, but
attributes
should also be a structure defined in the WSDL.这就是当我尝试创建“条目”时发生的情况:
This is what happens when i try to create "entry":
试试这个,使用我的 WSDL 可以实现类似的效果。
正如 simon 所说,这确实取决于您的 WSDL。
Try this, a similar thing worked using my WSDL.
As simon said, it does depend on your WSDL.