List of usage examples for javax.mail.internet ContentType toString
@Override
public String toString()
From source file:org.apache.axis2.transport.testkit.http.JavaNetClient.java
public void sendMessage(ClientOptions options, ContentType contentType, byte[] message) throws Exception { URL url = new URL(channel.getEndpointReference().getAddress()); log.debug("Opening connection to " + url + " using " + URLConnection.class.getName()); try {/*from w w w. jav a 2 s . c o m*/ URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestProperty("Content-Type", contentType.toString()); if (contentType.getBaseType().equals("text/xml")) { connection.setRequestProperty("SOAPAction", ""); } OutputStream out = connection.getOutputStream(); out.write(message); out.close(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; log.debug("Response code: " + httpConnection.getResponseCode()); log.debug("Response message: " + httpConnection.getResponseMessage()); int i = 0; String headerValue; while ((headerValue = httpConnection.getHeaderField(i)) != null) { String headerName = httpConnection.getHeaderFieldKey(i); if (headerName != null) { log.debug(headerName + ": " + headerValue); } else { log.debug(headerValue); } i++; } } InputStream in = connection.getInputStream(); IOUtils.copy(in, System.out); in.close(); } catch (IOException ex) { log.debug("Got exception", ex); throw ex; } }
From source file:org.freebxml.omar.server.common.Utility.java
/** * Create a SOAPMessage object from a InputStream to a SOAPMessage * @param soapStream the InputStream to the SOAPMessage * @return the created SOAPMessage/*from w ww . j a v a 2 s . co m*/ */ public SOAPMessage createSOAPMessageFromSOAPStream(InputStream soapStream) throws javax.xml.soap.SOAPException, IOException, javax.mail.internet.ParseException { javax.xml.soap.MimeHeaders mimeHeaders = new javax.xml.soap.MimeHeaders(); javax.mail.internet.ContentType contentType = new javax.mail.internet.ContentType("text/xml"); //"multipart/related"); String contentTypeStr = contentType.toString(); //System.err.println("contentTypeStr = '" + contentTypeStr + "'"); mimeHeaders.addHeader("Content-Type", contentTypeStr); mimeHeaders.addHeader("Content-Id", "ebXML Registry SOAP request"); javax.xml.soap.MessageFactory factory = javax.xml.soap.MessageFactory.newInstance(); SOAPMessage msg = factory.createMessage(mimeHeaders, soapStream); msg.saveChanges(); return msg; }