soap - python suds UsernameToken -


code:

security = security() token = usernametoken('b77a5c561934e089', 'kmfhknzyn1u/pgaiy3+h0bohdki=') security.tokens.append(token) client.set_options(wsse=security) 

my problem one: when including usernametoken, receive kind of header:

   <soap-env:header>       <wsse:security mustunderstand="true">          <wsse:usernametoken>             <wsse:username>b77a5c561934e089</wsse:username>             <wsse:password>kmfhknzyn1u/pgaiy3+h0bohdki=</wsse:password>          </wsse:usernametoken>       </wsse:security>    </soap-env:header> 

but need response requirement on web service:

<sp:signedsupportingtokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">   <wsp:policy>     <sp:usernametoken sp:includetoken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/includetoken/alwaystorecipient">       <wsp:policy>         <sp:wssusernametoken10 />       </wsp:policy>     </sp:usernametoken>   </wsp:policy> </sp:signedsupportingtokens> 

how can suds? searched whole internet, didnt find solution.

your code soap generic solution. web service seems require custom response.

i presume authentication not work?

try marshall response requester class. plugin allows modify soap envelope. can add own attributes.

class myrequesterclass(object):      class _myservicemarshalled(messageplugin):          def marshalled(self, context):             commons.set_service_common_header(context, "yourservice")              body = context.envelope.getchild('body')             service = body.getchild("childwhereyouwantaddyourcustomxml")              service.attributes.append(attribute("sp:includetoken", "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/includetoken/alwaystorecipient"))              etc, etc 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -