2012-02-28 37 views
0

このxmlを送信することで、この支払いのgetwayリクエストを行いたいと思います。djangoまたはphp curl投稿xmlデータ

<?xml version="1.0" encoding="UTF-8"?> 
<COBROAIRLINES> 
<paymentService> 
<id_company>0000</id_company> 
<id_branch>5</id_branch> 
<country>MEX</country> 
<user>USUARIO</user> 
<password>DE3C9FEF064F1459C30C0E7B</password> 
<merchant>00000</merchant> 
<reference>123pba</reference> 
<tp_operation>12</tp_operation> 
<creditCardType>V/MC</creditCardType> 
<creditCardName>NOMBRE TH</creditCardName> 
<creditCardNumber>AF3992EE603B743FC70D0D71F858C63C</creditCardNumber> 
<creditCardExpMonth>AB3D</creditCardExpMonth> 
<creditCardExpYear>AA3E</creditCardExpYear> 
<creditCardCVV>291</creditCardCVV> 
<initialDeferment>00</initialDeferment> 
<numberOfPayments>06</numberOfPayments> 
<planType>03</planType> 
</paymentService> 
<transaction> 
<transactionTS>2008/01/01 10:00:00</transactionTS> 
<currency>MXN</currency> 
<orderAmount>1000</orderAmount> 
<orderTotalTickets>1</orderTotalTickets> 
<orderPromo>0</orderPromo> 
<orderSource>000</orderSource> 
<sdos>1</sdos> 
</transaction> 
<passengerFlight> 
<passengerName>Juan Perez</passengerName> 
<passengerTicketAmount>1000</passengerTicketAmount> 
<passengerFrequentFlierNumber>96321</passengerFrequentFlierNumber> 
<flightFare>A</flightFare> 
<flightRoundTrip>0</flightRoundTrip> 
<flightOriginCity>MEX</flightOriginCity> 
<flightOriginCountry>MEX</flightOriginCountry> 
<flightDestinationCity>TKY</flightDestinationCity> 
<flightDestinationCountry>JAP</flightDestinationCountry> 
<flightDaysTillDeparture>1</flightDaysTillDeparture> 
<flightLayovers>0</flightLayovers> 
</passengerFlight> 
<userSalutation>Ing.</userSalutation> 
<userName>Juan Perez</userName> 
<userStreet>Heriberto Frias 1527</userStreet> 
<userNeighborhood>Del Valle</userNeighborhood> 
Confidential 13 de 25 Airlines Payment Iv6.0 
<userCity>Mexico</userCity> 
<userState>DF</userState> 
<userZipCode>03100</userZipCode> 
<userCountry>Mexico</userCountry> 
<userPhone>5554425700</userPhone> 
<userPhone2>5512345678</userPhone2> 
<userEMail>[email protected]</userEMail> 
<userLogin>prueba</userLogin> 
<userReturnCustomer>0</userReturnCustomer> 
<billingName>Juan Perez</billingName> 
<billingStreet>Corregidora</billingStreet> 
<billingHouseNumber>92</billingHouseNumber> 
<billingHouseNumberInt>1</billingHouseNumberInt> 
<billingNeighborhood>Miguel Hidalgo</billingNeighborhood> 
<billingMunicipality>Tlalpan</billingMunicipality> 
<billingCity>Mexico</billingCity> 
<billingState>DF</billingState> 
<billingZipCode>14260</billingZipCode> 
<billingCountry>Mexico</billingCountry> 
<billingPhone>5515009000</billingPhone> 
<billingPhone2>5515009020</billingPhone2> 
<billingEMail>[email protected]</billingEMail> 
<browserSessionID>org.apache.catalina.session.Sta...</browserSessionID> 
<browserHostName>172.0.0.1</browserHostName> 
<browserAccept>image/gif</browserAccept> 
<browserAcceptEncoding>gzip, deflate</browserAcceptEncoding> 
<browserAcceptCharset>ISO-8859-1,utf-8;q=0.7,*;q=0.7 </browserAcceptCharset> 
<browserID>Mozilla/4.0 (compatible; MSIE 5.5)</browserID> 
<browserIDLanguageCode>en-us,en;q=0.5</browserIDLanguageCode> 
<browserCookie>CL=null</browserCookie> 
<browserIP>172.452.16.23</browserIP> 
<browserReferer>http://www.cualquiera.com</browserReferer> 
<browserConnection>keep-alive</browserConnection> 
<javascriptData> TF1;014;5;7;18068;6%2C0%2C6001%2C18000;....</javascriptData> 
<customField1>ABCDEF</customField1> 
<customField2></customField2> 
<customField3></customField3> 
<customField4></customField4> 
<customField5></customField5> 
</COBROAIRLINES> 

支払いgetwayのURLが支払getwayのドキュメントのhttps://dev.mitec.com.mx/wscobroSdos/CobroAirlines/?xml= で、彼らは、XML = xmlファイルの内容を与えています。 だから、基本的に私はそれがGETかPOSTか分かっていませんが、xmlのcharachterはPOSTではないと仮定しています。

私は何を行うことができますなぜ私が試してみましたが、

$xmldatafile="payment.xml"; 
    $xmlData = file_get_contents($xmldatafile); 
    $URL = "https://dev.mitec.com.mx/wscobroSdos/CobroAirlines?xml="; 

    $ch = curl_init(); 
    // curl_setopt($ch, CURLOPT_MUTE, 1); 
    curl_setopt($ch, CURLOPT_URL, $URL); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

    echo $output = curl_exec($ch); 
    if(curl_errno($ch)) { 
    print curl_error($ch); 
} 
    curl_close($ch); 

、それは私にこの応答を与えているのか分かりませんか?

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<CENTEROFPAYMENTS> 
    <reference></reference> 
    <response>error</response> 
    <foliocpagos></foliocpagos> 
    <auth></auth> 
    <cd_response></cd_response> 
    <cd_error>01</cd_error> 
    <nb_error>El xml enviado no corresponde a ningun modelo</nb_error> 
    <time>05:02:44</time> 
    <date>28/02/2012</date> 
    <voucher></voucher> 
</CENTEROFPAYMENTS> 

も私の究極の目標であるジャンゴのpythonにしようとした同じAPI: 私は、これは、応答メートルになっているpaymentgetwayサイトhttp://www.centrodepagos.com.mx/cdpweb/descargas.htm

だと思います。

import pycurl 
ncServerURL='https://dev.mitec.com.mx/wscobroSdos/CobroAirlines?xml=' 
binaryptr = open('payment.xml','rb').read() 
c = pycurl.Curl() 
c.setopt(pycurl.URL, ncServerURL) 
c.setopt(pycurl.POST, 1) 
c.setopt(pycurl.HTTPHEADER, ["Content-type: text/xml"]) 
# c.setopt(c.URL, ncServerURL + '?xml=' + binaryptr) 
# c.setopt(pycurl.TIMEOUT, ncServerMaxTime) 
# c.setopt(pycurl.CONNECTTIMEOUT, ncServerMaxTime) 
c.setopt(pycurl.NOSIGNAL, 1) # disable signals, curl will be using other means besides signals to timeout. 
c.setopt(pycurl.POSTFIELDS, binaryptr) 
import StringIO 
b = StringIO.StringIO() 
c.setopt(pycurl.WRITEFUNCTION, b.write) 
c.perform() 
ncServerData = b.getvalue() 
print ncServerData 

応答Mの取得は、次のとおり

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<CENTEROFPAYMENTS> 
    <reference></reference> 
    <response>error</response> 
    <foliocpagos></foliocpagos> 
    <auth></auth> 
    <cd_response></cd_response> 
    <cd_error>01</cd_error> 
    <nb_error>El xml enviado no corresponde a ningun modelo</nb_error> 
    <time>05:02:44</time> 
    <date>28/02/2012</date> 
    <voucher></voucher> 
</CENTEROFPAYMENTS> 

はurllib2の

import urllib2 
import urllib 
binaryptr = open('payment.xml','rb').read() 
data = binaryptr 
headers = { 
    'Content-Type': 'application/soap+xml; charset=utf-8' 
} 
req = urllib2.Request('https://dev.mitec.com.mx/wscobroSdos/CobroAirlines?xml=', data, headers) 
response = urllib2.urlopen(req) 
the_page = response.read() 
print the_page 

と試み上記と同じエラーを得ました。

+0

なぜurllibの代わりにcurlを使用しますか? – Willian

+0

@Willianもurllibで試してみる – XMen

答えて

1

本文ではなくURLにXMLが必要なようです。これはかなり悪いデザインですが、それを追加しようとしていますか?xml =

$URL = "https://dev.mitec.com.mx/wscobroSdos/CobroAirlines/?xml=" . $xmlData; 
+0

どのようにして擬似コードを書くことができるのですか – XMen

+0

同じレスポンスを得ようとしましたが、レスポンスで質問を更新しました – XMen

関連する問題