2010-05-26 18 views
1

這是我的代碼,我不知道如何調試它,因爲我只是得到一個「內部服務器錯誤」:得到使用REST客戶端在紅寶石內部服務器錯誤張貼到HTTP POST

我想到HTTP POST到外部ASPX:

def upload 
    uri = 'https://api.postalmethods.com/2009-02-26/PostalWS.asmx' #postalmethods URI 

    #https://api.postalmethods.com/2009-02-26/PostalWS.asmx?op=UploadFile 
    #http://www.postalmethods.com/method/2009-02-26/UploadFile 

    @postalcard = Postalcard.find(:last) 
    #Username=string&Password=string&MyFileName=string&FileBinaryData=string&FileBinaryData=string&Permissions=string&Description=string&Overwrite=string 
    filename = @postalcard.postalimage.original_filename 
    filebinarydata = File.open("#{@postalcard.postalimage.path}",'rb') 

    body = "Username=me&Password=sekret&MyFileName=#{filename}&FileBinaryData=#{filebinarydata}" 

    @response = RestClient.post(uri, 
        body, #body as string 
        {"Content-Type" => 'application/x-www-form-urlencoded', 
        "Content-Length" => @postalcard.postalimage.size} # end headers 
       ) #close arguments to Restclient.post 
    end 
+1

如果不知道RestClient或postalmethods API的任何信息,您似乎正在對SOAP服務執行標準HTTP Post,而未執行必要的SOAP編碼。看看Savon用紅寶石做SOAP。 – 2010-05-26 09:58:16

+0

是的,我是...我不知道有一種方法可以做肥皂編碼...謝謝@Steve – Angela 2010-05-26 21:34:40

回答

0

打開PostalMethods在其HTTP POST上有錯誤和錯誤。

它只需要SOAP,所以我需要薩翁。