Salesforce

Example - Overriding default MultiPartEntityWriter in httpClient

« Go Back

Information

 
TitleExample - Overriding default MultiPartEntityWriter in httpClient
URL NameExample-Overriding-default-MultiPartEntityWriter-in-httpClient
Article Number000140360
EnvironmentProduct: OpenEdge
Version: 11.6, 11.7
OS: All Supported Platforms
Other: OpenEdge HttpClient
Question/Problem Description

This article contains an example of creating an entity writer object, that is responsible for reading HTTP message bodies and creating 'strongly typed' objects. So a HTTP message with a Content-Type of multipart/form-data uses a MultipartEntityWriter to create an instance of a OpenEdge.Net.MultipartEntity class based on a CHARACTER or MEMPTR representation.

There may be cases where you have custom content types or the shipped writers are buggy. In this case, you can create a new, or override an existing, EntityWriter. These must be instances of OpenEdge.Net.HTTP.Filter.Payload.MessageWriter.
 

Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution

 

Registering writers

In your code, add the entity writer to the appropriate registry. This only needs to be done once per session, so it's recommended to do this duriung session startup.
 

USING OpenEdge.Net.HTTP.Filter.Writer.EntityWriterRegistry. 
USING Example.Writer.ExtendedJsonEntityWriter. 
// The HTTP client (and certain webhandlers) will now use the ExtendedJsonEntityWriter 
// for all JSON content 
EntityWriterRegistry:Registry:Put('application/json':u, 
                                                      get-class(ExtendedJsonEntityWriter)).

The Registry property is an instance of the OpenEdge.Core.Util.BuilderRegistry type, which is a map of characters (keys) and Progress.Lang.Class instances (values). There are GetPutRemove and Clear methods, as well Has and a Size property for registry inspection.

Examples (attached)

File nameDescriptionComments
ExtendedJsonEntityWriter.clsWrites JSON as Progress.ObjectModel.JsonConstruct and certain primitive types 
test_ext_writer.pExample of registering the writer and calling it
Workaround
Notes
References to Other Documentation:
Progress Article(s):

 Is there an HTTP client for OpenEdge?

​​​​​​​
Keyword Phrase
Last Modified Date11/20/2020 7:01 AM

Powered by