[Fedora-suds-list] how to set a hyphenated field in client request?

Jeff Ortel jortel at redhat.com
Fri Mar 27 14:21:48 UTC 2009


Hey Matthew,

The suds.sudsobject implements __getitem__() and __setitem__() just for this reason.

Try:

 >
 > result['user-verified-content'].append(a)
 > result['user-verified-content'].append(b)
 > result['user-verified-content'].append(c)
 >
or

 >
 > result['user-verified-content'] = [a,b,c]
 >

Regards,

Jeff

Matthew wrote:
> Hi,
> 
> The quick summary is there is a field in a SOAP request named, 
> "event-id", and I'm having trouble setting this field because the name 
> contains a hyphen.  How do I get around this?   For example:
> 
>  >>> result = client.factory.create('ns0:UserVerifiedEvent')
>  >>> print result
> (UserVerifiedEvent){
>    event-id = None
>    user-verified-content[] = <empty>
>    domain-specific-attributes =
>       (MediaAttributes){
>          domain-attribute[] = <empty>
>       }
>  }
> 
> 
> Here's more background.
> 
> I'm trying to develop an MLB.tv client for Linux and they've changed 
> their web service to a SOAP architecture.
> 
> A little snooping and I was able to find that the first request sends an 
> event-id and the response has a listing of all media content matching 
> that event-id.
> 
> The request looks like this:
> 
> <SOAP-ENV:Envelope 
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <SOAP-ENV:Body>
>     <scma:user-verified-media-request 
> xmlns:scma="http://services.bamnetworks.com/media/types/2.0">
>       <scma:event-id>164-251340-2009-03-12</scma:event-id>
>       <scma:subject>LIVE_EVENT_COVERAGE</scma:subject>
>     </scma:user-verified-media-request>
>   </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> 
> Here's the wsdl:
> 
>  >>> import suds
>  >>> from suds.client import Client
>  >>> url = 'http://www.mlb.com/flash/mediaplayer/v4/wsdl/MediaService.wsdl'
>  >>> client = Client(url)
>  >>> print client
> 
> Suds ( https://fedorahosted.org/suds/ )  version: 0.3.5 (beta)  build: 
> R483-20090324
> 
> Service ( MediaService2_0 ) tns="http://services.bamnetworks.com/media/2.0"
>    Prefixes (1)
>       ns0 = "http://services.bamnetworks.com/media/types/2.0"
>    Ports (1):
>       (MediaService2_0SOAP11port_http)
>          Methods (1):
>             find(xs:string event-id, xs:long content-id, xs:string 
> playback-scenario, xs:string subject, xs:string ip-address, 
> ns0:CreditCard credit-card, ns0:IdentityPoint 
> fingerprint-identity-point, xs:string session-key, )
>          Types (28):
>             ns0:Address
>             ns0:AudioTrack
>             ns0:AuthStatus
>             ns0:BlackedOutStatus
>             ns0:BlackoutKeywords
>             ns0:BlackoutStatus
>             ns0:CreditCard
>             ns0:Entitlements
>             ns0:IdentityPoint
>             ns0:LocationCannotBeDeterminedStatus
>             ns0:LoginRequired
>             ns0:MediaAttribute
>             ns0:MediaAttributes
>             ns0:MediaItem
>             ns0:MediaUserLocation
>             ns0:NotAuthorizedStatus
>             ns0:PreviewStatus
>             ns0:ResponseStatusCode
>             ns0:SessionKey
>             ns0:SignOnRestrictionStatus
>             ns0:SuccessStatus
>             ns0:SwarmcastKeyGenResponse
>             ns0:SwarmcastKeyStatusCode
>             ns0:UserVerifiedContent
>             ns0:UserVerifiedEvent
>             ns0:UserVerifiedMediaItem
>             ns0:UserVerifiedMediaRequest
>             ns0:UserVerifiedMediaResponse
> 
> Now, I'm still trying to learn SOAP, WSDL, and suds, but somehow I need 
> to set the event-id.  I thought maybe I needed to create a 
> UserVerifiedEvent so I tried that but I'm stumped at how to set a value 
> to event-id because of the hyphen.
> 
>  >>> result = client.factory.create('ns0:UserVerifiedEvent')
>  >>> print result
> (UserVerifiedEvent){
>    event-id = None
>    user-verified-content[] = <empty>
>    domain-specific-attributes =
>       (MediaAttributes){
>          domain-attribute[] = <empty>
>       }
>  }
>  >>> result.event-id = '164-251340-2009-03-12'
> SyntaxError: can't assign to operator
> 
> 
> Any ideas?
> 
> Thanks,
> Matthew Levine
> https://sourceforge.net/projects/mlbviewer/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list




More information about the fedora-suds-list mailing list