Mule 4 Anypoint Studio download file from external api - api

I will need to create a flow in Anypoint to download a .gz file from an external API source(through OAuth). I have created a listener -> Request -> Write flow. But I don't see the file saved in my local after I called the API. I have hardcoded Bearer token in the header and raw parameters in body, everything looks good. It doesn't show any error but when I tried to debug it and I'm seeing output and payload both are empty. I'm able to download the gz file with Postman. Am I in the right direction? I saw someone was using outbound endpoint but it is not showing in Mule 4.
Is there any way I can see what the external API returned(Success or failed)? And the content? Please advise.
Many thanks.
Regards,
Richard
Update 1:
Mule Flow
DEBUG
Added the Flow and the Debugging message. I have simplified the flow and just tried to make the POST rest call with Bearer token. It should return a json response. But still getting an empty response. Do we know what's that java.util.LinkedHashMap thing? Thanks.
Update 2:
Request Body
Request Header
XML Configuration:
XML Flow

You can add loggers to the application to trace the execution.
You could also enable HTTP wire logging to print requests/responses in the log too. To enable it you have to set the package org.mule.service.http.impl.service.HttpMessageLogger to DEBUG in the log4j2.xml or in the Runtime Manager console. Detailed instructions available at this KB article.

Related

Getting Unsupported Media Type in Postman response while sending GraphQL API mock request data

I am working on an application with graphQL and spring boot framework. Here I am using GraphQL's Schema-first approach to write my schema details. In my scenario, I need to update the user profile image using GraphQL. I am using my test client as postman and I have attached the mock request structure as well. When I send my mock data to the server, I am receiving '415 - Unsupported Media Type' error response. Can someone please guide me on this. ?
Also, please suggest if I have to use multipart file to get the uploaded file at the server.
Thanks in advance.

invoke web service with authentication headers in ode bpel

I'm using eclipse bpel designer and trying to invoke a external service which requires authentication headers to be passed.
Here is what I have done
1. Created a headers.endpoint file with the following content
*alias.sample_ns="http://sample.com"
sample_ns.serviceName.portName.ode.http.default-headers.username=system
sample_ns.serviceName.portName.ode.http.default-headers.password=admin*
Placed it in ..\webapps\ode\WEB-INF\processes\$process folder
When I invoke the service I'm getting the following error
"Error sending message (mex={PartnerRoleMex#hqejbhcnphrckf492s9n9b [PID {http://createReservation}CreateReservation-1541] calling org.apache.ode.bpel.epr.WSAEndpoint#1e1f4b8.saveRecord(...) Status ASYNC}): Transport error: 401 Error: Unautho".
I think I need to add header information when invoking the service in BPEL process as well. But couldn't find the way to do it. How can it be done, if this is actually what I'm missing? Or is there something else to be done?
Thanks in advance
Note: HTTP Auth information cannot be set in the *.endpoint files.
For invoking HTTP Service
Testcase will show you how to do it
https://github.com/apache/ode/tree/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties
Add message part in WSDL as shown here
https://github.com/apache/ode/blob/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl#L66
Assign credentials in Process
https://github.com/apache/ode/blob/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties.bpel#L73
For invoking Soap Service
http://ode.apache.org/http-authentication.html

How to Login in Web Application using REST APIs through JMETER

I am trying a Performance scenario where single user logs in to web application.
For that i am using Jmeter and REST-APIs
Here i have to call REST-APIs for that i have used "HTTP Request Defaults", I have created one thread group and added one "HTTP Request Default".
From APIs i have to pass two parameters:
1) User Name
2) Password
What would be the syntax of parameters in HTTP Request Defaults? or what sampler i should use for this?
I have one API link from which we can trigger those parameter, which will get applied on web application.
First of all you'll need a HTTP Header Manager configured to send the following header:
Name: Content-Type
Value: application/json
Elsewise your request may not be processed as needed
The sampler you need to use is generic HTTP Request sampler. The easiest way to provide JSON payload is to switch to Body Data tab and put your JSON there as below:
Optionally you may with to use JSON Path Extractor for correlation
See Testing SOAP/REST Web Services Using JMeter guide for a quick ramp-up on the RESTful web services testing domain.
for ease of use
In your Jmeter click on File, select Templates
In the opened window/dialog, select "Building a SOAP web-service test plan"
Click on Create.
It will open a test plan, which should give you a fare idea on how to achieve your scenario.
Hope this will help.

how to get response back from mule server to my own application

I've gone through AnyPoint Connector tutorial of mulesoft. Here Following this tutorial I was able to get response in logger in mule studio console. Then I thought to to one step further, to create a web application and get response back to my application html file. In this way I am getting response as a file which is of type Application/octate-stream But I want a json response.
I have no idea to do this. Please tell me the way. I am very new to mule and web services stuff. In fact I started my study on mule two days back only.
Thanks.
Select "Object to JSON" from Mule toolbar "Transformers" list, and add that as the last component inside the flow.

WSO2 API Manager is not responding to a request that returns zip file (application/octet-stream)

Using WSO2 API Manager 1.3.1. Trying to use the API Manager to proxy to a REST service. I have set up the service in API Mgr and can successfully post and get responses, typically json, though some are text.
However, when I try to GET a resource that returns binary content (a zip "file", content-type:application/octet-stream), the API Manager does not seem to respond and I can see an error in the console window (i'm running wso2server.bat in console):
[2013-07-03 11:52:05,048] WARN - SourceHandler Connection time out
while writing the response: 173.21.1.22:1268->173.21.1.22:8280
I have an HTTPModule on my internal service and it seems to be responding with the appropriate content (I can see the GET and response data logged). I can also call to the internal service directly and get a response, so that end of things seems OK. But going through the API Manager seems to fail.
I found information on enabling other content-types:
WSO2 API Manager - Publishing API with non-XML response
http://wso2.com/library/articles/binary-relay-efficient-way-pass-both-xml-non-xml-content-through-apache-synapse
Using that information I tried to enable the application/octet-stream for messageFormatter and messageBuilder using the binary relay and it did not help (or seem to make a difference). I have even disabled all other content-types and use the binary relay for all content-types and it does not help.
Currently, I'm running with just the following in both axis2.xml and axis2_client.xml (in their appropriate sections):
<messageBuilder contentType=".*" class="org.wso2.carbon.relay.BinaryRelayBuilder"/
<messageFormatter contentType=".*" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
I still get my json and text responses, but WSO2 times out getting the zip content. I saw the JIRA referenced in axis2.xml about enabling the ".*" relay, but as the other requests seem to work, I'm not sure it's an issue for me. I did try adding
'format="rest"' to the API definition, but it seemed to break all operations even the ones that worked prior so I've pulled it back out.
Any ideas on what is happening or how to dig in and debug this will help. Thanks!
After working with this for much too long, it turns out that my WSO2 configuration was correct, using the Message Relay and BinaryRelayBuilder, etc. While my REST service could reply immediately, I was setting a HTTP header that I assume WSO2 does not like, because when i removed it WSO2 would reply at an expected rate (instantly).
I was setting the header:
Transfer-Encoding: binary
When I removed that header from my service reply, then WSO2 operated as expected. I don't know if that's a "bug" in WSO2 or if I was implementing incorrectly, but I do have what seems like a "workaround" by omitting that header from my service response.