Why spring cloud gateway always returns response in JSON format if no Accept Header is specified in the HTTP request? - spring

We have migrated our in house gateway to spring cloud gateway for routing the requests to respective down-stream micro-services. Whenever a call is made without Accept header, the existing service was returning the response in the XML format(this is the behaviour of the downstream micro-services if we don't pass any Accept headers) - However, when the same call is made without Accept header to spring cloud gateway, the response is returned in JSON format.
How to configure spring cloud gateway to not take the application/json as the Accept header if not passed by the client?
spring-cloud-gateway-starter-version: 3.0.0

Related

Rename X-B3-TraceId headers in spring cloud sleuth

I have few services written in Node that are using "X-Request-Id" as the header to identify requests. I am now writing services in Java using spring-boot where I can use spring-cloud-sleuth to track traceId and spanId.
However, I would like to continue using the "X-Request-Id" as the request identifier across all of my services. Is there any way to rename the "X-B3-TraceId" header in spring-sleuth so that it sends the same header in HTTP requests and also uses the said header from incoming requests to set the traceId?
You can propagate extra fields, see the Propagation section of the Spring Cloud Sleuth docs.
spring:
sleuth:
propagation-keys: x-correlation-id

Pass multipart/form-data through API Gateway in Lambda Proxy integration

I am trying to upload multiple files through the API Gateway in a lambda proxy integration using multipart/form-data. I added the multipart/form-data as one of the supported media types in the API Gateway settings. The issue that I am having is that the API Gateway is encoding it in Base64 when it passes it to the lambda proxy. Is there a way to disable this encoding and forward the data as it is to the lambda proxy?

Send Mock response for Soap Request

We have created an soap request and sending the request using WebServiceTemplate
WebServiceTemplate.marshalSendAndReceive(request)
As my client is not ready with the server. I am trying to handle this request in my local and planning to post some dummy response.
Can you help me how I can mock this response?
If you are using CXF, see my JUnit Rule utility project. It creates an Endpoint using JaxWsServerFactoryBean.

Spring Integration webservice outbound gateway - capturing request and response to DB with additional values

I am using Spring integration WS 2.2 outbound gateway to invoke a webservice.
One of our requirement is to capture the soap request and response xmls to the database in addition to some other values like transaction id etc.
If i use ClientInterceptor to save the request/response to DB, it only has access to the soap request and the response but not to the values like transaction Id. So is there a way to retrieve and return the soap request and response from the interceptor OR a way to pass custom values to the interceptor?
Thanks

401 Authorization Required on REST client

I am trying to write a very simple REST client using RestTemplate and Jackson JSON.
Tried such sample from spring.io Getting error 401 Authorization Required even on localhost or even if I include it into the same Tomcat6 Eclipse project where that REST WebService is running.
We don't require any authorization on that Web Service while in Dev or local environment,
and anyway I am an authorized user.
Is that something enforced by Spring RestTemplate?
Running client as Java application on Java 1.6.
I am new to REST and JSON.
No there is no enforced Authorization required by Spring's RestTemplate. You should be able to build or launch an example simple REST webservice and send requests to it with RestTemplate without receiving this response, so either the server you are sending the requests to or something inbetween is returning this response code. Can you share any more details of the service you are communicating with? Is it something internal or a public API which may require Authorization?

Resources