本文整理汇总了Java中javax.xml.soap.SOAPBody.extractContentAsDocument方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPBody.extractContentAsDocument方法的具体用法?Java SOAPBody.extractContentAsDocument怎么用?Java SOAPBody.extractContentAsDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPBody
的用法示例。
在下文中一共展示了SOAPBody.extractContentAsDocument方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleOutbound
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Override
protected boolean handleOutbound(final SOAPMessageContext msgContext)
{
try
{
SOAPMessage message = msgContext.getMessage();
SOAPBody body = message.getSOAPBody();
Document document = body.extractContentAsDocument();
NodeList nodes = document.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++)
{
Node current = nodes.item(i);
NodeList childNodes = current.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++)
{
Node currentChildNode = childNodes.item(j);
if ("return".equals(currentChildNode.getLocalName()))
{
currentChildNode.setTextContent("PutByServerSOAPHandler");
}
}
}
body.addDocument(document);
message.saveChanges();
}
catch (SOAPException e)
{
throw new RuntimeException(e);
}
return true;
}
示例2: handleInbound
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Override
protected boolean handleInbound(final SOAPMessageContext msgContext)
{
try
{
SOAPMessage message = msgContext.getMessage();
SOAPBody body = message.getSOAPBody();
Document document = body.extractContentAsDocument();
NodeList nodes = document.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++)
{
Node current = nodes.item(i);
NodeList childNodes = current.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++)
{
Node currentChildNode = childNodes.item(j);
if ("return".equals(currentChildNode.getLocalName()))
{
currentChildNode.setTextContent("PutByClientSOAPHandler");
}
}
}
body.addDocument(document);
message.saveChanges();
}
catch (SOAPException e)
{
throw new RuntimeException(e);
}
return true;
}
示例3: testExtractContentAsDocument
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Validated @Test
public void testExtractContentAsDocument() {
try {
MessageFactory fact = MessageFactory.newInstance();
SOAPMessage message = fact.createMessage();
SOAPBody soapBody = message.getSOAPBody();
QName qname1 = new QName("http://wombat.ztrade.com",
"GetLastTradePrice", "ztrade");
SOAPElement child1 = soapBody.addChildElement(qname1);
Document document = soapBody.extractContentAsDocument();
assertNotNull(document);
assertTrue(document instanceof Document);
Element element = document.getDocumentElement();
String elementName = element.getTagName();
//Retreive the children of the SOAPBody (should be none)
Iterator childElements = soapBody.getChildElements();
int childCount = 0;
while (childElements.hasNext()) {
Object object = childElements.next();
childCount++;
}
assertEquals(childCount, 0);
}
catch (Exception e) {
fail("Unexpected Exception : " + e);
}
}
示例4: handleInbound
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Override
protected boolean handleInbound(final SOAPMessageContext msgContext)
{
log.info("handleInbound()");
try
{
SOAPMessage message = msgContext.getMessage();
SOAPBody body = message.getSOAPBody();
Document document = body.extractContentAsDocument();
Node node = document;
log.info(DOMWriter.printNode(node, true));
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++)
{
Node current = nodes.item(i);
NodeList childNodes = current.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++)
{
Node currentChildNode = childNodes.item(j);
if ("result".equals(currentChildNode.getLocalName()))
{
currentChildNode.setTextContent(currentChildNode.getTextContent() + " modified in handler");
}
}
}
log.info(DOMWriter.printNode(node, true));
// Add document back as removed by call to 'extractContentAsDocument()'
body.addDocument(document);
message.saveChanges();
}
catch (SOAPException e)
{
throw new RuntimeException("Error in Handler", e);
}
log.info("Finished");
return true;
}
示例5: invoke
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public SOAPMessage invoke(SOAPMessage request)
{
logger.log(Level.FINE, "DOMDocumentAcceptorProvider.invoke");
try
{
if (logger.isLoggable(Level.FINER))
{
ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
request.writeTo(requestOutputStream);
logger.log(Level.FINER, "DOMDocumentAcceptorProvider.invoke: request = " + requestOutputStream.toString());
requestOutputStream.close();
}
if (_domDocumentAcceptorDispatcher != null)
{
SOAPPart requestPart = request.getSOAPPart();
SOAPEnvelope requestEnvelope = requestPart.getEnvelope();
SOAPBody requestBody = requestEnvelope.getBody();
Document requestDocument = requestBody.extractContentAsDocument();
Element requestElement = requestDocument.getDocumentElement();
NodeList requestNodeList = requestElement.getChildNodes();
String id = null;
for (int requestNodeIndex = 0; requestNodeIndex < requestNodeList.getLength(); requestNodeIndex++)
{
Node requestNode = requestNodeList.item(requestNodeIndex);
if ((requestNode.getNodeType() == Node.ELEMENT_NODE) && CommonDefs.INTERCONNECT_PARAMETERNAME_ID.equals(requestNode.getNodeName()) && CommonDefs.INTERCONNECT_NAMESPACE.equals(requestNode.getNamespaceURI()))
{
if (id == null)
id = requestNode.getTextContent();
requestElement.removeChild(requestNode);
}
}
logger.log(Level.FINE, "DOMDocumentAcceptorProvider.invoke: id = " + id);
if ((id != null) && (requestDocument != null))
_domDocumentAcceptorDispatcher.dispatch(id, requestDocument);
MessageFactory responceFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage responce = responceFactory.createMessage();
if (logger.isLoggable(Level.FINER))
{
ByteArrayOutputStream responceOutputStream = new ByteArrayOutputStream();
responce.writeTo(responceOutputStream);
logger.log(Level.FINER, "DOMDocumentAcceptorProvider.invoke: responce = " + responceOutputStream.toString());
responceOutputStream.close();
}
return responce;
}
}
catch (SOAPException soapException)
{
logger.log(Level.WARNING, "DOMDocumentAcceptorProvider ", soapException);
}
catch (IOException ioException)
{
logger.log(Level.WARNING, "DOMDocumentAcceptorProvider ", ioException);
}
return null;
}
开发者ID:arjuna-technologies,项目名称:Interconnect_DataBroker_PlugIn,代码行数:65,代码来源:DOMDocumentAcceptorProvider.java
示例6: run
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Override
public void run()
{
logger.log(Level.FINE, "DOMDocumentPullDataSource.run");
Document result = null;
try
{
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
SOAPPart requestPart = request.getSOAPPart();
SOAPEnvelope requestEnvelope = requestPart.getEnvelope();
SOAPBody requestBody = requestEnvelope.getBody();
SOAPElement requestElement = requestBody.addChildElement(CommonDefs.INTERCONNECT_OPERATIONNAME_PROVIDER_OBTAINDATA, "ic", CommonDefs.INTERCONNECT_NAMESPACE);
SOAPElement requestParameter = requestElement.addChildElement(CommonDefs.INTERCONNECT_PARAMETERNAME_ID, "ic");
requestParameter.addTextNode(_endpointPath);
if (logger.isLoggable(Level.FINER))
{
ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
request.writeTo(requestOutputStream);
logger.log(Level.FINER, "DOMDocumentPullDataSource.run: request = " + requestOutputStream.toString());
requestOutputStream.close();
}
SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = connectionFactory.createConnection();
SOAPMessage responce = connection.call(request, _serviceURL+ "/" + CommonDefs.INTERCONNECT_SERVICE_PATH + "/" + CommonDefs.INTERCONNECT_SERVICENAME_PROVIDER);
if (logger.isLoggable(Level.FINER))
{
ByteArrayOutputStream responceOutputStream = new ByteArrayOutputStream();
responce.writeTo(responceOutputStream);
logger.log(Level.FINER, "DOMDocumentPullDataSource.run: responce: " + responceOutputStream.toString());
responceOutputStream.close();
}
SOAPPart responcePart = responce.getSOAPPart();
SOAPEnvelope responceEnvelope = responcePart.getEnvelope();
SOAPBody responceBody = responceEnvelope.getBody();
if (responceBody.hasChildNodes())
result = responceBody.extractContentAsDocument();
}
catch (Throwable throwable)
{
logger.log(Level.WARNING, "Problems with web service invoke", throwable);
}
if (result != null)
_dataProvider.produce(result);
}
开发者ID:arjuna-technologies,项目名称:Interconnect_DataBroker_PlugIn,代码行数:54,代码来源:DOMDocumentPullDataSource.java
示例7: run
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@Override
public void run()
{
logger.log(Level.FINE, "InvocationTimerTask.run");
Document result = null;
try
{
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = messageFactory.createMessage();
SOAPPart requestPart = request.getSOAPPart();
SOAPEnvelope requestEnvelope = requestPart.getEnvelope();
SOAPBody requestBody = requestEnvelope.getBody();
requestEnvelope.addNamespaceDeclaration("oper", _operationNamespace);
SOAPBodyElement operationElement = requestBody.addBodyElement(requestEnvelope.createQName(_operationName, "oper"));
if ((_username != null) && (! _username.trim().equals("")))
{
SOAPElement usernameElement = operationElement.addChildElement("UserName", "oper");
usernameElement.setTextContent(_username);
}
if ((_password != null) && (! _password.trim().equals("")))
{
SOAPElement passwordElement = operationElement.addChildElement("Password", "oper");
passwordElement.setTextContent(_password);
}
if (logger.isLoggable(Level.FINE))
{
ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
request.writeTo(requestOutputStream);
logger.log(Level.FINE, "Request: " + requestOutputStream.toString());
requestOutputStream.close();
}
SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = connectionFactory.createConnection();
SOAPMessage responce = connection.call(request, _serviceURL);
if (logger.isLoggable(Level.FINE))
{
ByteArrayOutputStream responceOutputStream = new ByteArrayOutputStream();
responce.writeTo(responceOutputStream);
logger.log(Level.FINE, "Responce: " + responceOutputStream.toString());
responceOutputStream.close();
}
SOAPPart responcePart = responce.getSOAPPart();
SOAPEnvelope responceEnvelope = responcePart.getEnvelope();
SOAPBody responceBody = responceEnvelope.getBody();
result = responceBody.extractContentAsDocument();
}
catch (Throwable throwable)
{
logger.log(Level.WARNING, "Problems with web service invoke", throwable);
}
if (result != null)
_dataProvider.produce(result);
}
开发者ID:arjuna-technologies,项目名称:WebService_DataBroker_PlugIn,代码行数:62,代码来源:PullSOAPWebServiceDataSource.java
示例8: extractDocument
import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
* extractDocument
*
* @param message
* SOAPMessage with document to be extracted
* @return Document extracted from the message body
* @throws SOAPException
* - if there was an error creating the SOAP Connection
*/
public Document extractDocument(SOAPMessage message) throws SOAPException {
SOAPBody soapBody = message.getSOAPBody();
Document doc = soapBody.extractContentAsDocument();
return doc;
}