@Override public void newToken(String token) { if (useSoapHeaderSessions) { for (PublicInterface p : getServiceInterfaces().values()) { List<Header> headers = new ArrayList<Header>(); try { Token tokenObject = new Token(token); Header sessionHeader = new Header(new QName("uri:org.bimserver.shared", "token"), tokenObject, new JAXBDataBinding(Token.class)); headers.add(sessionHeader); } catch (JAXBException e) { LOGGER.error("", e); } ((BindingProvider) p).getRequestContext().put(Header.HEADER_LIST, headers); } } }
@SuppressWarnings("unchecked") private List<Header> listSoapHeaders(Object soapHeadersObject) throws TransformerFactoryConfigurationError { if (null != soapHeadersObject) { if (soapHeadersObject instanceof org.dom4j.Document) { List<Header> soapHeaders = new ArrayList<Header>(); try { DOMResult result = new DOMResult(); TransformerFactory.newInstance().newTransformer() .transform(new org.dom4j.io.DocumentSource((org.dom4j.Document) soapHeadersObject), result); for (Node node = ((Document) result.getNode()).getDocumentElement() .getFirstChild(); node != null; node = node.getNextSibling()) { if (Node.ELEMENT_NODE == node.getNodeType()) { soapHeaders.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()), node)); } } } catch (Exception e) { LOG.log(Level.SEVERE, "Uncaught exception during SOAP headers transformation: ", e); } } else if (soapHeadersObject instanceof List) { return (List<Header>) soapHeadersObject; } } return null; }
@SuppressWarnings("unchecked") private List<Header> listSoapHeaders(Object soapHeadersObject) throws TransformerFactoryConfigurationError { if (null != soapHeadersObject) { if (soapHeadersObject instanceof org.dom4j.Document) { List<Header> soapHeaders = new ArrayList<Header>(); try { DOMResult result = new DOMResult(); TransformerFactory.newInstance().newTransformer() .transform(new org.dom4j.io.DocumentSource((org.dom4j.Document) soapHeadersObject), result); for (Node node = ((Document) result.getNode()).getDocumentElement() .getFirstChild(); node != null; node = node.getNextSibling()) { if (Node.ELEMENT_NODE == node.getNodeType()) { soapHeaders.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()), node)); } } } catch (Exception e) { LOG.log(Level.SEVERE, "Uncaught exception during SOAP headers transformation: ", e); } } else if (soapHeadersObject instanceof List) { return (List<Header>) soapHeadersObject; } } return null; }
private void addSoapHeader(Map<String, String> filteredParams, SoapMessage soapMessage) { try { final Header tpicHeader = new Header(TraceeConstants.SOAP_HEADER_QNAME, TpicMap.wrap(filteredParams), new JAXBDataBinding(TpicMap.class)); soapMessage.getHeaders().add(tpicHeader); } catch (JAXBException e) { LOGGER.warn("Error occured during TracEE soap header creation: {}", e.getMessage()); LOGGER.debug("Detailed exception", e); } }
/** * Builds an element containing a WS-RM Fault. This adds the appropriate WS-RM namespace declaration to * the element, and then adds the Fault as a child element. * * @param sf * @param qname constructed element name * @return element */ public Header buildHeaderFault(SequenceFault sf) throws JAXBException { Object o = buildHeaderFaultObject(sf); return new Header(new QName(getConstants().getWSRMNamespace(), RMConstants.SEQUENCE_FAULT_NAME), o, getDataBinding()); }
/** * Class constructor, Initializes a new instance of the class. * @param client The ETClient object * @param endpoint The endpoint URL * @param accessToken The access token * @throws com.exacttarget.fuelsdk.ETSdkException */ public ETSoapConnection(ETClient client, String endpoint, String accessToken) throws ETSdkException { this(client, endpoint); try { List<Header> headers = new ArrayList<Header>(); accessTokenElement = soapFactory.createElement(new QName(null, "fueloauth")); if (accessToken != null) { setAccessToken(accessToken); } headers.add(new Header(new QName(null, "fueloauth"), accessTokenElement)); soapClient.getRequestContext().put(Header.HEADER_LIST, headers); } catch (SOAPException ex) { throw new ETSdkException("could not initialize SOAP proxy", ex); } }
/** * Write flow id to message. * * @param message the message * @param flowId the flow id */ public static void writeFlowId(Message message, String flowId) { if (!(message instanceof SoapMessage)) { return; } SoapMessage soapMessage = (SoapMessage)message; Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME); if (hdFlowId != null) { LOG.warning("FlowId already existing in soap header, need not to write FlowId header."); return; } try { soapMessage.getHeaders().add( new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class))); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME); } } catch (JAXBException e) { LOG.log(Level.SEVERE, "Couldn't create flowId header.", e); } }
/** * Write flow id to message. * * @param message the message * @param flowId the flow id */ public static void writeFlowId(Message message, String flowId) { if (!(message instanceof SoapMessage)) { return; } SoapMessage soapMessage = (SoapMessage)message; Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME); if (hdFlowId != null) { LOG.warning("FlowId already existing in soap header, need not to write FlowId header."); return; } try { soapMessage.getHeaders().add( new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class))); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME); } } catch (JAXBException e) { LOG.log(Level.SEVERE, "Couldn't create flowId header.", e); } }
private static Header createHeader(QName headerName, String value) throws Fault { try { return new Header(headerName, value, new JAXBDataBinding(String.class)); } catch (JAXBException e) { throw new Fault(e); } }
Header holder = new Header(new QName(lastAdded.getNamespaceURI(), lastAdded.getLocalName()), lastAdded);
public void setBodyFieldsOnly(boolean bodyFieldsOnly) { this.bodyFieldsOnly = bodyFieldsOnly; searchPreferences.setBodyFieldsOnly(bodyFieldsOnly); Object searchPreferencesObject = createNativeSearchPreferences(searchPreferences); try { Header searchPreferencesHeader = new Header( new QName(getPlatformMessageNamespaceUri(), "searchPreferences"), searchPreferencesObject, new JAXBDataBinding(searchPreferencesObject.getClass())); setHeader(port, searchPreferencesHeader); } catch (JAXBException e) { throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e); } }
/** * Set preferences for given port. * * @param port port which to set preferences for * @param nsPreferences general preferences * @param nsSearchPreferences search preferences * @throws NetSuiteException if an error occurs during performing of operation */ protected void setPreferences(PortT port, NsPreferences nsPreferences, NsSearchPreferences nsSearchPreferences) throws NetSuiteException { Object searchPreferences = createNativeSearchPreferences(nsSearchPreferences); Object preferences = createNativePreferences(nsPreferences); try { Header searchPreferencesHeader = new Header( new QName(getPlatformMessageNamespaceUri(), "searchPreferences"), searchPreferences, new JAXBDataBinding(searchPreferences.getClass())); Header preferencesHeader = new Header( new QName(getPlatformMessageNamespaceUri(), "preferences"), preferences, new JAXBDataBinding(preferences.getClass())); setHeader(port, preferencesHeader); setHeader(port, searchPreferencesHeader); } catch (JAXBException e) { throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e); } }
public BareDocumentResponse testDocLitFault(String in) throws BadRecordLitFault { //System.out.println("Executing testDocLitFault sayHi\n"); List<Header> headers = new ArrayList<>(); Header header = null; try { header = new Header(new QName("http://test", "test"), new String("test"), new JAXBDataBinding(String.class)); } catch (JAXBException e) { e.printStackTrace(); } headers.add(header); context.getMessageContext().put(Header.HEADER_LIST, headers); throw new BadRecordLitFault("int fault", 5); }
/** * Set log-in specific SOAP headers for given port. * * @param port port * @throws NetSuiteException if an error occurs during performing of operation */ protected void setLoginHeaders(PortT port) throws NetSuiteException { if (!StringUtils.isEmpty(credentials.getApplicationId())) { Object applicationInfo = createNativeApplicationInfo(credentials); try { if (applicationInfo != null) { Header appInfoHeader = new Header( new QName(getPlatformMessageNamespaceUri(), "applicationInfo"), applicationInfo, new JAXBDataBinding(applicationInfo.getClass())); setHeader(port, appInfoHeader); } } catch (JAXBException e) { throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e); } } }
/** * Remove log-in specific SOAP headers for given port. * * @param port port * @throws NetSuiteException if an error occurs during performing of operation */ protected void updateLoginHeaders(PortT port) throws NetSuiteException { if (!isUseRequestLevelCredentials()) { removeHeader(port, new QName(getPlatformMessageNamespaceUri(), "applicationInfo")); } else { Object passport = createNativePassport(credentials); try { if (passport != null) { Header passportHeader = new Header( new QName(getPlatformMessageNamespaceUri(), "passport"), passport, new JAXBDataBinding(passport.getClass())); setHeader(port, passportHeader); } } catch (JAXBException e) { throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e); } } }
new QName(OOBHeaderTest.TEST_HDR_NS, OOBHeaderTest.TEST_HDR_RESPONSE_ELEM), OutofBandHeader.class, null, ob); Header hdr = new Header( new QName(OOBHeaderTest.TEST_HDR_NS, OOBHeaderTest.TEST_HDR_RESPONSE_ELEM), job,
private void addPartialResponseHeader(SoapMessage message) { try { // add piggybacked wsa:From header to partial response List<Header> header = message.getHeaders(); Document doc = DOMUtils.getEmptyDocument(); SoapVersion ver = message.getVersion(); Element hdr = doc.createElementNS(ver.getHeader().getNamespaceURI(), ver.getHeader().getLocalPart()); hdr.setPrefix(ver.getHeader().getPrefix()); marshallFrom("urn:piggyback_responder", hdr, getMarshaller()); Element elem = DOMUtils.getFirstElement(hdr); while (elem != null) { Header holder = new Header( new QName(elem.getNamespaceURI(), elem.getLocalName()), elem, null); header.add(holder); elem = DOMUtils.getNextElement(elem); } } catch (Exception e) { verificationCache.put("SOAP header addition failed: " + e); e.printStackTrace(); } }
@org.junit.Test public void testKeyIdentifier2() throws Exception { if (test.isStreaming()) { return; } SpringBusFactory bf = new SpringBusFactory(); URL busFile = X509TokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = X509TokenTest.class.getResource("DoubleItOperations.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierPort2"); DoubleItPortType2 x509Port = service.getPort(portQName, DoubleItPortType2.class); updateAddressPort(x509Port, PORT); List<Header> headers = new ArrayList<>(); Header dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), "dummy-header", new JAXBDataBinding(String.class)); headers.add(dummyHeader); ((BindingProvider)x509Port).getRequestContext().put(Header.HEADER_LIST, headers); int response = x509Port.doubleIt(25); assertEquals(50, response); int response2 = x509Port.doubleIt2(15); assertEquals(30, response2); ((java.io.Closeable)x509Port).close(); bus.shutdown(true); }
s.setMessageNumber(msgId.getAndIncrement()); JAXBElement<AppSequenceType> seq = new ObjectFactory().createAppSequence(s); Header h = new Header(seq.getName(), seq, new JAXBDataBinding(getJAXBContext()));
s.setMessageNumber(msgId.getAndIncrement()); JAXBElement<AppSequenceType> seq = new ObjectFactory().createAppSequence(s); Header h = new Header(seq.getName(), seq, new JAXBDataBinding(getJAXBContext()));