[Tutor] soappy, soap, xml ..fuss

Ismar Sehic i.sheeha at gmail.com
Tue Oct 1 10:08:00 CEST 2013


hello, it's me again with my stubborn soap and xml request.please take a
look at this code and the output, just tell if i'm missing something - i
don't get it.

 ---- > code

> '''
> Created on 30.09.2013
>
> @author: i.sehic
> '''
> import SOAPpy
> from xml.etree.ElementTree import Element, SubElement, tostring
> import pprint
>
> class HotelbedsRequests():
>
>     def __init__(self):
>         self.wsdlFile = 'http://testapi.interface-xml.com/appservices
> /ws/FrontendService?wsdl'
>         self.server = SOAPpy.WSDL.Proxy(self.wsdlFile)
>
>     def sendPriceRequest(self, adults, children_, hotel = "", room = "",
> board = ""):
>
>         header = """<?xml version="1.0" encoding="UTF-8"?>"""
>
>         root = Element('soapenv:Envelope', {"soapenv:encodingStyle":"
> http://schemas.xmlsoap.org/soap/encoding/", "xmlns:soapenv":"
> http://schemas.xmlsoap.org/soap/envelope/", "xmlns:xsi":"
> http://www.w3.org/2001/XMLSchema-instance" })
>         body = SubElement(root, "soapenv:Body")
>         getrequest = SubElement(body, "hb:getHotelValuedAvail",
> {"xmlns:hb":"http://axis.frontend.hydra.hotelbeds.com",
> "xsi:type":"xsd:string"})
>         getavailrp = SubElement(getrequest, "HotelValuedAvailRQ",
> {"echoToken":"DummyEchoToken", "sessionId":"DummySessionId", "xmlns":"
> http://www.hotelbeds.com/schemas/2005/06/messages", "xmlns:xsi":"
> http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation":"
> http://www.hotelbeds.com/schemas/2005/06/messagesHotelValuedAvailRQ.xsd"})
>         language = SubElement(getavailrp, "Language")
>         language.text = "ENG"
>         credentials = SubElement(getavailrp, "Credentials")
>         user = SubElement(credentials, "User")
>         user.text = "xxxxxxxxxxxx"
>         pw = SubElement(credentials, "Password")
>         pw.text = "xxxxxxxxxxxx"
>         paginationdata = SubElement(getavailrp, "PaginationData",
> {"pageNumber":'1'})
>         checkin = SubElement(getavailrp, "CheckInDate",
> {"date":"20130814"})
>         checkout = SubElement(getavailrp, "CheckOutDate",
> {"date":"20130819"})
>         desti = SubElement(getavailrp, "Destination", {"code":"PMI",
> "type": "SIMPLE"})
>         occupancylist = SubElement(getavailrp, "OccupancyList")
>         occupancyhotel = SubElement(occupancylist, "HotelOccupancy")
>         roomcount = SubElement(occupancyhotel, "RoomCount")
>         roomcount.text = "1"
>         occu = SubElement(occupancyhotel, "Occupancy")
>         adult = SubElement(occu, "AdultCount")
>         adult.text = str(adults)
>         #adult.text = str(adult)
>         children = SubElement(occu, "ChildCount")
>         children.text = str(children_)
>         #children.text = str(children)
>
>
>         xmlstring = header + tostring(root)
>         pprint.pprint(xmlstring)
>
>
>         print self.server.methods.keys()
>
>         self.server.getHotelValuedAvail(xmlstring)
>         callInfo = self.server.methods['getHotelValuedAvail']
>
>         print callInfo.inparams
>         print callInfo.inparams[0].name
>         print callInfo.inparams[0].type
>
>         print callInfo.outparams
>         print callInfo.outparams[0].name
>         print callInfo.outparams[0].type
>
>
>     def readHotelPriceResponse(self):
>         pass
>
>
>
> HotelbedsRequests().sendPriceRequest(2, 1)
>

----->output:

/usr/lib/pymodules/python2.6/SOAPpy/wstools/XMLSchema.py:2871:
> DeprecationWarning: object.__init__() takes no parameters
>   tuple.__init__(self, args)
> '<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><hb:getHotelValuedAvail
> xmlns:hb="http://axis.frontend.hydra.hotelbeds.com"
> xsi:type="xsd:string"><HotelValuedAvailRQ echoToken="DummyEchoToken"
> sessionId="DummySessionId" xmlns="
> http://www.hotelbeds.com/schemas/2005/06/messages" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://www.hotelbeds.com/schemas/2005/06/messagesHotelValuedAvailRQ.xsd"><Language>ENG</Language><Credentials><User>xxxx</User><Password>xxxx</Password></Credentials><PaginationData
> pageNumber="1" /><CheckInDate date="20130814" /><CheckOutDate
> date="20130819" /><Destination code="PMI" type="SIMPLE"
> /><OccupancyList><HotelOccupancy><RoomCount>1</RoomCount><Occupancy><AdultCount>2</AdultCount><ChildCount>1</ChildCount></Occupancy></HotelOccupancy></OccupancyList></HotelValuedAvailRQ></hb:getHotelValuedAvail></soapenv:Body></soapenv:Envelope>'
> [u'purchaseConfirm', u'getHotelCategoryList', u'getZoneGroupList',
> u'getPurchaseList', u'getHotelRoomTypeGroupList', u'purchaseCancel',
> u'getTicketValuation', u'getCountryList', u'getHotelBoardGroupList',
> u'getPurchaseDetail', u'serviceAdd', u'getHotelDetail',
> u'cancelProtectionAdd', u'getIncomingOfficeList', u'purchaseFlush',
> u'getTicketCountryList', u'getCarCountryList', u'cancelProtectionRemove',
> u'getCarValuedAvail', u'getTicketDetail', u'getCancelProtectionAvail',
> u'serviceRemove', u'getCarInfoSet', u'getIncomingOfficeDetail',
> u'getHotelBoardList', u'getDestinationGroupList',
> u'getHotelCategoryGroupList', u'getHotelList', u'getTransferValuedAvail',
> u'getHotelValuedAvail', u'getTicketAvail', u'getTicketClassificationList',
> u'getTransferCountryList', u'getHotelCountryList']
> Traceback (most recent call last):
>   File "soappy.py", line 71, in <module>
>     HotelbedsRequests().sendPriceRequest(2, 1)
>   File "soappy.py", line 54, in sendPriceRequest
>     self.server.getHotelValuedAvail(xmlstring)
>   File "/usr/lib/pymodules/python2.6/SOAPpy/Client.py", line 470, in
> __call__
>     return self.__r_call(*args, **kw)
>   File "/usr/lib/pymodules/python2.6/SOAPpy/Client.py", line 492, in
> __r_call
>     self.__hd, self.__ma)
>   File "/usr/lib/pymodules/python2.6/SOAPpy/Client.py", line 363, in __call
>     config = self.config)
>   File "/usr/lib/pymodules/python2.6/SOAPpy/Client.py", line 187, in call
>     r.endheaders()
>   File "/usr/lib/python2.6/httplib.py", line 904, in endheaders
>     self._send_output()
>   File "/usr/lib/python2.6/httplib.py", line 776, in _send_output
>     self.send(msg)
>   File "/usr/lib/python2.6/httplib.py", line 735, in send
>     self.connect()
>   File "/usr/lib/python2.6/httplib.py", line 716, in connect
>     self.timeout)
>   File "/usr/lib/python2.6/socket.py", line 514, in create_connection
>     raise error, msg
> socket.error: [Errno 110] Connection timed out
>

what could cause this socket error?and what is this Deprecation Warning?i
don't get it anymore, i tried all the possible ways - with simple http
request i get an internal server error [500].i wrote an email to the people
at hotelbeds services 7 days ago, still waiting for the reply.how do i make
this API, i cannot get simple xml request through.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131001/8fb8c4d6/attachment-0001.html>


More information about the Tutor mailing list