how to set soap fault error code messages using spring java - spring

I am working on Spring with soap.
I need to define some soap fault error messages in java. which we can see in wsdl response.
soap fault error code with message.
I am trying to configure in custom exception

Related

Consume Kafka Messages and Post to REST API using Spring Boot

I have below the requirement to be implemented in Spring Boot.
How to achieve this?
Consume a message from a topic and Transform the message fields for the REST API
POST it to a REST API via HTTP or HTTPs.
Capture the API response.
Record any errors while posting the message.
You can use Spring Kafka or Spring Cloud Stream with Kafka binder to receive the message.
It will deserialize it you, then you can transfrom it to object you want.
Then you can use (inject) RestTemplate (or Webclient for reactive) to post the message. It will send the message and receive the response. For error handling, you can use the default ones via try/catch, or implement your own by implementing ResponseErrorHandler .
Some useful links:
RestTemplate
RestTemplate Error handling
Spring Kafka

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

Spring-ws using custom schema for SOAP Faults

I am working on creating a web service using Spring-WS. And i am using the validation framework provided by Spring-WS to validate the request. When there are validation errors, the web service returns a SOAP fault with the validation errors in the detail element of the SOAP Fault. I'd like to know if there is a way we can send a custom response(message with my own schema) instead of a SOAP Fault response? If so, i'd be grateful if you can describe how i can achieve this.
I have checked the idea of extending PayloadValidatingInterceptor for this purpose, but this only provides me a way to customize the fault string or the error detail message of the SOAP fault which is not what I want.
Thanks in advance!

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?

custom HTTP status code with spring and restful webservice

I am new to the spring and restful framework. My server hosts 3 restful web services. I have used spring support for the restful web services to implement the server. The client sends JSON request to the server and gets JSON response. Client is based on spring support for the restful. The server returns 200/OK for successful processing, which is default.
What I want is the server to send custom HTTP status code 550 to the client in case there is an issue while processing the request. It should not throw any exception to the client. It should only send 550/an_error_object(as json) back to the client.
How is it possible with the spring support of restful ? I am doing the following on the server side.
HttpServletResponse.setStatus(550)
but, the client side is failing to recognize the status code 550; it throws an exception since org.springframework.http.HttpStatus doesn't have any enum constant '550' defined.
Any suggestions will be great!
Thanks in advance.
Rohit
1) Don't use unregistered status codes. See the registered status codes.
2) That being said, that's a bug in the Spring framework. It should deal properly with extension status codes.
It'll probably going to be fixed in version 4.3 of Spring.
https://jira.spring.io/browse/SPR-14205

Resources