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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Designing a Java Connector for Software Integrations
  • Kafka JDBC Source Connector for Large Data
  • Make Your Integration Seamless By Using Ballerina Client Connectors
  • How to Integrate a Distributed Database With Event Streaming

Trending

  • Streamlining Event Data in Event-Driven Ansible
  • Beyond Linguistics: Real-Time Domain Event Mapping with WebSocket and Spring Boot
  • Agile and Quality Engineering: A Holistic Perspective
  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis

Configure an HTTP Connector as a Listener

Check out how to set up an HTTP connector (and a requester) in Mulesoft to serve as a listener.

By 
Kumar Gaurav user avatar
Kumar Gaurav
·
Jul. 27, 16 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
19.0K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

The HTTP connector can send and receive HTTP and HTTPS requests given a selected host, port, and address. So depending on your needs, you can either:

  • Listen for HTTP requests.
  • Send HTTP requests.

Through additional configuration, the connector allows you to:

  • Use TLS encryption to send or receive HTTPS requests.
  • Send Authenticated Requests, via Basic Authentication, Digest, and OAuth.

As HTTP Listener       

To instantiate the connector as an HTTP listener connector, you must place it onto a blank Anypoint Studio canvas into the Source section of a new flow (as the first element in the flow) as you design your Mule application:

Image title


As HTTP Requester

To instantiate the connector as an HTTP request connector, you must place it into the Process section of a flow (anywhere except the beginning of it):
Image title


Demonstration

So, now we will see how an HTTP connector works as an HTTP listener. Below is the target flow to be designed for an HTTP connector as a listener:

Image title


Step 1:  Create a new flow httpconndemoFlow as directed below:

Image title


Step 2: Configure the HTTP listener of httpconndemoFlow for the GET method as:
Image title


Step 3: Add a set payload transformer and a logger just after it, then add values for the respective fields specified below:
Image title


Step 4: Check the XML configuration:


<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.8.0">
    <http:listener-config xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="/httpdemo" doc:name="HTTP Listener Configuration">    </http:listener-config>
    <flow name="httconndemoFlow">
        <http:listener xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" config-ref="HTTP_Listener_Configuration" path="/" allowedMethods="G" doc:name="HTTP">    </http:listener>
        <set-payload xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" value="#['This is a sample payload']" doc:name="Set Payload">    </set-payload>
        <logger xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" message="#['LOGGER_MSG- '+message.payload]" level="INFO" doc:name="Logger">   </logger>
    </flow>
</mule>


Step 5: Start testing in your browser and check logger messages in the Mule console:

Image title


Conclusion

There you have it! We have seen how an HTTP connector works as a listener. Similarly, an HTTP requester can be configured and used the same way.

An HTTP listener can be configured for different HTTP methods — GET, POST, etc. Obviously, I went with the GET method for this demonstration.

Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Related

  • Designing a Java Connector for Software Integrations
  • Kafka JDBC Source Connector for Large Data
  • Make Your Integration Seamless By Using Ballerina Client Connectors
  • How to Integrate a Distributed Database With Event Streaming

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: