本文整理匯總了Java中javax.xml.soap.MimeHeaders.getHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java MimeHeaders.getHeader方法的具體用法?Java MimeHeaders.getHeader怎麽用?Java MimeHeaders.getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.MimeHeaders
的用法示例。
在下文中一共展示了MimeHeaders.getHeader方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkContentType
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
private void checkContentType(SOAPMessage soapMessage)
{
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] ct = mimeHeaders.getHeader("Content-Type");
boolean found = false;
if (ct != null)
{
for (int i = 0; i < ct.length; i++)
{
if (ct[i].startsWith(contentType))
found = true;
}
}
if (!found)
throw new RuntimeException("Expected '" + contentType + "' content-type not found in the headers");
}
示例2: handleInbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
log.info("handleInbound");
//legacy JBossWS-Native approach
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] cookies = mimeHeaders.getHeader("Set-Cookie");
// proper approach through MessageContext.HTTP_RESPONSE_HEADERS
if (cookies == null) {
@SuppressWarnings("unchecked")
Map<String, List<String>> httpHeaders = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> l = httpHeaders.get("Set-Cookie");
if (l != null && !l.isEmpty()) {
cookies = l.toArray(new String[l.size()]);
}
}
if (cookies != null && cookies.length == 1)
inboundCookie = cookies[0];
return true;
}
示例3: handleInbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
log.info("handleInbound");
// legacy JBossWS-Native approach...
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] cookies = mimeHeaders.getHeader("Cookie");
// proper approach through MessageContext.HTTP_REQUEST_HEADERS
if (cookies == null) {
@SuppressWarnings("unchecked")
Map<String, List<String>> httpHeaders = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> l = httpHeaders.get("Cookie");
if (l != null && !l.isEmpty()) {
cookies = l.toArray(new String[l.size()]);
}
}
if (cookies != null && cookies.length == 1 && cookies[0].equals("client-cookie=true"))
setCookieOnResponse = true;
return true;
}
示例4: putHeaders
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
* Adds the given MIME headers into the HTTP response object.
*
* @param headers MIME headers to be added
* @param res the Http servlet response
*/
public static void putHeaders(MimeHeaders headers, HttpServletResponse res) {
for (Iterator it = headers.getAllHeaders(); it.hasNext();) {
MimeHeader header = (MimeHeader) it.next();
String[] values = headers.getHeader(header.getName());
res.setHeader(header.getName(), buildHeaderValue(header, values));
}
}
示例5: putHeaders
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
* Puts the mime headers into a mime message.
*
* @param mimeHeaders the mime headers.
* @param message the mime message.
* @throws MessagingException if error occurred when adding the headers.
*/
private void putHeaders(MimeHeaders mimeHeaders,
MimeMessage message) throws MessagingException {
for (Iterator iterator = mimeHeaders.getAllHeaders(); iterator
.hasNext();) {
MimeHeader mimeHeader = (MimeHeader) iterator.next();
String[] mimeValues = mimeHeaders.getHeader(mimeHeader.getName());
for (int i = 0; i < mimeValues.length;) {
String value = mimeValues[i++];
message.addHeader(mimeHeader.getName(), value);
}
}
}
示例6: handleInbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
log.info("handleInbound");
try
{
SOAPMessage soapMessage = msgContext.getMessage();
soapMessage.saveChanges(); // force changes save to make sure headers are copied to the message
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] ct = mimeHeaders.getHeader("Content-Type");
if (ct != null)
{
for (int i = 0; i < ct.length; i++)
{
if (ct[i].startsWith(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
return true;
}
}
return false;
}
catch (SOAPException ex)
{
throw new WebServiceException(ex);
}
}
示例7: handleOutbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
try
{
SOAPMessage soapMessage = msgContext.getMessage();
soapMessage.saveChanges(); // force changes save to make sure headers are copied to the message
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
String[] ct = mimeHeaders.getHeader("Content-Type");
if (ct != null)
{
for (int i = 0; i < ct.length; i++)
{
if (ct[i].startsWith(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
return true;
}
}
return false;
}
catch (SOAPException ex)
{
throw new WebServiceException(ex);
}
}
示例8: invoke
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
* The Webservice implementation method, invokes the service handler.
* @param request the SOAP request
* @return the SOAP response
*/
public SOAPMessage invoke(final SOAPMessage request) {
if (request != null) {
// Workaround for SOAP1.2 SOAPAction. Although HTTP header has the action value it is missing in
// the SOAPMessage's MimeHeader
MimeHeaders mimeHeaders = request.getMimeHeaders();
String[] mimeContentTypes = mimeHeaders.getHeader(CONTENT_TYPE);
if (mimeContentTypes != null) {
String mimeContentType = mimeContentTypes[0];
if ((mimeContentType != null) && (mimeContentType.indexOf(ACTION_EQUALS) == -1)) {
Map headers = (Map)_wsContext.getMessageContext().get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> contentTypes = (List)headers.get(CONTENT_TYPE_L);
if ((contentTypes == null) || (contentTypes.size() == 0)) {
contentTypes = (List)headers.get(CONTENT_TYPE);
}
if ((contentTypes != null) && (contentTypes.size() > 0)) {
int idx = contentTypes.get(0).indexOf(ACTION_EQUALS);
if (idx > 0) {
String action = contentTypes.get(0).substring(idx + 7).replace("\"\"","\"");
mimeHeaders.setHeader(CONTENT_TYPE, mimeContentType + "; " + ACTION_EQUALS + action);
}
}
}
}
}
SOAPMessage response = null;
ClassLoader original = Classes.setTCCL(_invocationClassLoader);
try {
response = _serviceConsumer.invoke(request, _wsContext);
} finally {
Classes.setTCCL(original);
}
return response;
}
示例9: getHeader
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
static String getHeader(MimeHeaders headers, String name) {
String[] values = headers.getHeader(name);
return (values != null && values.length > 0) ? values[0] : null;
}
示例10: getAuthContextID
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public String getAuthContextID(MessageInfo messageInfo)
{
SOAPMessage request = (SOAPMessage) messageInfo.getRequestMessage();
if (request == null)
{
return null;
}
String authContext = null;
MimeHeaders headers = request.getMimeHeaders();
if (headers != null)
{
String[] soapActions = headers.getHeader("SOAPAction");
if (soapActions != null && soapActions.length > 0)
{
authContext = soapActions[0];
if (!StringUtils.isEmpty(authContext))
{
return authContext;
}
}
}
SOAPPart soapMessage = request.getSOAPPart();
if (soapMessage != null)
{
try
{
SOAPEnvelope envelope = soapMessage.getEnvelope();
if (envelope != null)
{
SOAPBody body = envelope.getBody();
if (body != null)
{
Iterator it = body.getChildElements();
while (it.hasNext())
{
Object o = it.next();
if (o instanceof SOAPElement)
{
QName name = ((SOAPElement) o).getElementQName();
return name.getLocalPart();
}
}
}
}
}
catch (SOAPException se)
{
//ignore;
Logger.getLogger(JBossWSClientAuthConfig.class).trace(se);
}
}
return null;
}
示例11: getAuthContextID
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public String getAuthContextID(MessageInfo messageInfo)
{
SOAPMessage request = (SOAPMessage) messageInfo.getRequestMessage();
if (request == null)
{
return null;
}
String authContext = null;
MimeHeaders headers = request.getMimeHeaders();
if (headers != null)
{
String[] soapActions = headers.getHeader("SOAPAction");
if (soapActions != null && soapActions.length > 0)
{
authContext = soapActions[0];
if (!StringUtils.isEmpty(authContext))
{
return authContext;
}
}
}
SOAPPart soapMessage = request.getSOAPPart();
if (soapMessage != null)
{
try
{
SOAPEnvelope envelope = soapMessage.getEnvelope();
if (envelope != null)
{
SOAPBody body = envelope.getBody();
if (body != null)
{
Iterator it = body.getChildElements();
while (it.hasNext())
{
Object o = it.next();
if (o instanceof SOAPElement)
{
QName name = ((SOAPElement) o).getElementQName();
return name.getLocalPart();
}
}
}
}
}
catch (SOAPException se)
{
//ignore;
Logger.getLogger(JBossWSServerAuthConfig.class).trace(se);
}
}
return null;
}
示例12: SOAPMessageImpl
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public SOAPMessageImpl(InputStream inputstream, MimeHeaders mimeHeaders, boolean processMTOM)
throws SOAPException {
String contentType = null;
String tmpContentType = "";
if (mimeHeaders != null) {
String contentTypes[] = mimeHeaders.getHeader(HTTPConstants.CONTENT_TYPE);
if (contentTypes != null && contentTypes.length > 0) {
tmpContentType = contentTypes[0];
contentType = SAAJUtil.normalizeContentType(tmpContentType);
}
}
if ("multipart/related".equals(contentType)) {
try {
Attachments attachments =
new Attachments(inputstream, tmpContentType, false, "", "");
// Axiom doesn't give us access to the MIME headers of the individual
// parts of the SOAP message package. We need to reconstruct them from
// the available information.
MimeHeaders soapPartHeaders = new MimeHeaders();
soapPartHeaders.addHeader(HTTPConstants.CONTENT_TYPE,
attachments.getSOAPPartContentType());
String soapPartContentId = attachments.getSOAPPartContentID();
soapPartHeaders.addHeader("Content-ID", "<" + soapPartContentId + ">");
soapPart = new SOAPPartImpl(this, attachments.getSOAPPartInputStream(),
soapPartHeaders, processMTOM ? attachments : null);
for (String contentId : attachments.getAllContentIDs()) {
if (!contentId.equals(soapPartContentId)) {
AttachmentPart ap =
createAttachmentPart(attachments.getDataHandler(contentId));
ap.setContentId("<" + contentId + ">");
attachmentParts.add(ap);
}
}
} catch (OMException e) {
throw new SOAPException(e);
}
} else {
initCharsetEncodingFromContentType(tmpContentType);
soapPart = new SOAPPartImpl(this, inputstream, mimeHeaders, null);
}
this.mimeHeaders = (mimeHeaders == null) ?
new MimeHeaders() :
SAAJUtil.copyMimeHeaders(mimeHeaders);
}
示例13: saveMsgWithAttachments
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public int saveMsgWithAttachments(OutputStream os) throws Exception {
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
SOAPPart soapPart = msg.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
SOAPElement el = header.addHeaderElement(envelope.createName("field4", NS_PREFIX, NS_URI));
SOAPElement el2 = el.addChildElement("field4b", NS_PREFIX);
el2.addTextNode("field4value");
el = body.addBodyElement(envelope.createName("bodyfield3", NS_PREFIX, NS_URI));
el2 = el.addChildElement("bodyfield3a", NS_PREFIX);
el2.addTextNode("bodyvalue3a");
el2 = el.addChildElement("bodyfield3b", NS_PREFIX);
el2.addTextNode("bodyvalue3b");
el.addChildElement("datefield", NS_PREFIX);
// First Attachment
AttachmentPart ap = msg.createAttachmentPart();
final String testText = "some attachment text...";
ap.setContent(testText, "text/plain");
msg.addAttachmentPart(ap);
// Second attachment
DataHandler dh = new DataHandler(TestUtils.getTestFileAsDataSource("axis2.jpg"));
AttachmentPart ap2 = msg.createAttachmentPart(dh);
ap2.setContentType("image/jpg");
msg.addAttachmentPart(ap2);
msg.saveChanges(); // This is only required with Sun's SAAJ implementation
MimeHeaders headers = msg.getMimeHeaders();
assertTrue(headers != null);
String [] contentType = headers.getHeader("Content-Type");
assertTrue(contentType != null);
int i = 0;
for (Iterator iter = msg.getAttachments(); iter.hasNext();) {
AttachmentPart attachmentPart = (AttachmentPart)iter.next();
final Object content = attachmentPart.getDataHandler().getContent();
if (content instanceof String) {
assertEquals(testText, (String)content);
} else if (content instanceof FileInputStream) {
// try to write to a File and check whether it is ok
final FileInputStream fis = (FileInputStream)content;
byte[] b = new byte[15000];
final int lengthRead = fis.read(b);
FileOutputStream fos =
new FileOutputStream(new File(System.getProperty("basedir", ".") + "/" +
"target/test-resources/atts-op" + (i++) + ".jpg"));
fos.write(b, 0, lengthRead);
fos.flush();
fos.close();
}
}
msg.writeTo(os);
os.flush();
return msg.countAttachments();
}