当前位置: 首页>>代码示例>>Java>>正文


Java SOAPMessage.setProperty方法代码示例

本文整理汇总了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; 
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:52,代码来源:WebServiceTranslator.java


注:本文中的javax.xml.soap.SOAPMessage.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。