DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Top 10 Engineering KPIs Technical Leaders Should Know
  • What Is Envoy Proxy?
  • Integrating AWS With Salesforce Using Terraform
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers

Trending

  • Top 10 Engineering KPIs Technical Leaders Should Know
  • What Is Envoy Proxy?
  • Integrating AWS With Salesforce Using Terraform
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  1. DZone
  2. Coding
  3. Languages
  4. MuleSoft 4.0 BETA (XML to JSON Transformation)

MuleSoft 4.0 BETA (XML to JSON Transformation)

This tutorial explains how to transform XML to JSON.

Varun Goyal user avatar by
Varun Goyal
·
Jul. 02, 18 · Tutorial
Like (3)
Save
Tweet
Share
13.87K Views

Join the DZone community and get the full member experience.

Join For Free

Step 1

Open Anypoint studio and create a new project as shown namely as xml2json.

  • Drag and drop an HTTP listener Connector to get a request for your servers and give the host and port numbers. Like here, the host is set to mule4.eaiesb.com and port to 8099 and test your connection to check whether the port is in use or not by testing the connection successfully.
  • After the successful connection and verification that the port is not reserved, set the path for your service as: /xml2json

Step 2

Drag a transform message from the Mule palette.

  • It helps us to transform the Mule message from the XML to JSON as shown:

Image title

Step 3

Set the input metadata and output metadata format.

  • Click on +Add to select the input XML schema file and give a friendly name like StudentsXMLSchema.
  • Select the type as XML and from Schema, select an input file as here: Students.xsd as shown below:

Image title

  • Set the output metadata and Type ID: StudentsJSONSchema is used as the name by selecting Type as JSON and set the Schema as here: Students.json and create the desired output structure as shown:

Image title

Step 4

Map input metadata fields to output fields.

  • Once you map the field, the transform message will write the code with respect accordingly to that shown below:

Image title

Step 5

Run the Mule project.

By default, Mule will download all the artifacts from the Maven repository and once the project does not have errors, it will show a successful deployment.

Step 6

Open the Postman and hit the service URL request as shown:

  • Select the method as POST and go to body and select raw in it. Select the DataType as XML and give the XML data in body and click on Send.

Image title


Step 7

Check the output response data in the JSON format transformed successfully.

Image title

Happy Learning!!

XML JSON BETA (programming language) MuleSoft

Opinions expressed by DZone contributors are their own.

Trending

  • Top 10 Engineering KPIs Technical Leaders Should Know
  • What Is Envoy Proxy?
  • Integrating AWS With Salesforce Using Terraform
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: