当前位置: 首页 > 知识库问答 >
问题:

Apache cxf soap匿名寻址

呼延骏俊
2023-03-14

我是Soap寻址的新手,我必须在Apache cxf camel中使用wsa寻址。

这是apache cxf从wsdl创建的服务endpoint

@WebMethod(operationName = "Inventory_SubmitResult", action = "http://htng.org/PWSWG/2010/12/Inventory_SubmitResult")
@Action(input = "http://htng.org/PWSWG/2010/12/Inventory_SubmitResult", output = "http://htng.org/PWSWG/2010/12/Inventory_SubmitResultResponse")
public void inventorySubmitResult(
    @WebParam(partName = "OTA_HotelInvCountNotifRS", mode = WebParam.Mode.INOUT, name = "OTA_HotelInvCountNotifRS", targetNamespace = "http://www.opentravel.org/OTA/2003/05")
    javax.xml.ws.Holder<OTAHotelInvCountNotifRS> otaHotelInvCountNotifRS
);

服务请求时出现问题,在soap请求中,这是soap2:Header中wsa的命名空间值

xmlns:wsa="http://www.w3.org/2005/08/addressing" 

我面临的问题是,传入请求中的ReplyTo标头的值低于

 <wsa:ReplyTo>
            <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
 </wsa:ReplyTo>

然后,cxf侦听器尝试回调上述地址,但由于“405 Method not allowed”而失败,我的功能无法工作。

日志中的错误堆栈跟踪

