本文整理汇总了Java中javax.xml.soap.SOAPMessage.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPMessage.setProperty方法的具体用法?Java SOAPMessage.setProperty怎么用?Java SOAPMessage.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPMessage
的用法示例。
在下文中一共展示了SOAPMessage.setProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOutputData
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public Object buildOutputData(Context context, Object convertigoResponse) throws Exception {
Engine.logBeans.debug("[WebServiceTranslator] Encoding the SOAP response...");
SOAPMessage responseMessage = null;
String sResponseMessage = "";
String encodingCharSet = "UTF-8";
if (context.requestedObject != null)
encodingCharSet = context.requestedObject.getEncodingCharSet();
if (convertigoResponse instanceof Document) {
Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is a XML document.");
Document document = Engine.theApp.schemaManager.makeResponse((Document) convertigoResponse);
//MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
MessageFactory messageFactory = MessageFactory.newInstance();
responseMessage = messageFactory.createMessage();
responseMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encodingCharSet);
SOAPPart sp = responseMessage.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
sb.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
//se.addNamespaceDeclaration(prefix, targetNameSpace);
se.addNamespaceDeclaration("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
se.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
se.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
// Remove header as it not used. Seems that empty headers causes the WS client of Flex 4 to fail
se.getHeader().detachNode();
addSoapElement(context, se, sb, document.getDocumentElement());
sResponseMessage = SOAPUtils.toString(responseMessage, encodingCharSet);
// Correct missing "xmlns" (Bug AXA POC client .NET)
//sResponseMessage = sResponseMessage.replaceAll("<soapenv:Envelope", "<soapenv:Envelope xmlns=\""+targetNameSpace+"\"");
}
else {
Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is not a XML document.");
sResponseMessage = convertigoResponse.toString();
}
if (Engine.logBeans.isDebugEnabled()) {
Engine.logBeans.debug("[WebServiceTranslator] SOAP response:\n" + sResponseMessage);
}
return responseMessage == null ? sResponseMessage.getBytes(encodingCharSet) : responseMessage;
}