private void mustUnderstand(List<Header> headers, QName name) { Header header = getHeader(headers, name); if (header == null) { return; } if (header instanceof SoapHeader) { SoapHeader soapHeader = (SoapHeader) header; soapHeader.setMustUnderstand(true); return; } headers.remove(header); SoapHeader newHeader = new SoapHeader(name, header.getObject()); newHeader.setMustUnderstand(true); headers.add(newHeader); } }
protected Header findSecurityHeader(SoapMessage message, boolean create) { for (Header h : message.getHeaders()) { QName n = h.getName(); if ("Security".equals(n.getLocalPart()) && (n.getNamespaceURI().equals(WSS4JConstants.WSSE_NS) || n.getNamespaceURI().equals(WSS4JConstants.WSSE11_NS))) { return h; } } if (!create) { return null; } Document doc = DOMUtils.getEmptyDocument(); Element el = doc.createElementNS(WSS4JConstants.WSSE_NS, "wsse:Security"); el.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsse", WSS4JConstants.WSSE_NS); SoapHeader sh = new SoapHeader(new QName(WSS4JConstants.WSSE_NS, "Security"), el); sh.setMustUnderstand(true); message.getHeaders().add(sh); return sh; }
protected Header findSecurityHeader(SoapMessage message, boolean create) { for (Header h : message.getHeaders()) { QName n = h.getName(); if ("Security".equals(n.getLocalPart()) && (n.getNamespaceURI().equals(WSS4JConstants.WSSE_NS) || n.getNamespaceURI().equals(WSS4JConstants.WSSE11_NS))) { return h; } } if (!create) { return null; } Document doc = DOMUtils.getEmptyDocument(); Element el = doc.createElementNS(WSS4JConstants.WSSE_NS, "wsse:Security"); el.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsse", WSS4JConstants.WSSE_NS); SoapHeader sh = new SoapHeader(new QName(WSS4JConstants.WSSE_NS, "Security"), el); sh.setMustUnderstand(true); message.getHeaders().add(sh); return sh; }
/** * Encodes an MAP as a SOAP header. * * @param message the message to store the headers on * @param value the value to encode * @param qname the QName for the header * @param clz the class * @param header the SOAP header element * @param marshaller the JAXB context to use */ protected <T> void encodeMAP(SoapMessage message, T value, QName qname, Class<T> clz, JAXBContext ctx, boolean mustUnderstand) throws JAXBException { JAXBDataBinding jaxbDataBinding = new JAXBDataBinding(ctx); SoapHeader h = new SoapHeader(qname, new JAXBElement<T>(qname, clz, value), jaxbDataBinding); h.setMustUnderstand(mustUnderstand); message.getHeaders().add(h); }
/** * Encodes an MAP as a SOAP header. * * @param message the message to store the headers on * @param value the value to encode * @param qname the QName for the header * @param clz the class * @param header the SOAP header element * @param marshaller the JAXB context to use */ protected <T> void encodeMAP(SoapMessage message, T value, QName qname, Class<T> clz, JAXBContext ctx, boolean mustUnderstand) throws JAXBException { JAXBDataBinding jaxbDataBinding = new JAXBDataBinding(ctx); SoapHeader h = new SoapHeader(qname, new JAXBElement<T>(qname, clz, value), jaxbDataBinding); h.setMustUnderstand(mustUnderstand); message.getHeaders().add(h); }
shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu)); Header oldHdr = message.getHeader( new QName(elem.getNamespaceURI(), elem.getLocalName()));
shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu)); Header oldHdr = message.getHeader( new QName(elem.getNamespaceURI(), elem.getLocalName()));
private void addOutOfBoundHeader(PutLastTradedPricePortType portType, boolean invalid, boolean mu) { InvocationHandler handler = Proxy.getInvocationHandler(portType); BindingProvider bp = null; try { if (handler instanceof BindingProvider) { bp = (BindingProvider)handler; Map<String, Object> requestContext = bp.getRequestContext(); OutofBandHeader ob = new OutofBandHeader(); ob.setName("testOobHeader"); ob.setValue("testOobHeaderValue"); ob.setHdrAttribute(invalid ? "dontProcess" : "testHdrAttribute"); SoapHeader hdr = new SoapHeader( new QName(TEST_HDR_NS, TEST_HDR_REQUEST_ELEM), ob, new JAXBDataBinding(ob.getClass())); hdr.setMustUnderstand(mu); List<Header> holder = new ArrayList<>(); holder.add(hdr); //Add List of headerHolders to requestContext. requestContext.put(Header.HEADER_LIST, holder); } } catch (JAXBException ex) { //System.out.println("failed to insert header into request context :" + ex); } }
shead.setActor(act); shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
shead.setActor(act); shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));