Post request from angular to spring boot server params are not seen - spring

I am quite new with angular and spring boot and I am trying to send a post request from angular to the spring server but it gives me bad request with message "Required String parameter 'key' is not present"
however the post is sent with request payload containing the key and the value, but it is a request payload not a form data and I don't know whether it differs or not :/
spring code:
https://drive.google.com/open?id=1oRMAtICuS0TaoPVMgDxd1ApGALnCOq-o

Related

How can I enable ws-addressing in spring so that replyTo is understood?

I created a ws endpoint with spring using spring-boot-starter-webservices.
I have used #org.springframework.ws.server.endpoint.annotation.Endpoint.It works fine.
But when I am trying to add the wsa:ReplyTo addressing header to the request with mustUnderstand=true the server prints:
Could not handle mustUnderstand headers: {http://www.w3.org/2005/08/addressing}ReplyTo. Returning fault
and returns a similar Fault as a response.
How can I enable addressing so that ReplyTo is understood and replies with 202, sending the response to the differrent endpoint described in ReplyTo?
I tried adding #javax.xml.ws.soap.Addressing(enabled=true) next to #Endpoint annotation but I still get the above behaviour.

How to access Request headers in Spring Web services PayloadValidatingInterceptor

I am currently working on a Spring Web services(SOAP) project. The requirement is to validate the request payload and return the error response if validation fails and log it. I have extended PayloadValidatingInterceptor to return custom validation message.
As part of logging requirement, we need to print the header values from Request Headers (HttpServletRequest) for tracking purpose.
How to access HttpServletRequest in the implementation of PayloadValidatingInterceptor?
Is it possible to inject HttpServletRequest?
version details:
Spring-Boot : 2.2.6
Spring-ws-core : 3.0.8
Please help.

Consume SOAP Web services from spring with security header

I'm getting deprecated message for the bean Wss4jSecurityInterceptor. I'm using >spring-boot-starter-ws(1.4.7-RELEASE). spring-ws-security(2.4.4-RELEASE), org.apache.ws.security wss4j (1.6.9).
How to add the username token to consume SOAP services using Spring WebService Template ?
Sorry..Silly error..Need to upgrade to "org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor;"...wss4j2 instead of wss4j.
However still Null pointer exception " Received Fault message for request Exception=null.
Settled. The application message exception object isn't extracted properly from the SoapFaultClientException.. e.getSoapFault().getFaultDetail()

How to send POST requests to a Spring Boot REST API using Postman form-data?

I'm trying a very simple Spring Boot + MySql app using STS: https://github.com/acenelio/person01
Posting a new Person using raw body works fine. However, when trying to post using form-data, I get either a 400 HttpMessageNotReadableException or 415 HttpMediaTypeNotSupportedException error, depending on which Content-type I set on Headers.
I provided some Postman printscreens here: https://sites.google.com/site/stackoverflownelioalves/arqs
What am I missing? I'm kinda new on Postman and Spring Boot. Thanks.
You can use the #RequestBody annotation:
#RequestMapping("/addInvestorProfile")
public #ResponseBody Boolean addInvestorProfile(#RequestBody() InvestorProfile profile
, #RequestParam(value = "sessionId") String sessionId)
{
.... your content
return true;
}
I am not sure which version of your spring boot. First of all, almost all spring mvc or spring boot controller method will accept all request content-type when you are not add consumer param to #RequestMapping annotation. So, maybe there is some wrong usage of postman.And I am work with spring boot & postman well.
try to compare postman behavior by copy request to curl
Usually post a request use curl looks like:
curl -XPOST UrlOfYourSpringBootEndPoint -d'body of your post'
more detail of curl here.

How to validate header parameters while calling REST services in spring mvc?

I want to validate header parameters that I am going to send while calling REST of spring MVC. The validating class should return JSon object depending on result of validation. how can I do that?

Resources