本文整理匯總了Java中javax.xml.soap.MimeHeaders.setHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java MimeHeaders.setHeader方法的具體用法?Java MimeHeaders.setHeader怎麽用?Java MimeHeaders.setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.MimeHeaders
的用法示例。
在下文中一共展示了MimeHeaders.setHeader方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleOutbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
// legacy JBossWS-Native approach
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.setHeader("Cookie", "client-cookie=true");
// proper approach through MessageContext.HTTP_REQUEST_HEADERS
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put("Cookie", Collections.singletonList("client-cookie=true"));
msgContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
inboundCookie = null;
return true;
}
示例2: handleOutbound
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
log.info("handleOutbound");
if (setCookieOnResponse)
{
// legacy JBossWS-Native approach
SOAPMessage soapMessage = msgContext.getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.setHeader("Set-Cookie", "server-cookie=true");
// proper approach through MessageContext.HTTP_REQUEST_HEADERS
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put("Set-Cookie", Collections.singletonList("server-cookie=true"));
msgContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
setCookieOnResponse = false;
}
return true;
}
示例3: getEbxmlMessage
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public static EbxmlMessage getEbxmlMessage(String messageId,
String messageBox) throws MessageValidationException {
try {
// get the byte array of the ebxml message
RepositoryDAO repositoryDAO = (RepositoryDAO) EbmsProcessor.core.dao
.createDAO(RepositoryDAO.class);
RepositoryDVO repositoryDVO = (RepositoryDVO) repositoryDAO
.createDVO();
repositoryDVO.setMessageId(messageId);
repositoryDVO.setMessageBox(messageBox);
repositoryDAO.findRepository(repositoryDVO);
byte[] content = repositoryDVO.getContent();
String contentType = repositoryDVO.getContentType();
// reconstruct the ebxml message
MimeHeaders mimeHeaders = new MimeHeaders();
mimeHeaders.setHeader("Content-Type", contentType);
SOAPMessage soapMessage = MessageFactory.newInstance()
.createMessage(mimeHeaders,
new ByteArrayInputStream(content));
return new EbxmlMessage(soapMessage);
} catch (Exception e) {
throw new MessageValidationException(
"Cannot reconstruct the message " + messageId
+ " from repository", e);
}
}
示例4: 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;
}
示例5: setAuthenticationData
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
* Sets the password for the second login message based on the data received from the
* first login message. Also sets the private key used to generate the authentication header.
*
* @param challenge
* @param cookie
* @param publicKey
* @throws SOAPException
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
*/
private void setAuthenticationData(final String challenge, final String cookie, final String publicKey)
throws SOAPException, InvalidKeyException, NoSuchAlgorithmException {
final MimeHeaders loginHeaders = loginAction.getMimeHeaders();
loginHeaders.setHeader(COOKIE, "uid=" + cookie);
privateKey = hash(challenge, publicKey + pin);
final String password = hash(challenge, privateKey);
loginAction.getSOAPBody().getElementsByTagName(LOGINPASSWORD).item(0).setTextContent(password);
loginAction.saveChanges();
}
示例6: loadMsgWithAttachments
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
public int loadMsgWithAttachments(InputStream is) throws Exception {
MimeHeaders headers = new MimeHeaders();
headers.setHeader("Content-Type", MIME_MULTIPART_RELATED);
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage(headers, is);
SOAPPart sp = msg.getSOAPPart();
assertTrue(sp != null);
SOAPEnvelope envelope = sp.getEnvelope();
assertTrue(envelope != null);
return msg.countAttachments();
}
示例7: SOAPPartImpl
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
protected SOAPPartImpl(MessageImpl message) {
document = new SOAPDocumentImpl(this);
headers = new MimeHeaders();
this.message = message;
headers.setHeader("Content-Type", getContentType());
}
示例8: createQueryMessage
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
protected SOAPMessage createQueryMessage()
{
String queryStr = getQueryString();
if (log.isDebugEnabled())
{
log.debug("MDX query: " + queryStr);
}
try
{
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
MimeHeaders mh = message.getMimeHeaders();
mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\"");
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
Name nEx = envelope.createName("Execute", "", XMLA_URI);
SOAPElement eEx = body.addChildElement(nEx);
// add the parameters
// COMMAND parameter
// <Command>
// <Statement>queryStr</Statement>
// </Command>
Name nCom = envelope.createName("Command", "", XMLA_URI);
SOAPElement eCommand = eEx.addChildElement(nCom);
Name nSta = envelope.createName("Statement", "", XMLA_URI);
SOAPElement eStatement = eCommand.addChildElement(nSta);
eStatement.addTextNode(queryStr);
// <Properties>
// <PropertyList>
// <DataSourceInfo>dataSource</DataSourceInfo>
// <Catalog>catalog</Catalog>
// <Format>Multidimensional</Format>
// <AxisFormat>TupleFormat</AxisFormat>
// </PropertyList>
// </Properties>
Map<String, String> paraList = new HashMap<String, String>();
String datasource = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE);
paraList.put("DataSourceInfo", datasource);
String catalog = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG);
paraList.put("Catalog", catalog);
paraList.put("Format", "Multidimensional");
paraList.put("AxisFormat", "TupleFormat");
addParameterList(envelope, eEx, "Properties", "PropertyList", paraList);
message.saveChanges();
if (log.isDebugEnabled())
{
log.debug("XML/A query message: \n" + prettyPrintSOAP(message.getSOAPPart().getEnvelope()));
}
return message;
}
catch (SOAPException e)
{
throw new JRRuntimeException(e);
}
}
示例9: createQueryMessage
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
/**
* Create the query for the discover action
*
* @param paraList parameters map where the key is the name of the parameter
* and the value is the value of the parameter
* @return the query as soap message
*/
protected SOAPMessage createQueryMessage(Map<String,String> paraList)
{
try
{
// Force the use of Axis as message factory...
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
MimeHeaders mh = message.getMimeHeaders();
mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Discover\"");
mh.setHeader("Content-Type", "text/xml; charset=utf-8");
mh.setHeader("Accept", "application/soap+xml, application/dime, multipart/related, text/*");
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
Name nDiscover = envelope.createName("Discover", "", XMLA_URI);
SOAPElement eDiscover = body.addChildElement(nDiscover);
// add the parameters
// COMMAND parameter
// <Command>
// <Statement>queryStr</Statement>
// </Command>
Name nRequest = envelope.createName("RequestType", "", XMLA_URI);
SOAPElement eRequest = eDiscover.addChildElement(nRequest);
eRequest.addTextNode(getRequestType());
Name nRestiction = envelope.createName("Restrictions", "", XMLA_URI);
SOAPElement eRestriction = eDiscover.addChildElement(nRestiction);
Name nRestictionList = envelope.createName("RestrictionList", "", XMLA_URI);
eRestriction.addChildElement(nRestictionList);
// <Properties>
// <PropertyList>
// <DataSourceInfo>dataSource</DataSourceInfo>
// <Catalog>catalog</Catalog>
// <Format>Multidimensional</Format>
// <AxisFormat>TupleFormat</AxisFormat>
// </PropertyList>
// </Properties>
paraList.put("Format", "Tabular");
paraList.put("Content", "SchemaData");
addParameterList(envelope, eDiscover, "Properties", "PropertyList", paraList);
message.saveChanges();
return message;
}
catch (SOAPException e)
{
e.printStackTrace();
}
return null;
}
示例10: createQueryMessage
import javax.xml.soap.MimeHeaders; //導入方法依賴的package包/類
protected SOAPMessage createQueryMessage(JRXMLADataSourceConnection xmlaConnection)
{
String queryStr = getQueryString();
if (log.isDebugEnabled())
{
log.debug("MDX query: " + queryStr);
}
try
{
// Force the use of Axis as message factory...
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
MimeHeaders mh = message.getMimeHeaders();
mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\"");
//mh.setHeader("Content-Type", "text/xml; charset=utf-8");
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
Name nEx = envelope.createName("Execute", "", XMLA_URI);
SOAPElement eEx = body.addChildElement(nEx);
// add the parameters
// COMMAND parameter
// <Command>
// <Statement>queryStr</Statement>
// </Command>
Name nCom = envelope.createName("Command", "", XMLA_URI);
SOAPElement eCommand = eEx.addChildElement(nCom);
Name nSta = envelope.createName("Statement", "", XMLA_URI);
SOAPElement eStatement = eCommand.addChildElement(nSta);
eStatement.addTextNode(queryStr);
// <Properties>
// <PropertyList>
// <DataSourceInfo>dataSource</DataSourceInfo>
// <Catalog>catalog</Catalog>
// <Format>Multidimensional</Format>
// <AxisFormat>TupleFormat</AxisFormat>
// </PropertyList>
// </Properties>
Map paraList = new HashMap();
String datasource = xmlaConnection.getDatasource();
paraList.put("DataSourceInfo", datasource);
String catalog = xmlaConnection.getCatalog();
paraList.put("Catalog", catalog);
paraList.put("Format", "Multidimensional");
paraList.put("AxisFormat", "TupleFormat");
addParameterList(envelope, eEx, "Properties", "PropertyList", paraList);
message.saveChanges();
if (log.isDebugEnabled())
{
log.debug("XML/A query message: " + message.toString());
}
return message;
}
catch (SOAPException e)
{
log.error(e);
throw new JRRuntimeException(e);
}
}