From i.sheeha at gmail.com Fri Sep 20 16:02:47 2013 From: i.sheeha at gmail.com (Ismar Sehic) Date: Fri, 20 Sep 2013 14:02:47 -0000 Subject: [Soap-Python] lxml, suds help Message-ID: i'm probably very annoying and boring with these python web service :)and sorry for the previous message reply subject,wont happen again... the thing is, i'm provided with some service provider documentation, including xml request example, xml response example, wsdl file for the protocol defintion, and xsd file for every request type. i've played around with LXML and SUDS, and i got this : xml parsing (i don't really know if i need this, but i made it just to see how it works ): try: > from lxml import etree > except ImportError: > import xml.etree.ElementTree as etree > # > document = etree.parse("HotelValuedAvailRQ.xml") > root = document.getroot() > #namespaces used > xmlns = '' > xsi = '{http://www.hotelbeds.com/schemas/2005/06/messages}' > # > user = document.find('//{namespace}User'.format(namespace=namespace)) > user.text = '' #set hotelbeds user(text) > > password = > document.find('//{namespace}Password'.format(namespace=namespace)) > password.text = '' #set hotelbeds password(text) > > language = > document.find('//{namespace}Language'.format(namespace=namespace)) > language.text = '' #set hotelbeds response language(text) > > > #set number of pages for xml response(attribute) > PaginationData = root[2].set('pageNumber', '4') > #set check in date, format :'20130509' > CheckInDate = root[3].set('date', '') > #set check out date > CheckOutDate = root[4].set('date', '') > #set dest code, set dest type > Destination = root[5].set('code', ''); root[5].set('type', '') > > #set the room count > RoomCount = > document.find('//{namespace}RoomCount'.format(namespace=namespace)) > RoomCount.text = '' > #set number of adults > AdultCount = > document.find('//{namespace}AdultCount'.format(namespace=namespace)) > RoomCount.text = '' > #set number of children > ChildCount = > document.find('//{namespace}ChildCount'.format(namespace=namespace)) > ChildCount.text = '3' > > document.write('HotelValuedAvailRQ.xml') > print '--->Changes saved' > > and i also made this, some suds experiment : import logging > logging.basicConfig(level = logging.INFO) > logging.getLogger('suds.client').setLevel(logging.DEBUG) > #logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) > #logging.getLogger('suds.transport').setLevel(logging.DEBUG) > #logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) > logging.getLogger('suds.wsse').setLevel(logging.DEBUG) > from suds.client import Client > url = 'http://xxx.xxx.xxx.xxx/appservices/ws/FrontendService?wsdl' > client = Client(url) > print client > which gives me following result : > Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: > R699-20100913 > > Service ( FrontendServiceService ) tns=" > http://www.hotelbeds.com/wsdl/2005/06" > Prefixes (0) > Ports (1): > (FrontendService) > Methods (34): > cancelProtectionAdd(xs:anyType cancelProtectionAdd, ) > cancelProtectionRemove(xs:anyType cancelProtectionRemove, ) > getCancelProtectionAvail(xs:anyType getCancelProtectionAvail, ) > getCarCountryList(xs:anyType getCarCountryList, ) > getCarInfoSet(xs:anyType getCarInfoSet, ) > getCarValuedAvail(xs:anyType getCarValuedAvail, ) > getCountryList(xs:anyType getCountryList, ) > getDestinationGroupList(xs:anyType getDestinationGroupList, ) > getHotelBoardGroupList(xs:anyType getHotelBoardGroupList, ) > getHotelBoardList(xs:anyType getHotelBoardList, ) > getHotelCategoryGroupList(xs:anyType > getHotelCategoryGroupList, ) > getHotelCategoryList(xs:anyType getHotelCategoryList, ) > getHotelCountryList(xs:anyType getHotelCountryList, ) > getHotelDetail(xs:anyType getHotelDetail, ) > getHotelList(xs:anyType getHotelList, ) > getHotelRoomTypeGroupList(xs:anyType > getHotelRoomTypeGroupList, ) > getHotelValuedAvail(xs:anyType getHotelValuedAvail, ) > getIncomingOfficeDetail(xs:anyType getIncomingOfficeDetail, ) > getIncomingOfficeList(xs:anyType getIncomingOfficeList, ) > getPurchaseDetail(xs:anyType getPurchaseDetail, ) > getPurchaseList(xs:anyType getPurchaseList, ) > getTicketAvail(xs:anyType getTicketAvail, ) > getTicketClassificationList(xs:anyType > getTicketClassificationList, ) > getTicketCountryList(xs:anyType getTicketCountryList, ) > getTicketDetail(xs:anyType getTicketDetail, ) > getTicketValuation(xs:anyType getTicketValuation, ) > getTransferCountryList(xs:anyType getTransferCountryList, ) > getTransferValuedAvail(xs:anyType getTransferValuedAvail, ) > getZoneGroupList(xs:anyType getZoneGroupList, ) > purchaseCancel(xs:anyType purchaseCancel, ) > purchaseConfirm(xs:anyType purchaseConfirm, ) > purchaseFlush(xs:anyType purchaseFlush, ) > serviceAdd(xs:anyType serviceAdd, ) > serviceRemove(xs:anyType serviceRemove, ) > Types (0): > > this is how the xml request should look like: > > 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"> > > xmlns:hb="http://axis.frontend.hydra.hotelbeds.com" xsi:type="xsd:string"> > 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"> > ENG > > TEST > TEST > > > > > > > > 1 > > 2 > 0 > > > > > > > > > - this is how xml request + soap envelope as first envelope should look like.do i generate that using SUDS, or do i hardcode the soap envelope with lxml? can you tell me, what next?i'm reading suds documentation, i have some clue about the next step, but i'm not sure.do i generate xml request from wsdl file's methods or do i edit existing xml files provided by the provider, and send them, and what about xsd files?i'm,interested only in getHotelValuedAvail,serviceAdd,serviceRemove,and purchaseFlush methods. and sorry if the message is too big... -------------- next part -------------- An HTML attachment was scrubbed... URL: