Php curl kullanarak bir WCF web hizmeti (PaySimple en v3.00 API) tüketen sorunlar yaşıyorum. Ben hizmet için bir xml yükü yayınlamak için çalışıyorum ve ben bir 400 alıyorum - Bad Request hatası. Ben Firefox'un Poster kullanırken add-on, ben çok aynı yükü gönderebilir ve ben beklenen yanıt almak - gerekli yanıtı içeren bir XML yanıt ile 200 OK. İşte benim kod parçacığı var:
        $ch = curl_init();
        $payload = $createPayload();
        $length = strlen($payload);
        $headers = array("Expect:");
        if($isPost)
        {
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
            $headers[] = "Content-length: $length";
        }
        else {
            curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
        }
        if($requestType == 'xml')
        {
            $headers[] = 'Content-Type: text/xml; charset: utf-8';
            $headers[] = 'Accept: application/xml';
        }
        else {
            $headers[] = 'Content-Type: application/json; charset: utf-8';
            $headers[] = 'Accept: application/json';
        }            
        $headers[] = "Connection: close";
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        //debugging
        curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
        $fh = fopen('curl_debug.txt', 'w');
        curl_setopt($ch, CURLOPT_STDERR, $fh);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);            
        $response = curl_exec($ch);
        curl_close($ch);
$ Yük aşağıdaki değeri içerir:
<AddCustomer xmlns="http://api.paysimple.com"><userkey>APIUser1989</userkey><apikey>pxTbp4F6y7JuaMu36qazEw51JiqUA7lGme0j62r3UeQyNojvEfpNo7tn4pLq0yEULHz5KykHWV6AjNQJEyskCw0tXSKZ0vcP5mCynh1IgfQEH4NdXRkXeMNAGEdx6Ee0</apikey><customer xmlns="http://api.paysimple.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ApiConsumerData/><PsReferenceId>0</PsReferenceId><AltEmail>testE-posta@paysimpledev.com</AltEmail><AltPhone/><BillingAddress1>TestBillingAddress1</BillingAddress1><BillingAddress2/><BillingCity>TestBillingCity</BillingCity><BillingCountryCode/><BillingPostalCode>80202</BillingPostalCode><BillingState>6</BillingState><CompanyName>TestCompany</CompanyName><CreatedOn>0001-01-01T00:00:00</CreatedOn><Email>testE-posta@paysimpledev.com</Email><Fax/><FirstName>TestFirstName</FirstName><LastModified>0001-01-01T00:00:00</LastModified><LastName>TestLastName</LastName><MiddleName/><Notes/><Phone>5551234567</Phone><ShippingAddress1/><ShippingAddress2/><ShippingCity/><ShippingCountryCode/><ShippingPostalCode/><ShippingSameAsBilling>true</ShippingSameAsBilling><ShippingState>0</ShippingState><WebSite/></customer></AddCustomer>
İşte curl_debug.txt kadar gösterir ne:
- ) (Bağlanmak için yaklaşık sandbox-api.paysimple.com port 443 (# 0)
 - 165.193.50.51 çalışılıyor ... * bağlı
 - Sandbox-api.paysimple.com bağlı (165.193.50.51) port 443 (# 0)
 - başarıyla ayarlandığını sertifika yerleri doğrulayın:
 - CAfile: none CApath: /etc/ssl/certs
 - RC4-MD5 kullanarak SSL bağlantısı
 - Sunucu sertifikası:
 - Konu: C = US; ST = Colorado; L = Denver; O = PaySimple, Inc; OU = PaySimple; CN = *. Paysimple.com
 - 2010-05-04 00:00:00 GMT: başlangıç tarihi
 - 2011-06-29 23:59:59 GMT Geçerlilik Tarihi:
 - ihraççı: C = US; O = DigiCert A.Ş.; OU = www.digicert.com; CN = DigiCert Yüksek Güvence CA-3
 - SSL sertifikası ok doğrulayın.
 
POST /3.00/paysimpleapi.svc/xml/listcustomers HTTP/1.1
Host: sandbox-api.paysimple.com
Content-length: 1153
Content-Type: text/xml; charset: utf-8
Accept: application/xml
Connection: close
HTTP/1.1 400 Bad Request
 Connection: close
 Date: Fri, 27 Aug 2010 11:07:21 GMT
 Server: Microsoft-IIS/6.0
 X-Powered-By: ASP.NET
 X-AspNet-Version: 2.0.50727
 Set-Cookie: ASP.NET_SessionId=oxpese454u4rr3552evybjue; path=/; HttpOnly
 Cache-Control: private
 Content-Length: 0  
Kapanış bağlantı # 0
F1! F1!