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


Java SOAPBody.addDocument方法代码示例

本文整理汇总了Java中javax.xml.soap.SOAPBody.addDocument方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPBody.addDocument方法的具体用法?Java SOAPBody.addDocument怎么用?Java SOAPBody.addDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.soap.SOAPBody的用法示例。


在下文中一共展示了SOAPBody.addDocument方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOldStyleSoapResponse

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
protected String createOldStyleSoapResponse(String soapVersion, String xml)
        throws SOAPException {
    try {
        SOAPMessage soapMessage = getSoapMessageFactory(soapVersion).createMessage();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        soapBody.addDocument(DomHelper.toDomDocument(xml));
        return DomHelper.toXmlNoWhiteSpace(soapMessage.getSOAPPart());
    }
    catch (Exception ex) {
        throw new SOAPException(ex.getMessage(), ex);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:13,代码来源:SoapServlet.java

示例2: 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

示例3: xmlStrToSOAPElement

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Converts the given XML string to SOAPElement.
 *
 * @param xml XML string
 * @return given XML string as a SOAPElement or null if the conversion
 * failed
 */
public static SOAPElement xmlStrToSOAPElement(String xml) {
    LOGGER.debug("Convert XML string to SOAPElement. XML : \"{}\"", xml);
    // Try to conver XML string to XML Document
    Document doc = SOAPHelper.xmlStrToDoc(xml);
    if (doc == null) {
        LOGGER.warn("Convertin XML string to SOAP element failed.");
        return null;
    }

    try {
        // Use SAAJ to convert Document to SOAPElement
        // Create SoapMessage
        SOAPMessage message = createSOAPMessage();
        SOAPBody soapBody = message.getSOAPBody();
        // This returns the SOAPBodyElement
        // that contains ONLY the Payload
        SOAPElement payload = soapBody.addDocument(doc);
        if (payload == null) {
            LOGGER.warn("Converting XML string to SOAPElement failed.");
        } else {
            LOGGER.debug("Converting XML string to SOAPElement succeeded.");
        }
        return payload;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        LOGGER.warn("Converting XML document to SOAPElement failed.");
        return null;
    }
}
 
开发者ID:vrk-kpa,项目名称:xrd4j,代码行数:37,代码来源:SOAPHelper.java

示例4: createSoapRequest

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Create the SOAP request object based on the document variable value.
 */
protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException {
    try {
        MessageFactory messageFactory = getSoapMessageFactory();
        SOAPMessage soapMessage = messageFactory.createMessage();
        Map<Name,String> soapReqHeaders = getSoapRequestHeaders();
        if (soapReqHeaders != null) {
            SOAPHeader header = soapMessage.getSOAPHeader();
            for (Name name : soapReqHeaders.keySet()) {
                header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name));
            }
        }

        SOAPBody soapBody = soapMessage.getSOAPBody();

        Document requestDoc = null;
        if (requestObj instanceof String) {
            requestDoc = DomHelper.toDomDocument((String)requestObj);
            soapBody.addDocument(requestDoc);
        }
        else {
            Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE));
            XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)VariableTranslator.getTranslator(getPackage(), reqVar.getType());
            requestDoc = docRefTrans.toDomDocument(requestObj);
            Document copiedDocument = DomHelper.copyDomDocument(requestDoc);
            soapBody.addDocument(copiedDocument);
        }

        return soapMessage;
    }
    catch (Exception ex) {
        throw new ActivityException(ex.getMessage(), ex);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:37,代码来源:DocumentWebServiceAdapter.java

示例5: createSoapResponse

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Allow version specific factory passed in TODO: allow specifying response
 * headers
 */
protected String createSoapResponse(String soapVersion, String xml) throws SOAPException {
    try {
        SOAPMessage soapMessage = getSoapMessageFactory(soapVersion).createMessage();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        soapBody.addDocument(DomHelper.toDomDocument(xml));
        return DomHelper.toXml(soapMessage.getSOAPPart().getDocumentElement());
    }
    catch (Exception ex) {
        throw new SOAPException(ex.getMessage(), ex);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:16,代码来源:SoapServlet.java

示例6: createSoapMessage

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
/**
 * Create a new SOAP message from the specified XMLBeans object. The XmlObject
 * will be injected into the SOAP Body.
 * @param xmlObject The XmlObject to create a SOAP message from
 * @return a SOAPMessage containing the contents of the specified XmlObject
 * @throws SOAPException
 */
public SOAPMessage createSoapMessage(XmlObject xmlObject) throws SOAPException {
    MessageFactory msgFactory = MessageFactory.newInstance();

    SOAPMessage soapMessage = msgFactory.createMessage();
    SOAPPart prt = soapMessage.getSOAPPart();
    SOAPEnvelope env = prt.getEnvelope();
    addWssHeader(env);
    SOAPBody soapBody = env.getBody();
    org.w3c.dom.Node node = xmlObject.getDomNode();
    soapBody.addDocument((Document) node);
    return soapMessage;
}
 
开发者ID:jenkinsci,项目名称:fortify-cloudscan-plugin,代码行数:20,代码来源:FortifySscClient.java

示例7: 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

示例8: invokeAdd

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
int invokeAdd(AddRequest addRequest) {
	int sum = 0;

	try {
		DocumentBuilderFactory builderFactory = DocumentBuilderFactory
				.newInstance();
		builderFactory.setNamespaceAware(true);
		Document doc = builderFactory.newDocumentBuilder().newDocument();

		JAXBContext context = JAXBContext.newInstance(AddRequest.class,
				AddResponse.class);

		context.createMarshaller().marshal(addRequest, doc);

		MessageFactory mf = MessageFactory
				.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
		SOAPMessage request = mf.createMessage();

		SOAPBody body = request.getSOAPBody();

		body.addDocument(doc);

		SOAPMessage response = dispatch.invoke(request);

		AddResponse addResponse = context
				.createUnmarshaller()
				.unmarshal(response.getSOAPBody().getFirstChild(),
						AddResponse.class).getValue();

		sum = addResponse.getSum();
	} catch (Exception e) {
		e.printStackTrace();
	}

	return sum;
}
 
开发者ID:asarkar,项目名称:jax-ws,代码行数:37,代码来源:CalculatorClient.java

示例9: _testAddDocument

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public void _testAddDocument() {
    try {
        Document document = null;
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);

        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.parse(TestUtils.getTestFileURI("soap-body.xml"));
        MessageFactory fact = MessageFactory.newInstance();
        SOAPMessage message = fact.createMessage();

        message.getSOAPHeader().detachNode();
        // assertNull(message.getSOAPHeader());    
        // TODO:this fails. Header is always being created if it doesnt exist in DOOM

        SOAPBody soapBody = message.getSOAPBody();
        soapBody.addDocument(document);
        message.saveChanges();

        // Get contents using SAAJ APIs
        Iterator iter1 = soapBody.getChildElements();
        getContents(iter1, "");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Unexpected Exception : " + e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:28,代码来源:SOAPBodyTest.java

示例10: 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

示例11: invokeSubtract1

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
private void invokeSubtract1(int i, int j) {
int diff = 0;

try {
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory
	    .newInstance();
    builderFactory.setNamespaceAware(true);
    Document doc = builderFactory.newDocumentBuilder().newDocument();

    OperationRequest operationRequest = new OperationRequest(i, j);

    JAXBContext context = JAXBContext.newInstance(
	    OperationRequest.class, OperationResponse.class);

    context.createMarshaller().marshal(operationRequest, doc);

    MessageFactory mf = MessageFactory
	    .newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    SOAPMessage request = mf.createMessage();

    // Specify operation in a SOAP header
    addOperationSOAPHdr("subtract", request);

    SOAPBody body = request.getSOAPBody();

    body.addDocument(doc);

    SOAPMessage response = dispatch.invoke(request);

    OperationResponse operationResponse = context
	    .createUnmarshaller()
	    .unmarshal(response.getSOAPBody().getFirstChild(),
		    OperationResponse.class).getValue();

    diff = operationResponse.getResult();
} catch (Exception e) {
    e.printStackTrace();
}

System.out.println("Difference of " + i + " and " + j + " is " + diff);
   }
 
开发者ID:asarkar,项目名称:jax-ws,代码行数:42,代码来源:JAXWSProviderDispatchClient.java

示例12: invoke

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@WebMethod
public SOAPMessage invoke(SOAPMessage request)
{
    logger.log(Level.FINE, "DOMDocumentProviderProvider.invoke");

    try
    {
        if (logger.isLoggable(Level.FINER))
        {
            ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
            request.writeTo(requestOutputStream);
            logger.log(Level.FINER, "DOMDocumentProviderProvider.invoke: request: " + requestOutputStream.toString());
            requestOutputStream.close();
        }

        if (_domDocumentProviderJunction != null)
        {
            String id = null;

            SOAPPart              requestPart     = request.getSOAPPart();
            SOAPEnvelope          requestEnvelope = requestPart.getEnvelope();
            SOAPBody              requestBody     = requestEnvelope.getBody();

            Iterator<SOAPElement> requestElements = (Iterator<SOAPElement>) requestBody.getChildElements();

            while (requestElements.hasNext())
            {
                SOAPElement requestElement = requestElements.next();

                if ((requestElement.getNodeType() == Node.ELEMENT_NODE) && CommonDefs.INTERCONNECT_OPERATIONNAME_PROVIDER_OBTAINDATA.equals(requestElement.getLocalName()) && CommonDefs.INTERCONNECT_NAMESPACE.equals(requestElement.getNamespaceURI()))
                {
                    Iterator<SOAPElement> requestParameters = (Iterator<SOAPElement>) requestElement.getChildElements();

                    while ((id == null) && requestParameters.hasNext())
                    {
                        SOAPElement requestParameter = requestParameters.next();

                        if ((requestParameter.getNodeType() == Node.ELEMENT_NODE) && CommonDefs.INTERCONNECT_PARAMETERNAME_ID.equals(requestParameter.getLocalName()) && CommonDefs.INTERCONNECT_NAMESPACE.equals(requestParameter.getNamespaceURI()))
                            id = requestParameter.getTextContent();
                    }
                }
            }

            MessageFactory responceFactory  = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

            SOAPMessage  responce         = responceFactory.createMessage();
            SOAPPart     responcePart     = responce.getSOAPPart();
            SOAPEnvelope responceEnvelope = responcePart.getEnvelope();
            SOAPBody     responceBody     = responceEnvelope.getBody();

            logger.log(Level.FINE, "DOMDocumentProviderProvider.invoke: id = " + id);
            if (id != null)
            {
                Document document = _domDocumentProviderJunction.withdraw(id);
                if (document != null)
                    responceBody.addDocument(document);
            }

            if (logger.isLoggable(Level.FINER))
            {
                ByteArrayOutputStream responceOutputStream = new ByteArrayOutputStream();
                request.writeTo(responceOutputStream);
                logger.log(Level.FINER, "DOMDocumentProviderProvider.invoke: responce = " + responceOutputStream.toString());
                responceOutputStream.close();
            }

            return responce;
        }
    }
    catch (SOAPException soapException)
    {
        logger.log(Level.WARNING, "DOMDocumentProviderProvider ", soapException);
    }
    catch (IOException ioException)
    {
        logger.log(Level.WARNING, "DOMDocumentProviderProvider ", ioException);
    }

    return null;
}
 
开发者ID:arjuna-technologies,项目名称:Interconnect_DataBroker_PlugIn,代码行数:82,代码来源:DOMDocumentProviderProvider.java

示例13: consume

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public void consume(Document data)
{
    logger.log(Level.FINE, "DOMDocumentPushDataSink.consume");

    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();
        Document       requestData      = (Document) data.cloneNode(true);
        Element        requestElement   = requestData.getDocumentElement();
        Element        requestIdElement = requestData.createElementNS(CommonDefs.INTERCONNECT_NAMESPACE, CommonDefs.INTERCONNECT_PARAMETERNAME_ID);
        requestIdElement.appendChild(requestData.createTextNode(_endpointPath));
        requestElement.appendChild(requestIdElement);
        requestBody.addDocument(requestData);

        if (logger.isLoggable(Level.FINE))
        {
            ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
            request.writeTo(requestOutputStream);
            logger.log(Level.FINE, "DOMDocumentPushDataSink.consume: request = " + requestOutputStream.toString());
            requestOutputStream.close();
        }

        SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection        connection        = connectionFactory.createConnection();
        URL                   serviceURL        = new URL(_serviceRootURL + "/" + CommonDefs.INTERCONNECT_SERVICE_PATH + "/" + CommonDefs.INTERCONNECT_SERVICENAME_ACCEPTOR);

        SOAPMessage responce = connection.call(request, serviceURL);

        if (logger.isLoggable(Level.FINE))
        {
            ByteArrayOutputStream responceOutputStream = new ByteArrayOutputStream();
            responce.writeTo(responceOutputStream);
            logger.log(Level.FINE, "DOMDocumentPushDataSink.consume: responce = " + responceOutputStream.toString());
            responceOutputStream.close();
        }
    }
    catch (Throwable throwable)
    {
        logger.log(Level.WARNING, "Problems with web service invoke", throwable);
    }
}
 
开发者ID:arjuna-technologies,项目名称:Interconnect_DataBroker_PlugIn,代码行数:46,代码来源:DOMDocumentPushDataSink.java

示例14: consume

import javax.xml.soap.SOAPBody; //导入方法依赖的package包/类
public void consume(Document data)
{
    logger.log(Level.FINE, "PushWebServiceDataSink.consume");

    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);
        requestBody.addBodyElement(requestEnvelope.createQName(_operationName, "oper"));
        requestBody.addDocument(data);

        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();
        }
    }
    catch (Throwable throwable)
    {
        logger.log(Level.WARNING, "Problems with web service invoke", throwable);
    }
}
 
开发者ID:arjuna-technologies,项目名称:WebService_DataBroker_PlugIn,代码行数:42,代码来源:PushSOAPWebServiceDataSink.java


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