Java Code Examples for javax.xml.soap.MimeHeaders#addHeader()
The following examples show how to use
javax.xml.soap.MimeHeaders#addHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserAgentHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleOutbound(SOAPMessageContext context) { if (context.getMessage() != null) { MimeHeaders mimeHeaders = context.getMessage().getMimeHeaders(); if (mimeHeaders != null) { String[] agents = mimeHeaders.getHeader("User-Agent"); if (ArrayUtils.isNotEmpty(agents)) { LOG.info("Removing MIME header [User-Agent] with value [" + StringUtils.join(agents, ",") + "]"); mimeHeaders.removeHeader("User-Agent"); } String value = this.config.getProperty("be.ehealth.technicalconnector.handler.user-agent.value", "Ehealth Technical") + " (" + applicationProps.getProperty("application.version", "unknown") + ")"; LOG.debug("Adding MIME header [User-Agent] with value [" + value + "]"); mimeHeaders.addHeader("User-Agent", value); } } return true; }
Example 2
Source File: UserAgentHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleOutbound(SOAPMessageContext context) { if (context.getMessage() != null) { MimeHeaders mimeHeaders = context.getMessage().getMimeHeaders(); if (mimeHeaders != null) { String[] agents = mimeHeaders.getHeader("User-Agent"); if (ArrayUtils.isNotEmpty(agents)) { LOG.info("Removing MIME header [User-Agent] with value [" + StringUtils.join(agents, ",") + "]"); mimeHeaders.removeHeader("User-Agent"); } String value = this.config.getProperty("be.ehealth.technicalconnector.handler.user-agent.value", "Ehealth Technical") + " (" + applicationProps.getProperty("application.version", "unknown") + ")"; LOG.debug("Adding MIME header [User-Agent] with value [" + value + "]"); mimeHeaders.addHeader("User-Agent", value); } } return true; }
Example 3
Source File: UserAgentHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public boolean handleOutbound(SOAPMessageContext context) { if (context.getMessage() != null) { MimeHeaders mimeHeaders = context.getMessage().getMimeHeaders(); if (mimeHeaders != null) { String[] agents = mimeHeaders.getHeader("User-Agent"); if (ArrayUtils.isNotEmpty(agents)) { LOG.info("Removing MIME header [User-Agent] with value [" + StringUtils.join(agents, ",") + "]"); mimeHeaders.removeHeader("User-Agent"); } String value = this.config.getProperty("org.taktik.connector.technical.handler.user-agent.value", "Ehealth Technical") + " (" + applicationProps.getProperty("application.version", "unknown") + ")"; LOG.debug("Adding MIME header [User-Agent] with value [" + value + "]"); mimeHeaders.addHeader("User-Agent", value); } } return true; }
Example 4
Source File: DeviceDiscovery.java From onvif with Apache License 2.0 | 6 votes |
private static Collection<String> parseSoapResponseForUrls(byte[] data) throws SOAPException, IOException { // System.out.println(new String(data)); final Collection<String> urls = new ArrayList<>(); MessageFactory factory = MessageFactory.newInstance(WS_DISCOVERY_SOAP_VERSION); final MimeHeaders headers = new MimeHeaders(); headers.addHeader("Content-type", WS_DISCOVERY_CONTENT_TYPE); SOAPMessage message = factory.createMessage(headers, new ByteArrayInputStream(data)); SOAPBody body = message.getSOAPBody(); for (Node node : getNodeMatching(body, ".*:XAddrs")) { if (node.getTextContent().length() > 0) { urls.addAll(Arrays.asList(node.getTextContent().split(" "))); } } return urls; }
Example 5
Source File: MimeHeadersUtil.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 6
Source File: AbstractITEndpoint.java From spring-ws-security-soap-example with MIT License | 5 votes |
/** * Calls the web service being tested and returns the response. * * @param request * request to the web service * @return the web service response * @throws SOAPException * never, this is a required declaration */ protected final SOAPMessage callWebService(final SOAPMessage request) throws SOAPException { final SOAPConnectionFactory soapConnectionFactory; // Connection factory final MimeHeaders headers; // Message headers soapConnectionFactory = SOAPConnectionFactory.newInstance(); // Sets the SOAP action headers = request.getMimeHeaders(); headers.addHeader("SOAPAction", soapAction); request.saveChanges(); return soapConnectionFactory.createConnection().call(request, wsURL); }
Example 7
Source File: Message.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 8
Source File: MimeHeadersUtil.java From hottub with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 9
Source File: Message.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 10
Source File: MimeHeadersUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 11
Source File: Message.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 12
Source File: MimeHeadersUtil.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 13
Source File: Message.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 14
Source File: MimeHeadersUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 15
Source File: Message.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 16
Source File: MimeHeadersUtil.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 17
Source File: SoapService.java From cerberus-source with GNU General Public License v3.0 | 5 votes |
@Override public SOAPMessage createSoapRequest(String envelope, String method, List<AppServiceHeader> header, String token) throws SOAPException, IOException, SAXException, ParserConfigurationException { String unescapedEnvelope = StringEscapeUtils.unescapeXml(envelope); boolean is12SoapVersion = SOAP_1_2_NAMESPACE_PATTERN.matcher(unescapedEnvelope).matches(); MimeHeaders headers = new MimeHeaders(); for (AppServiceHeader appServiceHeader : header) { headers.addHeader(appServiceHeader.getKey(), appServiceHeader.getValue()); } InputStream input = new ByteArrayInputStream(unescapedEnvelope.getBytes("UTF-8")); MessageFactory messageFactory = MessageFactory.newInstance(is12SoapVersion ? SOAPConstants.SOAP_1_2_PROTOCOL : SOAPConstants.SOAP_1_1_PROTOCOL); return messageFactory.createMessage(headers, input); }
Example 18
Source File: MimeHeadersUtil.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static MimeHeaders copy(MimeHeaders headers) { MimeHeaders newHeaders = new MimeHeaders(); Iterator eachHeader = headers.getAllHeaders(); while (eachHeader.hasNext()) { MimeHeader currentHeader = (MimeHeader) eachHeader.next(); newHeaders.addHeader( currentHeader.getName(), currentHeader.getValue()); } return newHeaders; }
Example 19
Source File: Message.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) { for(Map.Entry<String, List<String>> e : headers.entrySet()) { if (!e.getKey().equalsIgnoreCase("Content-Type")) { for(String value : e.getValue()) { mh.addHeader(e.getKey(), value); } } } }
Example 20
Source File: SOAPRequestBuilder.java From cougar with Apache License 2.0 | 4 votes |
public SOAPMessage buildSOAPRequest(Document document, HttpCallBean httpCallBean) { nameSpace = httpCallBean.getNameSpace(); if (nameSpace == null || nameSpace.equals("")) { throw new RuntimeException( "Cannot create SOAP message using the following name space : " + nameSpace); } // Construct SOAPMessage MessageFactory mf; try { mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); //add headers here MimeHeaders hd = message.getMimeHeaders(); hd.addHeader("X-Forwarded-For", httpCallBean.getIpAddress()); //SCR: 103 Trace Me testing //hd.addHeader("X-Trace-Me", "true"); // if(httpCallBean.getHeaderParams()!=null) { for (String key: httpCallBean.getHeaderParams().keySet()) { hd.addHeader(key, httpCallBean.getHeaderParams().get(key)); } } SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("bas", nameSpace); // generate header generateSoapHeader(envelope, httpCallBean); // generate body generateSOAPBody(envelope, document); message.saveChanges(); // TODO write this to the logs //Uncomment for debug /*try { System.out.println("\n Soap Request:\n"); message.writeTo(System.out); System.out.println(); } catch (IOException e) { throw new UtilityException(e); }*/ return message; } catch (SOAPException e) { throw new RuntimeException(e); } }