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


Java SOAPPart.getEnvelope方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPPart.getEnvelope方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPPart.getEnvelope方法的具體用法?Java SOAPPart.getEnvelope怎麽用?Java SOAPPart.getEnvelope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPPart的用法示例。


在下文中一共展示了SOAPPart.getEnvelope方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createXPath

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Constructs XPath query over the SOAP message
 * 
 * @param query XPath query
 * @param response SOAP message
 * @return XPath query
 * @throws SOAPException in case of SOAP issue
 * @throws JaxenException XPath problem
 */
public final XPath createXPath(final String query, final SOAPMessage response) throws SOAPException, JaxenException {

  /* Uses DOM to XPath mapping */
  final XPath xpath = new DOMXPath(query);

  /* Define a namespaces used in response */
  final SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
  final SOAPPart sp = response.getSOAPPart();
  final SOAPEnvelope env = sp.getEnvelope();
  final SOAPBody bdy = env.getBody();

  /* Add namespaces from SOAP envelope */
  addNamespaces(nsContext, env);

  /* Add namespaces of top body element */
  final Iterator<?> bodyElements = bdy.getChildElements();
  while (bodyElements.hasNext()) {
    SOAPElement element = (SOAPElement) bodyElements.next();
    addNamespaces(nsContext, element);
  }
  xpath.setNamespaceContext(nsContext);
  return xpath;
}
 
開發者ID:inbravo,項目名稱:scribe,代碼行數:33,代碼來源:SOAPExecutor.java

示例2: createSOAPRequestMessage

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * createSOAPRequestMessage - create a SOAP message from an object
 *
 * @param webServiceKey
 *            key to locate the web service
 * @param request
 *            - request body content
 * @param action
 *            - SOAP Action string
 * @return SOAPMessage
 * @throws SOAPException
 *             - if there was an error creating the SOAP Connection
 * @throws JAXBException
 *             - if there was an error marshalling the SOAP Message
 */
private SOAPMessage createSOAPRequestMessage(String webServiceKey, Object request, String action) throws SOAPException, JAXBException {
    WebService service = getWebService(webServiceKey);

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();

    // SOAP Envelope
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("example", service.getNamespaceURI());

    if (action != null) {
        MimeHeaders headers = message.getMimeHeaders();
        headers.addHeader("SOAPAction", service.getNamespaceURI() + "VerifyEmail");
    }

    // SOAP Body
    SOAPBody body = message.getSOAPBody();

    marshallObject(webServiceKey, request, body);

    message.saveChanges();
    return message;
}
 
開發者ID:AgileTestingFramework,項目名稱:atf-toolbox-java,代碼行數:40,代碼來源:WebServiceAutomationManager.java

示例3: testSendReceiveMessageWithEmptyNSPrefix

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
@Validated @Test
public void testSendReceiveMessageWithEmptyNSPrefix() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage request = mf.createMessage();

    SOAPPart sPart = request.getSOAPPart();
    SOAPEnvelope env = sPart.getEnvelope();
    SOAPBody body = env.getBody();

    //Namespace prefix is empty
    body.addBodyElement(new QName("http://fakeNamespace2.org","echo"))
    							.addTextNode("This is some text");

    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = sCon.call(request, getAddress());
    assertFalse(response.getAttachments().hasNext());
    assertEquals(0, response.countAttachments());

    String requestStr = printSOAPMessage(request);
    String responseStr = printSOAPMessage(response);
    assertTrue(responseStr.indexOf("echo") > -1);
    sCon.close();
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:IntegrationTest.java

