I am trying to make a simple SOAP request but I am getting this error:
org.springframework.ws.soap.client.SoapFaultClientException: Unable to handle request without a valid action parameter. Please supply a valid soap action.
I am using soap12
. Here is my code:
MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory(msgFactory);
WebServiceTemplate webServiceTemplate = new WebServiceTemplate(saajSoapMessageFactory);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan("packageName");
marshaller.afterPropertiesSet();
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.afterPropertiesSet();
Object response = webServiceTemplate.marshalSendAndReceive("https://www.w3schools.com/xml/tempconvert.asmx", temperature);
I tried setting Content-Type
with WebServiceMessageCallback
to text/xml but it didn't get overriden.
I found a solution by adding:
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory(messageFactory);
saajSoapMessageFactory.setSoapVersion(SoapVersion.SOAP_12);
saajSoapMessageFactory.afterPropertiesSet();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.