本文整理汇总了Java中org.apache.axiom.om.OMOutputFormat.getCharSetEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java OMOutputFormat.getCharSetEncoding方法的具体用法?Java OMOutputFormat.getCharSetEncoding怎么用?Java OMOutputFormat.getCharSetEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.OMOutputFormat
的用法示例。
在下文中一共展示了OMOutputFormat.getCharSetEncoding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat format, String soapAction) {
String encoding = format.getCharSetEncoding();
String contentType = "text/plain";
if (encoding != null) {
contentType += "; charset=" + encoding;
}
// if soap action is there (can be there is soap response MEP is used) add it.
if ((soapAction != null)
&& !"".equals(soapAction.trim())
&& !"\"\"".equals(soapAction.trim())) {
contentType = contentType + ";action=\"" + soapAction + "\";";
}
return contentType;
}
示例2: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
/**
* Returns the content type
*
* @see org.apache.axis2.transport.MessageFormatter#getContentType(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
*/
public String getContentType(MessageContext messageContext,
OMOutputFormat format, String soapAction) {
String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
String encoding = format.getCharSetEncoding();
//If the Content Type is not available with the property "Content Type" retrieve it from the property "Message Type"
if (contentType == null) {
contentType = (String) messageContext.getProperty(Constants.Configuration.MESSAGE_TYPE);
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
return contentType;
}
示例3: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat format, String soapAction) {
String encoding = format.getCharSetEncoding();
String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
if(contentType == null) {
contentType = org.apache.axis2.namespace.Constants.MIME_CT_TEXT_PLAIN;
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
// if soap action is there (can be there is soap response MEP is used) add it.
if ((soapAction != null)
&& !"".equals(soapAction.trim())
&& !"\"\"".equals(soapAction.trim())) {
contentType = contentType + ";action=\"" + soapAction + "\";";
}
return contentType;
}
示例4: writeXMLDeclaration
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
private void writeXMLDeclaration(MessageContext messageContext, OutputStream outputStream, OMOutputFormat format) {
String xmlDeclaration;
String writeXmlDeclaration = (String) messageContext.getProperty(WRITE_XML_DECLARATION);
if (writeXmlDeclaration != null && "true".equalsIgnoreCase(writeXmlDeclaration)) {
String xmlDeclarationEncoding = (String) messageContext.getProperty(XML_DECLARATION_ENCODING);
if (xmlDeclarationEncoding == null) {
xmlDeclarationEncoding = (format.getCharSetEncoding() != null) ?
format.getCharSetEncoding() :
Charset.defaultCharset().toString();
}
String xmlDeclarationStandalone = (String) messageContext.getProperty(XML_DECLARATION_STANDALONE);
if (xmlDeclarationStandalone != null) {
xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" " + "standalone=\""
+ xmlDeclarationStandalone + "\" ?>";
} else {
xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" ?>";
}
try {
outputStream.write(xmlDeclaration.getBytes());
} catch (IOException e) {
log.error("Error while writing the XML declaration ", e);
}
}
}
示例5: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat format,
String soapAction) {
String encoding = format.getCharSetEncoding();
String contentType = HTTPConstants.MEDIA_TYPE_X_WWW_FORM;
if (encoding != null) {
contentType += "; charset=" + encoding;
}
// if soap action is there (can be there is soap response MEP is used) add it.
if ((soapAction != null)
&& !"".equals(soapAction.trim())
&& !"\"\"".equals(soapAction.trim())) {
contentType = contentType + ";action=\"" + soapAction + "\";";
}
return contentType;
}
示例6: getDataSource
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public DataSource getDataSource(MessageContext messageContext,
OMOutputFormat format, String soapAction) throws AxisFault {
return new TextFromElementDataSource(
messageContext.getEnvelope().getBody().getFirstElement(),
format.getCharSetEncoding(),
getContentType(messageContext, format, soapAction));
}
示例7: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext outMsgCtxt, OMOutputFormat omOutputFormat, String s) {
String contentType = (String)outMsgCtxt.getProperty(Constants.Configuration.CONTENT_TYPE);
String encoding = omOutputFormat.getCharSetEncoding();
if (contentType == null) {
contentType = (String)outMsgCtxt.getProperty(Constants.Configuration.MESSAGE_TYPE);
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
return contentType;
}
示例8: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext msgCtxt, OMOutputFormat format,
String soapActionString) {
String contentType = (String)msgCtxt.getProperty(Constants.Configuration.CONTENT_TYPE);
String encoding = format.getCharSetEncoding();
if (contentType == null) {
contentType = (String)msgCtxt.getProperty(Constants.Configuration.MESSAGE_TYPE);
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
return contentType;
}
示例9: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat format,
String soapAction) {
String encoding = format.getCharSetEncoding();
String contentType;
contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
if (log.isDebugEnabled()) {
log.debug("contentType set from messageContext =" + contentType);
log.debug("(NOTE) contentType from format is=" + format.getContentType());
}
if (contentType == null) {
contentType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
} else if (isSOAPContentType(contentType)) {
contentType = HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
if (log.isDebugEnabled()) {
log.debug("contentType is set incorrectly for Application XML.");
log.debug("It is changed to " + contentType);
}
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
if (log.isDebugEnabled()) {
log.debug("contentType returned =" + contentType);
}
return contentType;
}
示例10: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public String getContentType(MessageContext msgCtxt, OMOutputFormat format,
String soapActionString) {
String encoding = format.getCharSetEncoding();
String contentType = format.getContentType();
if (log.isDebugEnabled()) {
log.debug("contentType from the OMOutputFormat =" + contentType);
}
if (encoding != null && contentType != null &&
contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED)==-1) {
contentType += "; charset=" + encoding;
}
// action header is not mandated in SOAP 1.2. So putting it, if
// available
if (!msgCtxt.isSOAP11() && (soapActionString != null)
&& !"".equals(soapActionString.trim())
&& !"\"\"".equals(soapActionString.trim())) {
contentType = contentType + "; action=\"" + soapActionString+ "\"";
}
// This is a quick safety catch. Prior versions of SOAPFormatter
// placed a ';' at the end of the content-type. Many vendors ignore this
// last ';'. However it is not legal and some vendors report an error.
// To increase interoperability, the ';' is stripped off.
contentType = contentType.trim();
if (contentType.lastIndexOf(";") == (contentType.length()-1)) {
contentType = contentType.substring(0, contentType.length()-1);
}
if (log.isDebugEnabled()) {
log.debug("contentType returned =" + contentType);
}
return contentType;
}
示例11: getBytes
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
if (omElement != null) {
Iterator it = omElement.getChildElements();
String paraString = "";
String encoding= format.getCharSetEncoding();
if(encoding==null) {
encoding= "UTF-8";
}
while (it.hasNext()) {
OMElement ele1 = (OMElement) it.next();
String parameter;
try {
parameter = ele1.getLocalName() + "=" + URLEncoder.encode(ele1.getText(),encoding).replace("+", "%20");
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("UnsupportedEncoding for " + ele1.getText());
}
paraString = "".equals(paraString) ? parameter : (paraString + "&" + parameter);
}
return paraString.getBytes();
}
return new byte[0];
}
示例12: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
/**
* Different message formats can set their own content types
* Eg: JSONFormatter can set the content type as application/json
*
* @param messageContext
* @param format
* @param soapAction
*/
public String getContentType(MessageContext messageContext, OMOutputFormat format,
String soapAction) {
String contentType = HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA;
String encoding = format.getCharSetEncoding();
if (encoding != null) {
contentType += "; charset=" + encoding;
}
contentType = contentType + "; " + "boundary=" + format.getMimeBoundary();
return contentType;
}