exhuma.twn wrote: > Hi, > > TGWebservices is looking great. Thanks Kevin :) > Now, I tried to consume an exposed web-service using ZSI. But it > complains about the content-type not being text/xml. Is it not > possible to return the same result with a text/xml as content-type to > make ZSI happy? > > Code and results: > > ==== Producer code ==== > > class SimpleEvent_t(object): > name = str > id = int > types = [int] > def __init__(self, evt): > self.id = evt.idEvent > self.types = [x.idEventType for x in evt.types] > self.name = evt.name > > class WsRoot(WebServicesRoot): > > @wsexpose(SimpleEvent_t) > @wsvalidate(int) > def getEventList(self, loc): > "test" > print "geteventlist called with", loc > from model import Event, EventType > events = Event.select() > return [ SimpleEvent_t(x) for x in events ] > > ==== Consumer Code ==== > from ZSI.client import NamedParamBinding as NPBinding > > b = NPBinding(url='http://192.168.1.2:8080/wsevent/soap/', > tracefile=open('pyws.log', 'w')) > x = b.getEventList( loc=1 ) > print x > > ==== STDErr ==== > Traceback (most recent call last): > File "wstest.py", line 6, in ? > x = b.getEventList( loc=1 ) > File "/usr/lib/python2.4/site-packages/ZSI-2.0.dev_r1240-py2.4.egg/ > ZSI/client.py", line 68, in __call__ > File "/usr/lib/python2.4/site-packages/ZSI-2.0.dev_r1240-py2.4.egg/ > ZSI/client.py", line 175, in RPC > File "/usr/lib/python2.4/site-packages/ZSI-2.0.dev_r1240-py2.4.egg/ > ZSI/client.py", line 414, in Receive > File "/usr/lib/python2.4/site-packages/ZSI-2.0.dev_r1240-py2.4.egg/ > ZSI/client.py", line 377, in ReceiveSOAP > TypeError: Response is "application/soap+xml", not "text/xml" > > > ==== Trace file ==== > _________________________________ Sat Jun 9 11:42:58 2007 REQUEST: > <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/ > encoding/" > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> > <SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><getEventList><loc > id="o631568" > xsi:type="xsd:int">1</loc></getEventList></SOAP-ENV:Body></SOAP- > ENV:Envelope> > _________________________________ Sat Jun 9 11:43:01 2007 RESPONSE: > 200 > OK > ------- > Date: Sat, 09 Jun 2007 09:42:58 GMT > > Server: CherryPy/2.2.1 > > Content-Length: 102712 > > Content-Type: application/soap+xml;charset=utf-8 > > Set-Cookie: session_id=159fda04f0805ad859734224462521c27bd0bfb0; > expires=Sat, 09-Jun-2007 10:42:58 GMT; Path=/; > > Set-Cookie: tg-visit=2c39df1e5274d259d21d39d0d1eba0094a02f78c; Path=/; > > Connection: close > > > <soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://192.168.1.2:8080/wsevent/soap/types"> > <soapenv:Body> > <getEventListResponse><result xsi:type="SimpleEvent_t"> > <item xsi:type="SimpleEvent_t"><id xsi:type="xsd:int">1</ > id> > <name xsi:type="xsd:string">Summerbiking</name><types > xsi:type="Int_Array"><item > xsi:type="xsd:string">1</item></types></item> > [...snip...] > </result></getEventListResponse> > </soapenv:Body> > </soapenv:Envelope>
IIRC the following network capture shows that ZSI tells the server that it "accepts" text/xml. Shouldn't TGWebservices honour that? Just a thought ;) 0040 e4 a6 50 4f 53 54 20 2f 77 73 65 76 65 6e 74 2f ..POST / wsevent/ 0050 73 6f 61 70 2f 20 48 54 54 50 2f 31 2e 31 0d 0a soap/ HTTP/ 1.1.. 0060 48 6f 73 74 3a 20 31 39 32 2e 31 36 38 2e 31 2e Host: 192.168.1. 0070 32 3a 38 30 38 30 0d 0a 41 63 63 65 70 74 2d 45 2:8080..Accept- E 0080 6e 63 6f 64 69 6e 67 3a 20 69 64 65 6e 74 69 74 ncoding: identit 0090 79 0d 0a 43 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 y..Content- lengt 00a0 68 3a 20 35 31 30 0d 0a 43 6f 6e 74 65 6e 74 2d h: 510..Content- 00b0 74 79 70 65 3a 20 74 65 78 74 2f 78 6d 6c 3b 20 type: text/ xml; 00c0 63 68 61 72 73 65 74 3d 75 74 66 2d 38 0d 0a 53 charset=utf-8..S 00d0 4f 41 50 41 63 74 69 6f 6e 3a 20 22 22 0d 0a 0d OAPAction: ""... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

