调用时,Python SUDS不会在参数中包含命名空间

时间:2016-12-16 12:53:53

标签: python suds

使用SOAP UI,对我的服务的调用如下所示:

 <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns0="http://transactionblackout.service.sms.app.fc.ofss.com/TransactionBlackoutApplicationService" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://context.app.fc.ofss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header>
  <wsse:Security mustUnderstand="true">
     <wsse:UsernameToken>
        <wsse:Username>ofssuser</wsse:Username>
        <wsse:Password>welcome1</wsse:Password>
        <wsse:Nonce>aa2cfee1df46db6c9badc306b5cd67d8</wsse:Nonce>
        <wsu:Created>2016-12-16T12:24:19.523257Z</wsu:Created>
     </wsse:UsernameToken>
  </wsse:Security>
</SOAP-ENV:Header>
   <ns1:Body>
        <ns0:fetchAllBlackoutsTransactionBlackout>
     <ns0:sessionContext>
        <ns2:bankCode>08</ns2:bankCode>
        <ns2:channel>BRN</ns2:channel>
        <ns2:externalBatchNumber/>
        <ns2:externalSystemAuditTrailNumber/>
        <ns2:serviceCallContextType/>
        <ns2:targetUnit>OBP_BU</ns2:targetUnit>
        <ns2:transactionBranch>089999</ns2:transactionBranch>
        <ns2:userId>ofssuser</ns2:userId>
     </ns0:sessionContext>
  </ns0:fetchAllBlackoutsTransactionBlackout>
</ns1:Body>
</SOAP-ENV:Envelope>

我的client看起来喜欢这个

Service ( TransactionBlackoutApplicationService ) tns="http://transactionblackout.service.sms.app.fc.ofss.com/TransactionBlackoutApplicationService"
 Prefixes (11)
  ns0 = "http://context.app.fc.ofss.com"
  ns1 = "http://datatype.fc.ofss.com"
  ns2 = "http://dto.common.domain.framework.fc.ofss.com"
  ns3 = "http://enumeration.fc.ofss.com"
  ns4 = "http://enumeration.infra.fc.ofss.com"
  ns5 = "http://error.validation.infra.fc.ofss.com"
  ns6 = "http://exception.infra.fc.ofss.com"
  ns7 = "http://response.service.fc.ofss.com"
  ns8 = "http://transactionblackout.dto.sms.app.fc.ofss.com"
  ns9 = "http://transactionblackout.service.sms.app.fc.ofss.com/TransactionBlackoutApplicationService"
  ns10 = "http://validation.dto.app.fc.ofss.com"
Ports (1):
  (TransactionBlackoutApplicationServicePort)
     Methods (8):
        addBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
        closeBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
        deleteBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
        fetchAllBlackouts(ns0:sessionContext sessionContext, )
        fetchBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
        fetchUserBlackout(ns0:sessionContext sessionContext, xs:string role, xs:string partyId, )
        reopenBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
        updateBlackout(ns0:sessionContext sessionContext, ns8:transactionBlackoutDTO blackoutDTO, )
     Types (40):
        addBlackoutTransactionBlackout
        addBlackoutTransactionBlackoutResponse
        ns0:approvalContext
        ns7:baseResponse
        closeBlackoutTransactionBlackout
        closeBlackoutTransactionBlackoutResponse
        ns2:dataTransferObject
        ns1:date
        deleteBlackoutTransactionBlackout
        deleteBlackoutTransactionBlackoutResponse
        ns2:dictionary
        ns2:domainObjectDTO
        ns3:entityStatus
        ns6:extendedReply
        ns6:fatalExceptionBean
        fetchAllBlackoutsTransactionBlackout
        fetchAllBlackoutsTransactionBlackoutResponse
        fetchBlackoutTransactionBlackout
        fetchBlackoutTransactionBlackoutResponse
        fetchUserBlackoutTransactionBlackout
        fetchUserBlackoutTransactionBlackoutResponse
        ns3:maintenanceType
        ns2:nameValuePairDTO
        ns3:recordStatusType
        reopenBlackoutTransactionBlackout
        reopenBlackoutTransactionBlackoutResponse
        ns6:replyMessage
        ns4:replyMessageType
        ns4:responseCodeType
        ns3:serviceCallContextType
        ns0:sessionContext
        ns8:transactionBlackoutDTO
        ns8:transactionBlackoutInquiryResponse
        ns8:transactionBlackoutKeyDTO
        ns7:transactionStatus
        updateBlackoutTransactionBlackout
        updateBlackoutTransactionBlackoutResponse
        ns0:userContext
        ns10:validatable
        ns5:validationError

我尝试使用suds进行以下操作:

session = client.factory.create('{http://context.app.fc.ofss.com}sessionContext')
session.value = my_values
response=client.service.fetchAllBlackouts(sessionContext=session)

但服务看起来像:

    <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns0="http://transactionblackout.service.sms.app.fc.ofss.com/TransactionBlackoutApplicationService" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://context.app.fc.ofss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
  <wsse:Security mustUnderstand="true">
     <wsse:UsernameToken>
        <wsse:Username>ofssuser</wsse:Username>
        <wsse:Password>welcome1</wsse:Password>
        <wsse:Nonce>36fd4993d9165bdfa720c7c1d66c6582</wsse:Nonce>
        <wsu:Created>2016-12-16T12:41:54.985519Z</wsu:Created>
     </wsse:UsernameToken>
  </wsse:Security>
  </SOAP-ENV:Header>
 <ns1:Body>
  <ns0:fetchAllBlackoutsTransactionBlackout>
     <sessionContext>
        <ns2:bankCode>08</ns2:bankCode>
        <ns2:channel>BRN</ns2:channel>
        <ns2:externalBatchNumber/>
        <ns2:externalSystemAuditTrailNumber/>
        <ns2:serviceCallContextType/>
        <ns2:targetUnit>OBP_BU</ns2:targetUnit>
        <ns2:transactionBranch>089999</ns2:transactionBranch>
        <ns2:userId>ofssuser</ns2:userId>
     </sessionContext>
  </ns0:fetchAllBlackoutsTransactionBlackout>

sessionContect参数中,它没有添加命名空间 我收到以下错误:

Server raised fault: 'Unable to process request   '

服务受到攻击但传递的参数sessionContext为null

0 个答案:

没有答案