我目前正在从事 Spring soap 服务器项目。我从 Spring 的入门指南http://spring.io/guides/gs/produce-web-service/开始构建一个基本的 SOAP 服务。
默认的 SOAP 协议是 SOAP v1.1。有没有办法可以通过注释将协议设置为 v1.2?
我在课堂上尝试@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
了注释,@Endpoint
但它似乎不起作用。
我也尝试@Endpoint(value = SOAPBinding.SOAP12HTTP_BINDING)
设置它,但这也不起作用,如启动日志中所示
INFO --- [nio-8080-exec-1] o.s.ws.soap.saaj.SaajSoapMessageFactory :
Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
当然,如果我向服务器发布 SOAP 请求,我会收到以下错误
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] a.c.c.C.[.[.[.[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)
任何帮助表示赞赏。
谢谢!