當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPBody.extractContentAsDocument方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:34,代碼來源:ServerSOAPHandler.java

示例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;
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:34,代碼來源:ClientSOAPHandler.java

示例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);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:31,代碼來源:SOAPBodyTest.java

示例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;
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:46,代碼來源:SOAPHandler.java

示例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;
}
 
開發者ID:AgileTestingFramework,項目名稱:atf-toolbox-java,代碼行數:17,代碼來源:WebServiceAutomationManager.java


注:本文中的javax.xml.soap.SOAPBody.extractContentAsDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。