2018-10-30 22:13:35,720  WARN org.apache.cxf.phase.PhaseInterceptorChain:475 - 5bd939df4b105100018a9fcc@:int - [Path:/integration-service/synxis/tenants/101/properties/103] -[Tenant Id: 101] -[Property Id: 103] - Interceptor for {http://synxis.com/Ota2010a/}IOta2010AService#{http://synxis.com/Ota2010a/}Inventory_SubmitResult has thrown exception, unwinding noworg.apache.cxf.interceptor.Fault: Could not send Message.\n        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:67) ~[cxf-core-3.2.5.jar:3.2.5]\n  at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.2.5.jar:3.2.5]\n       at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:90) [cxf-core-3.2.5.jar:3.2.5]\n     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.2.5.jar:3.2.5]\n       at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:278) [cxf-core-3.2.5.jar:3.2.5]\n       at org.apache.cxf.ws.addressing.impl.InternalContextUtils$1.run(InternalContextUtils.java:319) [cxf-rt-ws-addr-3.2.5.jar:3.2.5]\n    at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:421) [cxf-core-3.2.5.jar:3.2.5]\n  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_112]\n        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_112]\n  at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:346) [cxf-core-3.2.5.jar:3.2.5]\n      at java.lang.Thread.run(Unknown Source) [na:1.8.0_112]\nCaused by: org.apache.cxf.transport.http.HTTPException: HTTP response '405: Method Not Allowed' when communicating with http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous\n    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1620) ~[cxf-rt-transports-http-3.2.5.jar:3.2.5]\n       at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1627) ~[cxf-rt-transports-http-3.2.5.jar:3.2.5]\n   at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1572) ~[cxf-rt-transports-http-3.2.5.jar:3.2.5]\n   at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1373) ~[cxf-rt-transports-http-3.2.5.jar:3.2.5]\n       at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56) ~[cxf-core-3.2.5.jar:3.2.5]\n    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:225) ~[cxf-core-3.2.5.jar:3.2.5]\n        at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56) ~[cxf-core-3.2.5.jar:3.2.5]\n    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:225) ~[cxf-core-3.2.5.jar:3.2.5]\n        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) ~[cxf-core-3.2.5.jar:3.2.5]\n     at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:673) ~[cxf-rt-transports-http-3.2.5.jar:3.2.5]\n    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63) ~[cxf-core-3.2.5.jar:3.2.5]\n  ... 10 common frames omitted\n

我试过下面的东西

>

xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 

http://www.w3.org/2005/08/addressing/anonymous

但我不能做所有这些,因为请求来自第三方。

我尝试在请求中编辑(删除replyto标头/更新replyto标头中的地址节点值)soap标头,方法是将拦截器置于PRE\u逻辑阶段,但没有成功

   public class WsaHeaderInterceptor extends AbstractSoapInterceptor {

    public WsaHeaderInterceptor(String replyToUrlTemplate, MessageType messageType) {
        super(Phase.PRE_LOGICAL);
    }

    @Override
    public void handleMessage(SoapMessage message) throws Fault {
        //hard-coded for debugging
        Header header = message.getHeaders().remove(1);

                ((Element) (header.getObject())).getFirstChild().getNextSibling().getFirstChild()
                      .setNodeValue("" + "http://www.w3.org/2005/08/addressing/anonymous");

                ((Element) (header.getObject())).getFirstChild().getNextSibling().getFirstChild()
                     .setTextContent("" + "http://www.w3.org/2005/08/addressing/anonymous");

    }
}

在这件事上花了几天时间,但无法修复,任何线索或指针都会很有帮助。

WSDL 文件

    <?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://synxis.com/Ota2010a/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="OTA2010A" targetNamespace="http://synxis.com/Ota2010a/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsp:Policy wsu:Id="ota2010AEndpoint_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <wsaw:UsingAddressing />
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xs:schema xmlns:tns="http://www.opentravel.org/OTA/2003/05" elementFormDefault="qualified" targetNamespace="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!--removed types -->
  </wsdl:types>

  <wsdl:message name="InvCountDeliveryResponse">
    <wsdl:part xmlns:q1="http://www.opentravel.org/OTA/2003/05" name="OTA_HotelInvCountNotifRS"
            element="q1:OTA_HotelInvCountNotifRS" />
  </wsdl:message>
  <wsdl:message name="InvCountDeliveryResponse_Headers">
    <wsdl:part xmlns:q2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" name="Security" element="q2:Security" />
    <wsdl:part xmlns:q3="http://htng.org/1.3/Header/" name="TimeStamp" element="q3:TimeStamp" />
    <wsdl:part xmlns:q4="http://htng.org/PWSWG/2007/02/AsyncHeaders" name="CorrelationID" element="q4:CorrelationID" />
    <wsdl:part xmlns:q5="http://htng.org/PWSWG/2007/02/AsyncHeaders" name="RelatesToCorrelationID" element="q5:RelatesToCorrelationID" />
    <wsdl:part xmlns:q6="http://htng.org/PWSWG/2007/02/AsyncHeaders" name="ReplyTo" element="q6:ReplyTo" />
  </wsdl:message>

  <wsdl:message name="InventoryCountResponse">
    <wsdl:part xmlns:q7="http://www.opentravel.org/OTA/2003/05" name="OTA_HotelInvCountNotifRS" element="q7:OTA_HotelInvCountNotifRS" />
  </wsdl:message>
  <wsdl:message name="InventoryCountResponse_Headers">
    <wsdl:part xmlns:q8="http://htng.org/1.3/Header/" name="TimeStamp" element="q8:TimeStamp" />
  </wsdl:message>

  <wsdl:portType name="IOta2010A">
    <!-- Adding Inbound for Async Response starts here -->
    <wsdl:operation name="Inventory_SubmitResult">
      <wsdl:input wsaw:Action="http://htng.org/PWSWG/2010/12/Inventory_SubmitResult" name="InvCountDeliveryResponse" message="tns:InvCountDeliveryResponse" />
      <wsdl:output wsaw:Action="http://htng.org/PWSWG/2010/12/Inventory_SubmitResultResponse" name="InventoryCountResponse" message="tns:InventoryCountResponse" />
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="ota2010AEndpoint" type="tns:IOta2010A">
    <wsp:PolicyReference URI="#ota2010AEndpoint_policy" />
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Inventory_SubmitResult" >
      <soap12:operation soapAction="http://htng.org/PWSWG/2010/12/Inventory_SubmitResult" style="document" />
      <wsdl:input name="InvCountDeliveryResponse">
        <soap12:header message="tns:InvCountDeliveryResponse_Headers" part="Security" use="literal" />
        <soap12:header message="tns:InvCountDeliveryResponse_Headers" part="TimeStamp" use="literal" />
        <soap12:header message="tns:InvCountDeliveryResponse_Headers" part="RelatesToCorrelationID" use="literal" />
        <soap12:header message="tns:InvCountDeliveryResponse_Headers" part="ReplyTo" use="literal" />
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output name="InventoryCountResponse">
        <soap12:header message="tns:InventoryCountResponse_Headers" part="TimeStamp" use="literal" />
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="OTA2010A">
      <wsdl:port name="ota2010AEndpoint" binding="tns:ota2010AEndpoint">
         <soap12:address location="https://integcert.synxis.com/Interface/ota2010av2/OTA2010A.svc"/>
         <wsa10:EndpointReference>
            <wsa10:Address>https://integcert.synxis.com/Interface/ota2010av2/OTA2010A.svc</wsa10:Address>
         </wsa10:EndpointReference>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

共有1个答案

易招
2023-03-14

这并不能真正回答问题,但希望这些信息能有用:

因此请求者使用<代码>http://www.w3.org/2005/08/addressing命名空间,然后指定http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousURI?

schemas.xmlsoap.org命名空间用于SOAP 1.1。而www.w3.org"命名空间用于SOAP 1.2。

然而,SOAP 1.2规范指出,SOAP 1.2应该向后兼容。

WS寻址符合SOAP 1.2消息传递框架处理模型,并且还与SOAP 1.1兼容以实现向后兼容性。

以下是关于SOAP 1.2匿名寻址的规范

它看起来确实像<代码>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous在CXF中通过组织识别URI。阿帕奇。cxf。ws。寻址。版本转换器类。

请求中的寻址似乎应该是有效的,并且应该被CXF理解。

 类似资料:
  • 一个元素可以按照HTML元素的嵌套方式包含其他元素,大多数情况下,框都是由显式定义的元素所生成的。 然而,当把文本直接添加到一个块容器元素中(不是包含在行内元素)时,即便没有为这些文本显式定义元素,它们也会生成框。 没有被元素显式包含的文本,称作匿名文本,因为没有与之关联的元素。把匿名文本所生成框,称作匿名框。匿名框分为两种,一种是匿名块框,另一种是匿名行内框。 当把文本直接添加到一个块容器元素中

  • 匿名类是指没有类名的内部类,必须在创建时使用 new 语句来声明类。其语法形式如下: 这种形式的 new 语句声明一个新的匿名类,它对一个给定的类进行扩展,或者实现一个给定的接口。使用匿名类可使代码更加简洁、紧凑,模块化程度更高。 匿名类有两种实现方式: 继承一个类,重写其方法。 实现一个接口(可以是多个),实现其方法。 下面通过代码来说明。 程序的输出结果如下: 从输出结果可以看出,匿名内部类有

  • 5.6. 匿名函数 拥有函数名的函数只能在包级语法块中被声明,通过函数字面量(function literal),我们可绕过这一限制,在任何表达式中表示一个函数值。函数字面量的语法和函数声明相似,区别在于func关键字后没有函数名。函数值字面量是一种表达式,它的值被成为匿名函数(anonymous function)。 函数字面量允许我们在使用函数时,再定义它。通过这种技巧,我们可以改写之前对st

  • 有没有想过定义一个很短的回调函数,但又不想用 def 的形式去写一个那么长的函数,那么有没有快捷方式呢? 答案是有的。 python 使用 lambda 来创建匿名函数,也就是不再使用 def 语句这样标准的形式定义一个函数。 匿名函数主要有以下特点: lambda 只是一个表达式,函数体比 def 简单很多。 lambda 的主体是一个表达式,而不是一个代码块。仅仅能在 lambda 表达式中封

  • 当我们在传入函数时,有些时候,不需要显式地定义函数,直接传入匿名函数更方便。 在Python中,对匿名函数提供了有限支持。还是以map()函数为例,计算f(x)=x2时,除了定义一个f(x)的函数外,还可以直接传入匿名函数: >>> map(lambda x: x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9]) [1, 4, 9, 16, 25, 36, 49, 64, 81]

  • 当我们在传入函数时,有些时候,不需要显式地定义函数,直接传入匿名函数更方便。 在Python中,对匿名函数提供了有限支持。还是以map()函数为例,计算f(x)=x2时,除了定义一个f(x)的函数外,还可以直接传入匿名函数: >>> list(map(lambda x: x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9])) [1, 4, 9, 16, 25, 36, 49, 6