0
我在PHP中有以下內容,但需要在django視圖中使用它。基本上,這是USAepay xml.I需要通過HTTP POST一樣向它發送:如何在django視圖中的變量中使用xml?
$result=$this->httpPost($url, array('xml'=>$data));
我試圖讓意見在Django以下的備選。
$data = '<?xml version="1.0" encoding="UTF-8"?>' .
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
'<SOAP-ENV:Body>' .
'<ns1:runCustomerTransaction>'.
'<Token xsi:type="ns1:ueSecurityToken">' .
'<ClientIP xsi:type="xsd:string">' . $_SERVER['REMOTE_ADDR'] . '</ClientIP>' .
'<PinHash xsi:type="ns1:ueHash">' .
'<HashValue xsi:type="xsd:string">' . $hash . '</HashValue>' .
'<Seed xsi:type="xsd:string">' . $seed . '</Seed>' .
'<Type xsi:type="xsd:string">sha1</Type>' .
'</PinHash>' .
'<SourceKey xsi:type="xsd:string">' . $this->key . '</SourceKey>' .
'</Token>' .
'<CustNum xsi:type="xsd:integer">' . $CustNum . '</CustNum>'.
'<PaymentMethodID xsi:type="xsd:integer">0</PaymentMethodID>'.
'<Parameters xsi:type="ns1:CustomerTransactionRequest">'.
'<Command xsi:type="xsd:string">Sale</Command>'.
'<Details xsi:type="ns1:TransactionDetail">' .
'<Amount xsi:type="xsd:double">' . $this->xmlentities($this->amount) . '</Amount>' .
'<Description xsi:type="xsd:string">' . $this->xmlentities($this->description) . '</Description>'.
'<Invoice xsi:type="xsd:string">' . $this->xmlentities($this->invoice) . '</Invoice>' .
'<Currency xsi:type="xsd:string">484</Currency>'.
'</Details>' .
'</Parameters>'.
'</ns1:runCustomerTransaction>'.
'</SOAP-ENV:Body>' .
'</SOAP-ENV:Envelope>';
你到底需要什麼幫助嗎?您的PHP正在從一個字符串構建XML。在Python中這樣做的問題是什麼? – 2013-02-12 16:10:27
閱讀關於python中的字符串格式 – ndpu 2013-02-12 16:15:45