Spring Soap client - get raw response - spring

I created a Soap client using Spring tutorial: https://spring.io/guides/gs/consuming-web-service/
It works fine using the Java objects.
I wonder if there's a way I could obtain response (the payload, preferably without SOAP wrapper) as it is send by the service?
Thanks

You can see the request you send to the SOAP service and the response the service returns in your log application adding this property to your application.properties
logging.level.org.springframework.ws=TRACE
or this one if you are using application.yaml
logging:
level:
org:
springframework:
ws: TRACE

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

Spring integration and Microservice communication

I am pretty new to Spring Integration. I have an application written in spring integration which does a rest call to my microservice(spring boot application)
The request is a pure String and the request message(header+payload) has content type set as TEXT_PLAIN and my microservice's controller consumes as mediatype.PLAIN_TEXT_VALUE
When initiate a request to the microservice from the spring integration application it is throwing an error as "unsupported type"
Why does it throw error and what other alternative do i have?
I do not want or can't have JSON as request or response. It is just an unformatted string as input and a formatted string as output

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