【问题标题】:Content-Type of soap call using spring-integration使用spring-integration的soap调用的Content-Type
【发布时间】:2017-08-17 07:03:53
【问题描述】:

我正在尝试使用 spring-integration 执行一个肥皂调用。 WSDL 是soap 1.2。

我的弹簧配置:

<int:channel id="inputChannel" />

<int:channel id="outputChannel" />

<int:header-enricher input-channel="inputChannel" output-channel="outputChannel">               
    <int:header name="#{T(org.springframework.http.HttpHeaders).CONTENT_TYPE}" value="text/xml" />
</int:header-enricher>

<bean id="eduflexWsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"
    p:marshaller-ref="eduflexMarshaller" 
    p:unmarshaller-ref="eduflexMarshaller" 
    p:defaultUri="http://srv-nl-edu65/wsParalax/"
    p:messageFactory-ref="soap12MessageFactory"
/>  

<bean id="soap12MessageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="soapVersion">
        <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/>
    </property>
</bean>

Java 代码:

MyRequestXml request = new MyRequestXml();
    //construct request

    MyResponse response = (MyResponse) m_template.marshalSendAndReceive(request, new WebServiceMessageCallback() {

        public void doWithMessage(WebServiceMessage message) {
            SoapMessage soapMessage = (SoapMessage) message;
            soapMessage.setSoapAction("soapAction");
        }
    });

最初,soap 动作没有设置,我得到了错误,所以我通过使用 WebServiceMessageCallback 修复了这个问题。

但现在我收到有关内容类型的错误:

org.springframework.ws.client.WebServiceTransportException: Unsupported Media Type [415]

我正在尝试使用 spring 集成 header-enricher 覆盖它,但在 wireshark 中我看到 header content-type 仍然是 Multipart/Related。

所以我的问题是如何强制 spring 集成将内容类型设置为 text/xml?强制soap到1.2版似乎也没有效果。

【问题讨论】:

  • 问题是:为什么不使用 Spring Integration WS Channel Adapters:docs.spring.io/spring-integration/reference/html/ws.html?这样您就不需要手动设置Content-Type。而且您在问题中的代码不清楚。我们看到&lt;header-enricher&gt;,但不清楚谁订阅了outputChannel...

标签: http soap http-headers spring-integration content-type


【解决方案1】:

我发现了我的问题,我有一个将 mtomEnabled 设置为 true 的 Jaxb2Marshaller。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 2021-05-29
    • 1970-01-01
    • 2019-04-15
    • 2011-04-24
    • 2012-01-21
    相关资源
    最近更新 更多