help with suds soap envelope

112 views
Skip to first unread message

Ismar Sehic

unread,
Sep 24, 2013, 3:47:42 AM9/24/13
to python-...@googlegroups.com
hello, i'm trying to make a wrapper for making xml requests to hotelbeds.com site.
this is what i got:


import logging
from suds.xsd.doctor import ImportDoctor, Import
from suds.plugin import Plugin
logging.basicConfig(level = logging.INFO)
logging.getLogger('suds.
client').setLevel(logging.DEBUG)
from suds.client import Client
url = 'http://xxx.xxx.xxx.xx/appservices/ws/FrontendService?wsdl'

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
doctor = ImportDoctor(imp)
client = Client(url, doctor = doctor)

print client

rw = client.service.getHotelValuedAvail(client)
print rw
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 (1)
     ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
  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 (48):
        ns0:Array
        ns0:ENTITIES
        ns0:ENTITY
        ns0:ID
        ns0:IDREF
        ns0:IDREFS
        ns0:NCName
        ns0:NMTOKEN
        ns0:NMTOKENS
        ns0:NOTATION
        ns0:Name
        ns0:QName
        ns0:Struct
        ns0:anyURI
        ns0:arrayCoordinate
        ns0:base64
        ns0:base64Binary
        ns0:boolean
        ns0:byte
        ns0:date
        ns0:dateTime
        ns0:decimal
        ns0:double
        ns0:duration
        ns0:float
        ns0:gDay
        ns0:gMonth
        ns0:gMonthDay
        ns0:gYear
        ns0:gYearMonth
        ns0:hexBinary
        ns0:int
        ns0:integer
        ns0:language
        ns0:long
        ns0:negativeInteger
        ns0:nonNegativeInteger
        ns0:nonPositiveInteger
        ns0:normalizedString
        ns0:positiveInteger
        ns0:short
        ns0:string
        ns0:time
        ns0:token
        ns0:unsignedByte
        ns0:unsignedInt
        ns0:unsignedLong
        ns0:unsignedShort

**********************************************************************
this is what i'm sending(logging set to INFO):
<HotelValuedAvailRS 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/messages HotelValuedAvailRS.xsd"><AuditData><ProcessTime>-1</ProcessTime><Timestamp>2013-09-24 09:37:35.644</Timestamp><RequestHost>176.9.36.98:98</RequestHost><ServerName>FORM</ServerName><ServerId>FO</ServerId><SchemaRelease>2005/06</SchemaRelease><HydraCoreRelease>2.0.201305161604</HydraCoreRelease><HydraEnumerationsRelease>1.0.201305161604</HydraEnumerationsRelease><MerlinRelease>N/A</MerlinRelease></AuditData><ErrorList><Error><Code>A12-02-ZZZ-FO</Code><Timestamp>1380008255644</Timestamp><Message>Content is not allowed in prolog.</Message></Error></ErrorList></HotelValuedAvailRS>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope>
   <soapenv:Body>
      <ns1:getHotelValuedAvail xsi:type="xsd:string">&lt;HotelValuedAvailRS xmlns=&quot;http://www.hotelbeds.com/schemas/2005/06/messages&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.hotelbeds.com/schemas/2005/06/messages HotelValuedAvailRS.xsd&quot;&gt;&lt;AuditData&gt;&lt;ProcessTime&gt;-1&lt;/ProcessTime&gt;&lt;Timestamp&gt;2013-09-24 09:37:35.644&lt;/Timestamp&gt;&lt;RequestHost&gt;176.9.36.98:98&lt;/RequestHost&gt;&lt;ServerName&gt;FORM&lt;/ServerName&gt;&lt;ServerId&gt;FO&lt;/ServerId&gt;&lt;SchemaRelease&gt;2005/06&lt;/SchemaRelease&gt;&lt;HydraCoreRelease&gt;2.0.201305161604&lt;/HydraCoreRelease&gt;&lt;HydraEnumerationsRelease&gt;1.0.201305161604&lt;/HydraEnumerationsRelease&gt;&lt;MerlinRelease&gt;N/A&lt;/MerlinRelease&gt;&lt;/AuditData&gt;&lt;ErrorList&gt;&lt;Error&gt;&lt;Code&gt;A12-02-ZZZ-FO&lt;/Code&gt;&lt;Timestamp&gt;1380008255644&lt;/Timestamp&gt;&lt;Message&gt;Content is not allowed in prolog.&lt;/Message&gt;&lt;/Error&gt;&lt;/ErrorList&gt;&lt;/HotelValuedAvailRS&gt;</ns1:getHotelValuedAvail>
   </soapenv:Body>
</soapenv:Envelope>
 
loggin set to DEBUG:
</ns0:getHotelValuedAvail>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'""', 'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.client:http succeeded:
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:getHotelValuedAvail xsi:type="xsd:string" xmlns:ns1="http://axis.frontend.hydra.hotelbeds.com">&lt;HotelValuedAvailRS xmlns=&quot;http://www.hotelbeds.com/schemas/2005/06/messages&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.hotelbeds.com/schemas/2005/06/messages HotelValuedAvailRS.xsd&quot;&gt;&lt;AuditData&gt;&lt;ProcessTime&gt;-1&lt;/ProcessTime&gt;&lt;Timestamp&gt;2013-09-24 09:45:45.876&lt;/Timestamp&gt;&lt;RequestHost&gt;176.9.36.98:98&lt;/RequestHost&gt;&lt;ServerName&gt;FORM&lt;/ServerName&gt;&lt;ServerId&gt;FO&lt;/ServerId&gt;&lt;SchemaRelease&gt;2005/06&lt;/SchemaRelease&gt;&lt;HydraCoreRelease&gt;2.0.201305161604&lt;/HydraCoreRelease&gt;&lt;HydraEnumerationsRelease&gt;1.0.201305161604&lt;/HydraEnumerationsRelease&gt;&lt;MerlinRelease&gt;N/A&lt;/MerlinRelease&gt;&lt;/AuditData&gt;&lt;ErrorList&gt;&lt;Error&gt;&lt;Code&gt;A12-02-ZZZ-FO&lt;/Code&gt;&lt;Timestamp&gt;1380008745875&lt;/Timestamp&gt;&lt;Message&gt;Content is not allowed in prolog.&lt;/Message&gt;&lt;/Error&gt;&lt;/ErrorList&gt;&lt;/HotelValuedAvailRS&gt;</ns1:getHotelValuedAvail></soapenv:Body></soapenv:Envelope>
<HotelValuedAvailRS 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/messages HotelValuedAvailRS.xsd"><AuditData><ProcessTime>-1</ProcessTime><Timestamp>2013-09-24 09:45:45.876</Timestamp><RequestHost>176.9.36.98:98</RequestHost><ServerName>FORM</ServerName><ServerId>FO</ServerId><SchemaRelease>2005/06</SchemaRelease><HydraCoreRelease>2.0.201305161604</HydraCoreRelease><HydraEnumerationsRelease>1.0.201305161604</HydraEnumerationsRelease><MerlinRelease>N/A</MerlinRelease></AuditData><ErrorList><Error><Code>A12-02-ZZZ-FO</Code><Timestamp>1380008745875</Timestamp><Message>Content is not allowed in prolog.</Message></Error></ErrorList></HotelValuedAvailRS>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope>
   <soapenv:Body>
      <ns1:getHotelValuedAvail xsi:type="xsd:string">&lt;HotelValuedAvailRS xmlns=&quot;http://www.hotelbeds.com/schemas/2005/06/messages&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.hotelbeds.com/schemas/2005/06/messages HotelValuedAvailRS.xsd&quot;&gt;&lt;AuditData&gt;&lt;ProcessTime&gt;-1&lt;/ProcessTime&gt;&lt;Timestamp&gt;2013-09-24 09:45:45.876&lt;/Timestamp&gt;&lt;RequestHost&gt;176.9.36.98:98&lt;/RequestHost&gt;&lt;ServerName&gt;FORM&lt;/ServerName&gt;&lt;ServerId&gt;FO&lt;/ServerId&gt;&lt;SchemaRelease&gt;2005/06&lt;/SchemaRelease&gt;&lt;HydraCoreRelease&gt;2.0.201305161604&lt;/HydraCoreRelease&gt;&lt;HydraEnumerationsRelease&gt;1.0.201305161604&lt;/HydraEnumerationsRelease&gt;&lt;MerlinRelease&gt;N/A&lt;/MerlinRelease&gt;&lt;/AuditData&gt;&lt;ErrorList&gt;&lt;Error&gt;&lt;Code&gt;A12-02-ZZZ-FO&lt;/Code&gt;&lt;Timestamp&gt;1380008745875&lt;/Timestamp&gt;&lt;Message&gt;Content is not allowed in prolog.&lt;/Message&gt;&lt;/Error&gt;&lt;/ErrorList&gt;&lt;/HotelValuedAvailRS&gt;</ns1:getHotelValuedAvail>
   </soapenv:Body>
</soapenv:Envelope>


**********************************************************************
this is how the xml request should look like:
<?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/messages HotelValuedAvailRQ.xsd">
<Language>ENG</Language>
<Credentials>
<User>TEST</User>
<Password>TEST</Password>
</Credentials>
<PaginationData pageNumber="1"/>
<CheckInDate date="20130709"/>
<CheckOutDate date="20130711"/>
<Destination code="PMI" type="SIMPLE"/>
<OccupancyList>
<HotelOccupancy>
<RoomCount>1</RoomCount>
<Occupancy>
<AdultCount>2</AdultCount>
<ChildCount>0</ChildCount>
</Occupancy>
</HotelOccupancy>
</OccupancyList>
</HotelValuedAvailRQ>
</hb:getHotelValuedAvail>
</soapenv:Body>
</soapenv:Envelope>

how can i edit soap envelope, and soap message itself, to make it look like the one above, do i have a problem with namespaces?
Reply all
Reply to author
Forward
0 new messages