Я новичок в адресации Soap, и мне нужно использовать wsa-адресацию с Apache cxf + camel.
Это конечная точка службы, созданная apache cxf из wsdl
@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 это значение пространства имен для wsa в soap2: Header
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 не разрешен», и моя функциональность не работает.
Ошибка трассировки стека в логах
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
Я пробовал ниже вещей
Изменение значения пространства имен для wsa в soap2: заголовок, как показано ниже, и
его работа.
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
- Изменение ответа на значение адреса, как показано ниже, и оно работает.
http://www.w3.org/2005/08/addressing/anonymous
- Удаление заголовка ReplyTo работает
Но я не могу сделать все это, поскольку запрос поступает от третьей стороны.
Я попытался отредактировать (удалить заголовок replyto / обновить значение узла адреса в ответе на заголовок) заголовки мыла в запросе, поместив перехватчик в фазу PRE_LOGICAL, но это не сработало
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>