Wikis - Page

Scripting: How to work with a binary payload

0 Likes
using System;
using System.Text;
using HP.SV.CSharp;

namespace HP.SV {
  public class CSharpRule {
  
    public static void Execute(HpsvRootObject sv) {
      byte[] binaryData = Convert.FromBase64String(sv.Request.BinaryContent.Data);
      string requestStringData = Encoding.UTF8.GetString(binaryData);
      
      string responseStringData = ProduceResponse(requestStringData);
      
      binaryData = Encoding.UTF8.GetBytes(responseStringData);
      sv.Response.Type = "BinaryContent";
      sv.Response.BinaryContent = new Type_of_element_BinaryContent();
      sv.Response.BinaryContent.Data = Convert.ToBase64String(binaryData);
    }

    private static string ProduceResponse(string requestStringData) {
      // TODO: Implement your logic return requestStringData;
    }
  }
}

Labels:

How To-Best Practice
Comment List
Related
Recommended