private static void updateSoap12FaultCodes(SoapFault f) { //per Soap 1.2 spec, the fault code MUST be one of the 5 values specified in the spec. //Soap 1.1 allows the soap fault code to be arbitrary (recommends the 4 values in the spec, but //explicitely mentions that it can be extended to include additional codes). Soap 1.2 however //requires the use of one of the 5 defined codes. Additional detail or more specific information //can be transferred via the SubCodes. QName fc = f.getFaultCode(); SoapVersion v = Soap12.getInstance(); if (fc.getNamespaceURI().equals(Soap12.SOAP_NAMESPACE) && (fc.equals(v.getReceiver()) || fc.equals(v.getSender()) || fc.equals(v.getMustUnderstand()) || fc.equals(v.getDateEncodingUnknown()) || fc.equals(v.getVersionMismatch()))) { //valid fault codes, don't change anything return; } f.setFaultCode(Soap12.getInstance().getReceiver()); if (f.getSubCodes() == null) { f.setRootSubCode(fc); } else if (!f.getSubCodes().contains(fc)) { f.getSubCodes().add(fc); } } public static SoapFault createFault(Fault f, SoapVersion v) {
private static void updateSoap12FaultCodes(SoapFault f) { //per Soap 1.2 spec, the fault code MUST be one of the 5 values specified in the spec. //Soap 1.1 allows the soap fault code to be arbitrary (recommends the 4 values in the spec, but //explicitely mentions that it can be extended to include additional codes). Soap 1.2 however //requires the use of one of the 5 defined codes. Additional detail or more specific information //can be transferred via the SubCodes. QName fc = f.getFaultCode(); SoapVersion v = Soap12.getInstance(); if (fc.getNamespaceURI().equals(Soap12.SOAP_NAMESPACE) && (fc.equals(v.getReceiver()) || fc.equals(v.getSender()) || fc.equals(v.getMustUnderstand()) || fc.equals(v.getDateEncodingUnknown()) || fc.equals(v.getVersionMismatch()))) { //valid fault codes, don't change anything return; } f.setFaultCode(Soap12.getInstance().getReceiver()); if (f.getSubCodes() == null) { f.setRootSubCode(fc); } else if (!f.getSubCodes().contains(fc)) { f.getSubCodes().add(fc); } } public static SoapFault createFault(Fault f, SoapVersion v) {
public void handleMessage(SoapMessage soapMessage) { Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage); if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) { return; } SoapVersion soapVersion = soapMessage.getVersion(); Set<Header> mustUnderstandHeaders = new HashSet<>(); Set<URI> serviceRoles = new HashSet<>(); Set<QName> notUnderstandHeaders = new HashSet<>(); Set<Header> ultimateReceiverHeaders = new HashSet<>(); Set<QName> mustUnderstandQNames = new HashSet<>(); initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles, paramHeaders); buildMustUnderstandHeaders(mustUnderstandHeaders, soapMessage, serviceRoles, ultimateReceiverHeaders); checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames, notUnderstandHeaders); if (!notUnderstandHeaders.isEmpty()) { if (!isRequestor(soapMessage)) { soapMessage.put(MustUnderstandInterceptor.UNKNOWNS, notUnderstandHeaders); soapMessage.getInterceptorChain().add(ending); } else { throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders), soapVersion.getMustUnderstand()); } } if (!ultimateReceiverHeaders.isEmpty() && !isRequestor(soapMessage)) { checkUltimateReceiverHeaders(ultimateReceiverHeaders, mustUnderstandQNames, soapMessage); } } @Override
public void handleMessage(SoapMessage message) throws Fault { // throws soapFault after the response code 202 is set in OneWayProcessorInterceptor if (message.get(MustUnderstandInterceptor.UNKNOWNS) != null) { //we may not have known the Operation in the main interceptor and thus may not //have been able to get the parameter based headers. We now know the //operation and thus can remove those. Set<QName> unknowns = CastUtils.cast((Set<?>)message.get(MustUnderstandInterceptor.UNKNOWNS)); Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(message); unknowns.removeAll(paramHeaders); message.remove(MustUnderstandInterceptor.UNKNOWNS); if (!unknowns.isEmpty()) { throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, unknowns), message.getVersion().getMustUnderstand()); } } } }
public void handleMessage(SoapMessage soapMessage) { Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage); if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) { return; } SoapVersion soapVersion = soapMessage.getVersion(); Set<Header> mustUnderstandHeaders = new HashSet<>(); Set<URI> serviceRoles = new HashSet<>(); Set<QName> notUnderstandHeaders = new HashSet<>(); Set<Header> ultimateReceiverHeaders = new HashSet<>(); Set<QName> mustUnderstandQNames = new HashSet<>(); initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles, paramHeaders); buildMustUnderstandHeaders(mustUnderstandHeaders, soapMessage, serviceRoles, ultimateReceiverHeaders); checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames, notUnderstandHeaders); if (!notUnderstandHeaders.isEmpty()) { if (!isRequestor(soapMessage)) { soapMessage.put(MustUnderstandInterceptor.UNKNOWNS, notUnderstandHeaders); soapMessage.getInterceptorChain().add(ending); } else { throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders), soapVersion.getMustUnderstand()); } } if (!ultimateReceiverHeaders.isEmpty() && !isRequestor(soapMessage)) { checkUltimateReceiverHeaders(ultimateReceiverHeaders, mustUnderstandQNames, soapMessage); } } @Override
public void handleMessage(SoapMessage soapMessage) throws Fault { SoapVersion soapVersion = soapMessage.getVersion(); Set<QName> notFound = new HashSet<>(); List<Header> heads = soapMessage.getHeaders(); for (Header header : heads) { if (header instanceof SoapHeader && ((SoapHeader)header).isMustUnderstand() && header.getDirection() == Header.Direction.DIRECTION_IN && !knownHeaders.contains(header.getName()) && (StringUtils.isEmpty(((SoapHeader)header).getActor()) || soapVersion.getUltimateReceiverRole() .equals(((SoapHeader)header).getActor()))) { notFound.add(header.getName()); } } if (!notFound.isEmpty()) { soapMessage.remove(UNKNOWNS); throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notFound), soapVersion.getMustUnderstand()); } }
@Override public void handleFault(SoapMessage msg) { Set<QName> unknowns = CastUtils.cast((Set<?>)msg.get(MustUnderstandInterceptor.UNKNOWNS)); if (msg.getExchange().getBindingOperationInfo() == null && unknowns != null && !unknowns.isEmpty()) { //per jaxws spec, if there are must understands that we didn't understand, but couldn't map //to an operation either, we need to throw the mustunderstand fault, not the one related to //an unknown operation msg.setContent(Exception.class, new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, unknowns), msg.getVersion().getMustUnderstand())); } }
public void handleMessage(SoapMessage message) throws Fault { // throws soapFault after the response code 202 is set in OneWayProcessorInterceptor if (message.get(MustUnderstandInterceptor.UNKNOWNS) != null) { //we may not have known the Operation in the main interceptor and thus may not //have been able to get the parameter based headers. We now know the //operation and thus can remove those. Set<QName> unknowns = CastUtils.cast((Set<?>)message.get(MustUnderstandInterceptor.UNKNOWNS)); Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(message); unknowns.removeAll(paramHeaders); message.remove(MustUnderstandInterceptor.UNKNOWNS); if (!unknowns.isEmpty()) { throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, unknowns), message.getVersion().getMustUnderstand()); } } } }
@Override public void handleFault(SoapMessage msg) { Set<QName> unknowns = CastUtils.cast((Set<?>)msg.get(MustUnderstandInterceptor.UNKNOWNS)); if (msg.getExchange().getBindingOperationInfo() == null && unknowns != null && !unknowns.isEmpty()) { //per jaxws spec, if there are must understands that we didn't understand, but couldn't map //to an operation either, we need to throw the mustunderstand fault, not the one related to //an unknown operation msg.setContent(Exception.class, new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, unknowns), msg.getVersion().getMustUnderstand())); } }
public void handleMessage(SoapMessage soapMessage) throws Fault { SoapVersion soapVersion = soapMessage.getVersion(); Set<QName> notFound = new HashSet<>(); List<Header> heads = soapMessage.getHeaders(); for (Header header : heads) { if (header instanceof SoapHeader && ((SoapHeader)header).isMustUnderstand() && header.getDirection() == Header.Direction.DIRECTION_IN && !knownHeaders.contains(header.getName()) && (StringUtils.isEmpty(((SoapHeader)header).getActor()) || soapVersion.getUltimateReceiverRole() .equals(((SoapHeader)header).getActor()))) { notFound.add(header.getName()); } } if (!notFound.isEmpty()) { soapMessage.remove(UNKNOWNS); throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notFound), soapVersion.getMustUnderstand()); } }