Creating SOAP web services using spring-ws using Soap v1.2 instead of standard v1.1

I am currently working on a Spring soap server project. I started with the Getting Started guide from Spring here http://spring.io/guides/gs/producing-web-service/ to create a basic SOAP service.

The default SOAP protocol is SOAP v1.1. Is there a way to install the protocol on v1.2, perhaps through annotations?

I tried the @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) annotation @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) in the @Endpoint class but it doesn't seem to work.

I also tried @Endpoint(value = SOAPBinding.SOAP12HTTP_BINDING) set it, but this does not work either in the logs at startup

 INFO --- [nio-8080-exec-1] osws.soap.saaj.SaajSoapMessageFactory : Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol 

Of course, if I send a SOAP request to the server, I get the following error

 2015-01-19 15:50:17.610 ERROR 20172 --- [nio-8080-exec-1] c.sun.xml.internal.messaging.saaj.soap : SAAJ0533: Cannot create message: incorrect content-type for SOAP version. Got application/soap+xml; charset=utf-8, but expected text/xml 2015-01-19 15:50:17.611 ERROR 20172 --- [nio-8080-exec-1] c.sun.xml.internal.messaging.saaj.soap : SAAJ0535: Unable to internalize message 2015-01-19 15:50:17.617 ERROR 20172 --- [nio-8080-exec-1] accC[.[.[.[messageDispatcherServlet] : Servlet.service() for servlet [messageDispatcherServlet] in context with path [] threw exception [R equest processing failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Unable to internalize message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message] with root cause com.sun.xml.internal.messaging.saaj.soap.SOAPVersionMismatchException: Cannot create message: incorrect content-type for SOAP version. Got: application/soap+xml; charset=utf-8 Expected: text/xml at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(Unknown Source) at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(Unknown Source) at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Unknown Source) at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(Unknown Source) 

Any help is appreciated.

Thanks!

+5
source share
1 answer

You mix Spring -WS with annotations from JAX-WS ( javax.xml.ws package). This will not work. To configure Spring -WS to use SOAP 1.2, add the following bean definition:

 @Bean public SaajSoapMessageFactory messageFactory() { SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(); messageFactory.setSoapVersion(SoapVersion.SOAP_12); return messageFactory; } 
+19
source

Source: https://habr.com/ru/post/1211446/


All Articles