tencent cloud

Cloud Infinite

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Product Overview
Product Strengths
Use Cases
Feature Overview
Regions and Domains
Specifications and Limits
Billing
Billing Overview
Billing Mode
Billable Items
Free Tier
Payment Overdue
Viewing Bill Details
FAQs
Getting Started
Registering and Logging In
Bind Bucket
Uploading and Processing File
Downloading and Deleting Images
Unbinding Buckets
Using CI via COS
Features
Image Processing
Media Processing
Content Moderation
AI Content Recognition
File Processing
Smart Voice
File processing
User Guide
Overview
Bucket Management
Smart Toolbox
Job and Workflow
Data Monitoring
Usage statistics
Use Cases
Copyright Protection Solutions
Image Processing Practices
Working with API Authorization Policies
Workflow Practices
API Documentation
API Overview
Structure
Common Request Headers
Common Response Headers
Activate Vast Service
Image Processing
AI-Based Content Recognition
Smart Audio
Media Processing
Content Moderation
Document Processing
File Processing
Job and Workflow
Cloud Virus Detection
Error Codes
Request Signature
SDK Documentation
SDK Overview
Android SDK
iOS SDK
COS Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Go SDK
COS iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
Mini Program SDK
Personal Information Protection Policy for SDK
Security and Compliance
Permission ‍Management
FAQs
Basic Settings
Document Processing
Media Processing
Content Recognition
Smart Audio
Agreements
Service Level Agreement
Contact Us
Glossary

Callback Information Processing

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-02-29 17:31:27

Overview

This document provides SDK code samples for standard callback information parsing in CI.

XML Callback Content Parsing

Description

The common XML callback information in CI is parsed into Java objects.

Examples

This example shows you how to parse the XML callback data by getting Unmarshallers.
Note:
You can get the required XML parser by viewing the APIs of COSClient. You can also find out which Unmarshaller is being used by viewing the query API corresponding to the feature.
For example, the query API corresponding to the file preview callback information is describeDocProcessJob.
The code snippet in COSClient used to check which Unmarshaller is used by the invoke method.
@Override
public DocJobResponse describeDocProcessJob(DocJobRequest request) {
this.checkCIRequestCommon(request);
CosHttpRequest<DocJobRequest> httpRequest = this.createRequest(request.getBucketName(), "/doc_jobs/" + request.getJobId(), request, HttpMethodName.GET);
return this.invoke(httpRequest, new Unmarshallers.DescribeDocJobUnmarshaller());
}
Use Unmarshaller to parse the response content.
public static void processCINotifyResponse(String response) throws Exception {
Unmarshallers.DescribeDocJobUnmarshaller describeDocJobUnmarshaller = new Unmarshallers.DescribeDocJobUnmarshaller();
InputStream is = new ByteArrayInputStream(response.getBytes());
DocJobResponse docJobResponse = describeDocJobUnmarshaller.unmarshall(is);
}

JSON Callback Content Parsing

Description

The common JSON callback information in CI is parsed into Java objects.

Examples

Note:
Essentially, processing JSON callbacks is to convert JSON to XML before processing.
The demo uses org.json to convert JSON to XML. This dependency is not provided in the POM of the SDK and needs to be imported by yourself.
For example, the query API corresponding to image moderation callback information is describeAuditingImageJob.
The code snippet in COSClient used to check which Unmarshaller is used by the invoke method.
@Override
public ImageAuditingResponse describeAuditingImageJob(DescribeImageAuditingRequest imageAuditingRequest) {
rejectNull(imageAuditingRequest.getBucketName(),
"The bucketName parameter must be specified setting the object tags");
rejectNull(imageAuditingRequest.getJobId(),
"The jobId parameter must be specified setting the object tags");
CosHttpRequest<DescribeImageAuditingRequest> request = createRequest(imageAuditingRequest.getBucketName(), "/image/auditing/" + imageAuditingRequest.getJobId(), imageAuditingRequest, HttpMethodName.GET);
return invoke(request, new Unmarshallers.ImageAuditingDescribeJobUnmarshaller());
}
Use Unmarshaller to parse the response content after converting the JSON response to XML.
// Callback demo
public static void processJsonCINotifyResponse(String jsonResponse) throws Exception {
JSONObject response = new JSONObject(jsonResponse);
JSONObject json = new JSONObject();
json.put("Response",response);
String xml = XML.toString(json);
Unmarshallers.ImageAuditingDescribeJobUnmarshaller imageJobUnmarshaller = new Unmarshallers.ImageAuditingDescribeJobUnmarshaller();
InputStream is = new ByteArrayInputStream(xml.getBytes());
ImageAuditingResponse imageAuditingResponse = imageJobUnmarshaller.unmarshall(is);
}
org.json.json is used in the above example, which is not provided in the SDK. If you need to use it, add the following dependencies:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan