【问题标题】:Spring-ws apache Camel with soap version 1.2带有肥皂版本 1.2 的 Spring-ws apache Camel
【发布时间】:2018-07-18 21:37:13
【问题描述】:

我正在使用默认支持soap 1.1 的spring-ws apache camel。但是我想发布一个将它绑定到soap 1.2的请求,因为我的端点服务只支持soap 1.2。我尝试在 applicationContext.xml 中设置 messageFactory,如下所示

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

然后将其添加到 RouteBuilder 中,例如, .to("spring-ws:https://"+url+"?soapAction=#xxx&wsAddressingAction=#xxx&messageFactory=#soapMessageFactory

但它不起作用。有没有其他方法可以在 spring-ws 组件中设置肥皂版本?我无权访问 Web 服务。

谢谢

【问题讨论】:

    标签: apache-camel spring-ws


    【解决方案1】:

    我遇到了类似的情况,并采取了稍微不同的方法来解决问题。我创建了一个自定义 WebServiceTemplate 并将我的消息工厂附加到它。然后我将 webServiceTemplate 指定为 RouteBuilder 中调用的一部分。代码如下:

    @Bean
    public WebServiceTemplate webServiceTemplate() throws Exception {
        final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        final SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(msgFactory);
        final WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory);
    
        return webServiceTemplate;
    }
    

    然后在我的路线上,我打了这样的电话:

        .toD("spring-ws:{{some.service.url}}?webServiceTemplate=#webServiceTemplate&wsAddressingAction=http://test.org/SomeService/SomeOperation")
    

    希望这会有所帮助。

    【讨论】:

    • 感谢您的回复。我尝试了上述方法,但它仍然对我不起作用。我收到以下异常,AxisEngine E org.apache.axis2.engine.AxisEngine 接收代表消息寻址属性的必需标头不存在 org.apache.axis2.AxisFault:代表消息寻址属性的必需标头不存在org.apache.axis2.addressing.AddressingFaultsHelper
    • 这与我在使用 messageFactory 时遇到的问题相同。端点服务可能需要其他属性标头吗?由于我无权访问网络服务,而且请求也没有记录在服务的任何地方,因此很难解决问题。
    • 您是否将 wsAddressingAction 设置为 spring-ws 调用的一部分?我发现了一个不同的线程,它谈到了禁用 WS-A 以消除您看到的错误消息。也许只是尝试使用没有 wsAddressingAction 的 webServiceTemplate 来查看是否有帮助。听起来您无权访问此服务,所以我假设您无法通过 SoapUI 调用它来查看成功的原始响应?如果可以,那么您就可以启动 spring 日志记录并将生成的请求与成功的请求进行比较。
    • 嗨,亚当,感谢您的回复。我确实尝试过不使用 wsAddressingAction,但这也不起作用,并且我得到了相同的寻址属性异常。当我不添加 webservicetemplate 并添加 wsAddressingAction 时,我在不兼容的 soap 版本上得到了 soapfault 错误。不确定 webservicetemplate 是否抑制了寻址属性,或者我的端点服务需要请求中的其他属性。我使用了弹簧日志,我可以看到标题和正文,但看不到信封。我假设信封在发送请求之前已被包装并且无法记录?
    • 您应该也能看到信封。请参阅此link。如果您还没有尝试过,您也可以采取一些措施来增加骆驼采伐量。在您的路线中,您可以在方法的开头执行getContext().setTracing(true) 以查看有关路线的更多详细信息。在 spring-ws 调用之前,您可以执行 .to("log:test?showAll=true") 以查看当前正文。在这三件事之间,我认为您将获得所需的大部分日志记录。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    相关资源
    最近更新 更多