Comments (6)
Just a quick initial guess: The value is an anyType, can you use the following: http://docs.python-zeep.org/en/latest/#any-objects (that is wrap the value in an xsd.anyObject)
from python-zeep.
I changed the code so that I use the AnyObject class, but still does not convert it to the correct values:
new_value_type = edp.get_type("{http://ws.polarion.com/types}Text")
any_val = xsd.AnyObject(new_value_type, new_value_type(type = "text/html", content="This is a first Test", contentLossy=False))
new_solution_type = edp.get_type("{http://ws.polarion.com/TrackerWebService-types}CustomField")
sol = new_solution_type(key="solution", parentItemURI=uri, value=any_val)
edp.service.setCustomField(sol)
The send packet looks like this:
<ns0:setCustomField>
<ns0:customField>
<ns2:parentItemURI>subterra:data-service:objects:/default/sw_team_linux${WorkItem}SWTLI-664</ns2:parentItemURI>
<ns2:key>solution</ns2:key>
<ns2:value><zeep.xsd.types.AnyObject object at 0x7f995e4f89b0></ns2:value>
</ns0:customField>
</ns0:setCustomField>
from python-zeep.
So the issue was that I used xsd.String() as default type for elements while it should have been anyType (ur-type). Can you give the master branch a try?
This seems to generate valid xml:
import zeep
from lxml import etree
from zeep import xsd
client = zeep.Client('http://almdemo.polarion.com/polarion/ws/services/TrackerWebService?wsdl')
new_value_type = client.get_type("{http://ws.polarion.com/types}Text")
value = xsd.AnyObject(
new_value_type,
new_value_type(type="text/html", content="This is a first Test", contentLossy=False))
new_solution_type = client.get_type("{http://ws.polarion.com/TrackerWebService-types}CustomField")
sol = new_solution_type(
key='solution',
parentItemURI='subterra:data-service:objects:/default/sw${WorkItem}LI-66',
value=value)
# Dump the message which would be created
node = client.service._binding.create_message('setCustomField', sol)
print(etree.tostring(node, pretty_print=True))
from python-zeep.
I tried the master branch, but it gives me an error:
File "/usr/lib/python3/dist-packages/zeep/wsdl/definitions.py", line 224, in create
return self.input.serialize(_args, *_kwargs)
File "/usr/lib/python3/dist-packages/zeep/wsdl/messages.py", line 70, in serialize
self.body.render(body, body_value)
File "/usr/lib/python3/dist-packages/zeep/xsd/elements.py", line 99, in render
return self.type.render(node, value)
File "/usr/lib/python3/dist-packages/zeep/xsd/types.py", line 130, in render
element.render(parent, sub_value)
File "/usr/lib/python3/dist-packages/zeep/xsd/elements.py", line 99, in render
return self.type.render(node, value)
File "/usr/lib/python3/dist-packages/zeep/xsd/types.py", line 130, in render
element.render(parent, sub_value)
File "/usr/lib/python3/dist-packages/zeep/xsd/elements.py", line 99, in render
return self.type.render(node, value)
File "/usr/lib/python3/dist-packages/zeep/xsd/builtins.py", line 444, in render
parent.text = self.xmlvalue(value)
File "src/lxml/lxml.etree.pyx", line 1031, in lxml.etree._Element.text.set (src/lxml/lxml.etree.c:55347)
File "src/lxml/apihelpers.pxi", line 711, in lxml.etree._setNodeText (src/lxml/lxml.etree.c:24667)
File "src/lxml/apihelpers.pxi", line 699, in lxml.etree._createTextNode (src/lxml/lxml.etree.c:24516)
File "src/lxml/apihelpers.pxi", line 1437, in lxml.etree._utf8 (src/lxml/lxml.etree.c:32414)
TypeError: Argument must be bytes or unicode, got 'Text'
from python-zeep.
Did you wrap the Text type in an AnyObject() like in my code snippet?
Error message should be more helpful nonetheless :-)
from python-zeep.
Arg, sorry, no, I didn't. I thought I didn't change my code.
Wrapping it with AnyObject fixes this. Thanks!
Is this somehow related to #17 ?
from python-zeep.
Related Issues (20)
- DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 HOT 8
- RuntimeWarning: Running interpreter doesn't sufficiently support code object introspection
- Wrongs Namespace
- while requestHeader method generates header based on operation name soaptype returns request header
- passing a composite element to a service operation HOT 1
- does it support multiple return values? HOT 1
- Access to HTTP request? HOT 1
- NS0
- [4.2.1] Validation Error Exception
- Cloudflare and <soap:Header>
- Zeep fails to parse `24:00:00` as `xsd:time` (ValueError: hour must be in 0..23) HOT 2
- Add a network pytest mark for tests that use the network
- httpx: DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content.
- Input message with multi parts
- Client only parses xsd type extensions one level
- AsyncClient has a blocking constructor
- Zeep fails trying to instantiate a client in python3.12 HOT 3
- Zeep parser produces dictionary keys that don't exist in raw XML
- Some XML elements do not have attributes (inconsistently)
- Getting 404 on loading https://schemas.xmlsoap.org/soap/encoding/ HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-zeep.