使用带有 Soap v1.2 而不是默认 v1.1 的 spring-ws 生成 SOAP 网络服务 [英] Producing SOAP webservices with spring-ws with Soap v1.2 instead of the default v1.1

查看:20
本文介绍了使用带有 Soap v1.2 而不是默认 v1.1 的 spring-ws 生成 SOAP 网络服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从事 Spring soap 服务器项目.我从 Spring 的入门指南开始,这里 http://spring.io/guides/gs/production-web-service/ 以构建基本的 SOAP 服务.

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

默认的 SOAP 协议是 SOAP v1.1.有没有办法可以通过注释将协议设置为 v1.2?

The default SOAP protocol is SOAP v1.1. Is there a way I could set the protocol to v1.2, possibly via annotations?

我在 @Endpoint 类上尝试了 @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) 注释,但它似乎不起作用.

I tried @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) annotation on the @Endpoint class but it doesnt seem to work.

我也尝试过 @Endpoint(value = SOAPBinding.SOAP12HTTP_BINDING) 来设置它,但这在启动日志中也不起作用

I also tried @Endpoint(value = SOAPBinding.SOAP12HTTP_BINDING) to set it, but this doesnt work either as seen in the logs on startup

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

当然,如果我向服务器发送 SOAP 请求,我会收到以下错误

Ofcourse, if I post 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] 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)

感谢任何帮助.

谢谢!

推荐答案

您将 Spring-WS 与 JAX-WS(包 javax.xml.ws)的注解混合在一起.那行不通.要将 Spring-WS 配置为使用 SOAP 1.2,请添加以下 bean 定义:

You are mixing Spring-WS with annotations from JAX-WS (package javax.xml.ws). That won't 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;
}

这篇关于使用带有 Soap v1.2 而不是默认 v1.1 的 spring-ws 生成 SOAP 网络服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