Axis2C : Sending data with Custom content type - axis2c

The client (Browser) expects to receive a JSON string in response. I have the JSON string to send at the service side. However the calling function (axis2_invoke) expects axiom_node_t which make it return XML.
Is there a way to send my response in a way I want to and not as axiom objects

AxiOM is a data abstraction layer, not XML.
When talking about Axis2/C-unofficial which supports JSON natively, you will get response depending of your request format:
if you setup Content-Type of your request to application/json you will get response in JSON format;
if you setup Content-Type of your request to application/soap+xml you will get response in SOAP format.
Your response AxiOM is to be be converted to appropriate format by Axis2/C's transport sender.

Related

Sending JSON response via GenericJsonWebHookReceiver MVC ASP.NET

I need to send the JSON response from GenericJsonWebHookReceiver provided by Nuget package in ASP.NET.
I am trying to send the JSON value in the return call like this - "return Task.FromResult(sampleJson);"  , where sampleJson is a valid JSON in string format.
But while testing, I am still getting empty response.
How can we send the JSON response with GenericJsonWebHookReceiver? Also how to set the proper header type in the response to define it as JSON type response?
Thanks,
/vikas

Conversion of json object to object in jmeter

I have a POST API consuming JSON Object. I need to pass the JSON as body data to the API. The conversion of JSON Object to the intended class object is failing. Do we have to specify any other parameters?
You have to specify Content-Type header to application/json using HTTP Header Manager (add it as a child to the HTTP sampler of POST request), so that JMeter sends the POST request telling the server that the body contains JSON using the header.

Is it a good practice to send json data in http headers

I have a REST API Endpoint endpoint/action. The method is POST having a json data in the request body. I have two headers for this
Content-Type=application/json
Custom-Header={"object":{"id":"someId"}}
The object is deserialized during processing and the "someId" is used for other processes
Was wondering if it is a good practice to send json strings/data in the http header. Couldn't find anything in the Http Header documentations.
Option would be just sending in the "someId" and fetching the object using the id

How to send json format input to ODATA?

I are trying to consume an OData Service whose purpose is to takes search criteria and returns the search results. I m using ODataJClient java library to consume the service.
I wanted to know if the input search criteria can be passed in JSON format to the OData Service. The catch is when we use the GET request, we are limited by the character length while the POST request would actually create a new entity with the payload. Any suggestions on how can we send the JSON input ? Thanks in advance ...
If you want to communicate with Service with JSON format, try add the following in request headers:
Content-Type: application/json
Accept: application/json

How does server handle JSON in the body of a POST

I am using jQuery to post JSON data to a tomcat server and the server is handling the JSON array data perfectly! It is as though I passed key=value request parameters along with the URL.
So why am I posting this? I would like to know how the server treats JSON in the body of a request and how the data ends up being interpreted as request parameters. I have Googled my a** off and all I find is how the server sends JSON back to the client.
$.ajax() converts JSON data into key-value pairs (querystring style) by default. You need to set { processData : false } in the AJAX request to keep it as raw JSON.