2016-11-29 11 views
0

Ich verwende eine SSIS-Skriptkomponente, um C# -Code für eine WEB-API auszuführen, die mir einen Wert zurückgibt, der ein Base64-codiertes Byte und ein Rückgabearray ist.Decode Base64 HTTPWEBRESPONSE in C# - Rückgabe Japanisch

Der tatsächliche Rückgabewert ist ein codierter JSON-String, den ich anschließend deserialisieren und ausgeben muss.

Ich verwende die folgenden C#, um zu versuchen, die Antwort zu dekodieren.

foreach (Attachment atch in rptOutputResponse.Response.attachments) 
     { 
      RptAttachmentsBuffer.AddRow(); 

      RptAttachmentsBuffer.AppId = rptOutputResponse.Response.appId; 
      RptAttachmentsBuffer.Type = atch.type; 
      RptAttachmentsBuffer.Name = atch.name; 
      RptAttachmentsBuffer.ContentType = atch.contentType; 

      byte[] rptConRaw = Encoding.UTF8.GetBytes(atch.content); 

      String s = Convert.ToBase64String(rptConRaw); 

      byte[] newbytes = Convert.FromBase64String(s); 

      System.Windows.Forms.MessageBox.Show(BitConverter.ToString(newbytes)); 

      RptAttachmentsBuffer.ReportContent.AddBlobData(newbytes); 

     } 

Das erwartete Ergebnis sieht so aus.

{"Applications":{"Application":{"AppID":2891426,"ReportID":4160202,"AppReference":"Taplin 12-Oct-16 10:37:02AM","CreateDT":"2016-10-12 10:37:23.3500000","ClientName":"GoGetta Brisbane","StoreName":"Brokers","Email":"","StoreCode":"GGT08","AppShortReference":"02","ClientNameShort":"GGT Bris","StoreNameShort":"GGT08","VerifyEmployer":null,"VerifyAmount":null,"VerifyFrequency":null,"VerifyWeekday":null,"LocalityCode":"en_AU","TemplateReportID":12,"daysRange":90,"templateReportName":"Enhanced Income Liabilities Full Report","Accounts":{"Account":[{"AccountID":4829641,"AccountNumber":"17-986-7500","AccountType":"savings","AccountName":"XXXXXXXXXXXX7500","AccountHolder 

Jedoch, wenn es zu meiner Tabelle ausgegeben wird, kommt es auf Japanisch durch. Was mache ich falsch?

+0

Was ist der Wert von 'atch.content'? – wdosanjos

+0

sollte es die codierte Zeichenfolge sein, die zurückgegeben wird. eyJBcHBsaWNhdGlvbnMiOnsiQXBwbGljYXRpb24iOnsiQXBwSUQiOjI4OTE0MjYsIlJlcG9ydElEIjo0MTYwMjAyLCJBcHBSZWZlcmVuY2UiOiJUYXBsaW4gMTItT2N0LTE2IDEwOjM3OjAyQU0iLCJDcmVhdGVEVCI6IjIwMTYtMTAtMTIgMTA6Mz ... –

Antwort

0

Bitte versuchen Sie folgendes:

foreach (Attachment atch in rptOutputResponse.Response.attachments) 
{ 
    RptAttachmentsBuffer.AddRow(); 

    RptAttachmentsBuffer.AppId = rptOutputResponse.Response.appId; 
    RptAttachmentsBuffer.Type = atch.type; 
    RptAttachmentsBuffer.Name = atch.name; 
    RptAttachmentsBuffer.ContentType = atch.contentType; 

    byte[] newbytes = Convert.FromBase64String(atch.content); 

    string json = Encoding.UTF8.GetString(newbytes); 

    System.Windows.Forms.MessageBox.Show(json); 

    RptAttachmentsBuffer.ReportContent.AddBlobData(newbytes); 

} 
+0

Sie mein neues Lieblings menschlich sind. Vielen Dank! –

+1

@wdosanjos, sollte newbytes mit json ersetzt werden !! –

+0

@MukeshModhvadiya danke. Ich habe die fehlende Variable 'newbytes' korrigiert. – wdosanjos