本文整理匯總了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;
}