示例4: addSoapHeader

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
protected void addSoapHeader(SOAPMessage soapMessage) throws SOAPException, NoSuchAlgorithmException {
	onvifDevice.createNonce();
	String encrypedPassword = onvifDevice.getEncryptedPassword();
	if (encrypedPassword != null && onvifDevice.getUsername() != null) {

		SOAPPart sp = soapMessage.getSOAPPart();
		SOAPEnvelope se = sp.getEnvelope();
		SOAPHeader header = soapMessage.getSOAPHeader();
		se.addNamespaceDeclaration("wsse",
				"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
		se.addNamespaceDeclaration("wsu",
				"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");

		SOAPElement securityElem = header.addChildElement("Security", "wsse");
		// securityElem.setAttribute("SOAP-ENV:mustUnderstand", "1");

		SOAPElement usernameTokenElem = securityElem.addChildElement("UsernameToken", "wsse");

		SOAPElement usernameElem = usernameTokenElem.addChildElement("Username", "wsse");
		usernameElem.setTextContent(onvifDevice.getUsername());

		SOAPElement passwordElem = usernameTokenElem.addChildElement("Password", "wsse");
		passwordElem.setAttribute("Type",
				"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
		passwordElem.setTextContent(encrypedPassword);

		SOAPElement nonceElem = usernameTokenElem.addChildElement("Nonce", "wsse");
		nonceElem.setAttribute("EncodingType",
				"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
		nonceElem.setTextContent(onvifDevice.getEncryptedNonce());

		SOAPElement createdElem = usernameTokenElem.addChildElement("Created", "wsu");
		createdElem.setTextContent(onvifDevice.getLastUTCTime());
	}
}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:36,代碼來源:SoapClient.java

示例5: create

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public static SOAPMessage create() throws SOAPException {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage message = messageFactory.createMessage();
    SOAPPart soapPart = message.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("codecentric", "https://www.codecentric.de");

    SOAPBody envelopeBody = envelope.getBody();
    SOAPElement soapBodyElem = envelopeBody.addChildElement("location", "codecentric");

    SOAPElement place = soapBodyElem.addChildElement("place", "codecentric");
    place.addTextNode("Berlin");

    MimeHeaders headers = message.getMimeHeaders();
    headers.addHeader("SOAPAction", "https://www.codecentric.de/location");

    message.saveChanges();
    return message;
}
 
開發者ID:hill-daniel,項目名稱:soap-wrapper-lambda,代碼行數:21,代碼來源:ExampleSoapMessage.java

示例6: processSOAP

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public SOAPMessage processSOAP(Exchange exchange) {
    // Since the Camel-CXF endpoint uses a list to store the parameters
    // and bean component uses the bodyAs expression to get the value
    // we'll need to deal with the parameters ourself
    SOAPMessage soapMessage = (SOAPMessage)exchange.getIn().getBody(List.class).get(0);
    if (soapMessage == null) {
        System.out.println("Incoming null message detected...");
        return createDefaultSoapMessage("Greetings from Apache Camel!!!!", "null");
    }

    try {
        SOAPPart sp = soapMessage.getSOAPPart();
        SOAPEnvelope se = sp.getEnvelope();
        SOAPBody sb = se.getBody();
        String requestText = sb.getFirstChild().getTextContent();
        System.out.println(requestText);
        return createDefaultSoapMessage("Greetings from Apache Camel!!!!", requestText);
    } catch (Exception e) {
        e.printStackTrace();
        return createDefaultSoapMessage("Greetings from Apache Camel!!!!", e.getClass().getName());
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:TesterBean.java

示例7: testProviderMessageNullResponse

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
@Test
@RunAsClient
public void testProviderMessageNullResponse() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(msgStringForNullResponse.getBytes()));

   URL epURL = baseURL;
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   if (resMsg != null)
   {
      SOAPPart soapPart = resMsg.getSOAPPart();
      //verify there's either nothing in the reply or at least the response body is empty
      if (soapPart != null && soapPart.getEnvelope() != null && soapPart.getEnvelope().getBody() != null)
      {
         SOAPBody soapBody = soapPart.getEnvelope().getBody();
         assertFalse(soapBody.getChildElements().hasNext());
      }
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:ProviderMessageTestCase.java

示例8: getDatasources

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Return an array of the datasources in the server, could be null
 * @return array of datasources
 */
public DataSourceTreeElement[] getDatasources() {
	setRequestType("DISCOVER_DATASOURCES");
	SOAPMessage response = executeDiscover(new HashMap<String, String>());
	SOAPPart soapPart = response.getSOAPPart();
	SOAPEnvelope soapEnvelope;
	try {			 
		soapEnvelope = soapPart.getEnvelope();
		SOAPElement rowSet = getRowsSet(response, soapEnvelope);
		List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
		Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
		Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
		while (rowValuesElement.hasNext())
		{
			SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
			result.add(new DataSourceElement(this, cellElement));
		}
		return result.toArray(new DataSourceTreeElement[result.size()]);
	} catch (SOAPException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:27,代碼來源:MetadataDiscover.java

示例9: getCatalogList

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Return an array of the catalogs in the server for a specific datasource, could be null
 * @param datasourceName the name of the datasource
 * @return array of catalogs
 */
public DataSourceTreeElement[] getCatalogList(String datasourceName) {
    setRequestType("DBSCHEMA_CATALOGS");
    HashMap<String, String> param = new HashMap<String, String>();
    param.put("DataSourceInfo", datasourceName);
	SOAPMessage response = executeDiscover(param);
	SOAPPart soapPart = response.getSOAPPart();
	SOAPEnvelope soapEnvelope;
	try {
		soapEnvelope = soapPart.getEnvelope();
		SOAPElement rowSet = getRowsSet(response, soapEnvelope);
		List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
		Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
		Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
		while (rowValuesElement.hasNext())
		{
			SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
			result.add(new CatalogElement(this, cellElement, datasourceName));
		}
		return result.toArray(new DataSourceTreeElement[result.size()]);
	} catch (SOAPException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:30,代碼來源:MetadataDiscover.java

示例10: getCubeList

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Return an array of the cubes in the server for a specific datasource and catalog, could be null
 * @param datasourceName the name of the datasource
 * @param catalogName the name of the catalog
 * @return array of cubes
 */
public DataSourceTreeElement[] getCubeList(String datasourceName, String catalogName) {
    setRequestType("MDSCHEMA_CUBES");
    HashMap<String, String> param = new HashMap<String, String>();
    param.put("DataSourceInfo", datasourceName);
    param.put("Catalog", catalogName);
	SOAPMessage response = executeDiscover(param);
	SOAPPart soapPart = response.getSOAPPart();
	SOAPEnvelope soapEnvelope;
	try {
		soapEnvelope = soapPart.getEnvelope();
		SOAPElement rowSet = getRowsSet(response, soapEnvelope);
		List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
		Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
		Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
		while (rowValuesElement.hasNext())
		{
			SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
			result.add(new CubeElement(this, cellElement, datasourceName));
		}
		return result.toArray(new DataSourceTreeElement[result.size()]);
	} catch (SOAPException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:32,代碼來源:MetadataDiscover.java

示例11: _testGetFaultReasonTexts

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public void _testGetFaultReasonTexts() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.addFaultReasonText("de-myReason", new Locale("de"));
    soapFault.addFaultReasonText("si-myReason", new Locale("si"));
    soapMessage.saveChanges();
    Iterator reasonTexts = soapFault.getFaultReasonTexts();
    while (reasonTexts.hasNext()) {
        String reasonText = (String)reasonTexts.next();
        assertNotNull(reasonText);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例12: testAddingPrefixesForChildElements

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
@Validated @Test
public void testAddingPrefixesForChildElements() throws Exception {
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage msg = factory.createMessage();
    SOAPPart sp = msg.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();
    SOAPElement el1 = sb.addBodyElement(se.createName("element1",
                                                      "prefix1",
                                                      "http://www.sun.com"));
    el1.addChildElement(se.createName("element2",
                                      "prefix2",
                                      "http://www.apache.org"));

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    msg.writeTo(baos);

    String xml = new String(baos.toByteArray());
    assertTrue(xml.indexOf("prefix1") != -1);
    assertTrue(xml.indexOf("prefix2") != -1);
    assertTrue(xml.indexOf("http://www.sun.com") != -1);
    assertTrue(xml.indexOf("http://www.apache.org") != -1);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:PrefixesTest.java

示例13: test_parentAccess2

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
/**
 * Check parent processing of SOAPMessage
 */
// TODO: check why this fails with Sun's SAAJ implementation
@Test
public void test_parentAccess2() throws Exception {

    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage m = mf.createMessage();
    SOAPPart sp = m.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    Node node = se.getParentNode();
    assertTrue(node == sp);
    node = node.getParentNode();
    assertTrue(node == null);

    SOAPElement e = se.getParentElement();
    assertTrue(node == null);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPPartTest.java

示例14: _testEnvelopeWithLeadingComment

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public void _testEnvelopeWithLeadingComment() throws Exception {
    String soapMessageWithLeadingComment =
            "<?xml version='1.0' encoding='UTF-8'?>" +
                    "<!-- Comment -->" +
                    "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
                    "<env:Body><echo><arg0>Hello</arg0></echo></env:Body>" +
                    "</env:Envelope>";

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message =
            factory.createMessage(new MimeHeaders(),
                                  new ByteArrayInputStream(
                                          soapMessageWithLeadingComment.getBytes()));
    SOAPPart part = message.getSOAPPart();
    SOAPEnvelope envelope = part.getEnvelope();
    message.writeTo(System.out);
    assertTrue(envelope != null);
    assertTrue(envelope.getBody() != null);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPEnvelopeTest.java

示例15: _testGetFaultCodeAsQName

import javax.xml.soap.SOAPPart; //導入方法依賴的package包/類
public void _testGetFaultCodeAsQName() throws Exception {
    //MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    MessageFactory fac = MessageFactory.newInstance();

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.setFaultCode("mycode");
    soapMessage.saveChanges();

    QName qname = soapFault.getFaultCodeAsQName();
    assertNotNull(qname);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:19,代碼來源:SOAPFaultTest.java


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