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


Java SOAPEnvelope.addNamespaceDeclaration方法代碼示例

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


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

示例1: createSOAPRequestMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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

示例2: addSoapHeader

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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

示例3: create

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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

示例4: WsDiscoveryS11SOAPMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
 * Create SOAP message of specified action type containing a JAXB element.
 * 
 * @param action Action type.
 * @param jaxb JAXB element.
 */
public WsDiscoveryS11SOAPMessage(WsDiscoveryActionTypes action, JAXBElement<E> jaxb) throws SOAPOverUDPException {
    super(WsDiscoveryConstants.defaultSoapProtocol, WsDiscoveryConstants.defaultEncoding);

    instanceId = WsDiscoveryConstants.instanceId;
    sequenceId = "urn:uuid:" + WsDiscoveryConstants.sequenceId;
    messageNumber = ++lastMessageNumber;
    
    try {
        SOAPEnvelope e = soapMessage.getSOAPPart().getEnvelope();
        e.addNamespaceDeclaration("wsd", namespace.getWsDiscoveryNamespace());
        e.addNamespaceDeclaration("wsa", namespace.getWsAddressingNamespace());
    } catch (SOAPException ex) {
        throw new SOAPOverUDPException("Unable to read SOAP envelope");
    }

    this.setAction(action.toURI());
    // Initialize to anonymous recipient
    this.setTo(URI.create("urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01"));
    this.setJAXBBody(jaxb);
}
 
開發者ID:nateridderman,項目名稱:java-ws-discovery,代碼行數:27,代碼來源:WsDiscoveryS11SOAPMessage.java

示例5: WsDiscoveryD2005SOAPMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
 * Create SOAP message of specified action type containing a JAXB element.
 * 
 * @param action Action type.
 * @param jaxb JAXB element.
 */
public WsDiscoveryD2005SOAPMessage(WsDiscoveryActionTypes action, JAXBElement<E> jaxb) throws SOAPOverUDPException {
    super(WsDiscoveryConstants.defaultSoapProtocol, WsDiscoveryConstants.defaultEncoding);

    instanceId = WsDiscoveryConstants.instanceId;
    sequenceId = "urn:uuid:" + WsDiscoveryConstants.sequenceId;
    messageNumber = ++lastMessageNumber;
    
    try {
        SOAPEnvelope e = soapMessage.getSOAPPart().getEnvelope();
        e.addNamespaceDeclaration("wsd", namespace.getWsDiscoveryNamespace());
        e.addNamespaceDeclaration("wsa", namespace.getWsAddressingNamespace());
    } catch (SOAPException ex) {
        throw new SOAPOverUDPException("Unable to read SOAP envelope");
    }

    this.setAction(action.toURI());
    // Initialize to anonymous recipient
    this.setTo(URI.create(namespace.getWsAddressingNamespace() + "/role/anonymous"));
    this.setJAXBBody(jaxb);
}
 
開發者ID:nateridderman,項目名稱:java-ws-discovery,代碼行數:27,代碼來源:WsDiscoveryD2005SOAPMessage.java

示例6: setOutputEncodingStyle

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private void setOutputEncodingStyle( SOAPEnvelope soapEnvelope, String operationName )
	throws IOException, SOAPException
{
	Port port = getWSDLPort();
	if ( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		if ( bindingOperation == null ) {
			return;
		}
		BindingOutput output = bindingOperation.getBindingOutput();
		if ( output == null ) {
			return;
		}
		for( ExtensibilityElement element : (List<ExtensibilityElement>) output.getExtensibilityElements() ) {
			if ( element instanceof javax.wsdl.extensions.soap.SOAPBody ) {
				List<String> list = ((javax.wsdl.extensions.soap.SOAPBody) element).getEncodingStyles();
				if ( list != null && list.isEmpty() == false ) {
					soapEnvelope.setEncodingStyle( list.get( 0 ) );
					soapEnvelope.addNamespaceDeclaration( "enc", list.get( 0 ) );
				}
			}
		}
	}
}
 
開發者ID:jolie,項目名稱:jolie,代碼行數:25,代碼來源:SoapProtocol.java

示例7: doWithMessage

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
  callback.doWithMessage(message);
  try {
    SaajSoapMessage saajMessage = (SaajSoapMessage) message;
    SOAPMessage soapmess = saajMessage.getSaajMessage();
    SOAPEnvelope env = soapmess.getSOAPPart().getEnvelope();
    env.addNamespaceDeclaration("xro", "http://x-road.ee/xsd/x-road.xsd");
    Iterator headers = env.getHeader().getChildElements();
    while (headers.hasNext()) {
      SOAPElement header = (SOAPElement) headers.next();
      if (header.getNamespaceURI().equalsIgnoreCase("http://x-rd.net/xsd/xroad.xsd")) {
        String localHeaderName = header.getLocalName();
        QName qName = new QName("http://x-road.ee/xsd/x-road.xsd", localHeaderName, "xro");
        header.setElementQName(qName);
      }
    }
  } catch (SOAPException e) {
    throw new RuntimeException(e);
  }

}
 
開發者ID:nortal,項目名稱:j-road,代碼行數:22,代碼來源:Adsv5XTeeServiceImpl.java

示例8: testAddDetailsTwice

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testAddDetailsTwice() throws Exception {
    MessageFactory fac = MessageFactory.newInstance();

    //Create the response to the message
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();

    body.addFault().addDetail();
    try {
        body.getFault().addDetail();
        fail("Expected Exception did not occur");
    } catch (SOAPException e) {
        assertTrue(true);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPFaultTest.java

示例9: testAppendSubCode

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testAppendSubCode() 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();
    QName qname = new QName("http://example.com", "myfault1", "flt1");
    soapFault.appendFaultSubcode(qname);

    QName qname2 = new QName("http://example2.com", "myfault2", "flt2");
    soapFault.appendFaultSubcode(qname2);

    QName qname3 = new QName("http://example3.com", "myfault3", "flt3");
    soapFault.appendFaultSubcode(qname3);

    soapMessage.saveChanges();

    Iterator faultSubCodes = soapFault.getFaultSubcodes();
    assertNotNull(faultSubCodes);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:SOAPFaultTest.java

示例10: _testGetFaultReasonTexts

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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

示例11: _testGetFaultReasonText

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public void _testGetFaultReasonText() 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();

    String faultReasonText = soapFault.getFaultReasonText(new Locale("si"));
    assertNotNull(faultReasonText);
    faultReasonText = soapFault.getFaultReasonText(new Locale("ja"));
    assertNull(faultReasonText);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例12: _testGetFaultCodeAsQName

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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

示例13: createProbeXML

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private byte[] createProbeXML() throws SOAPException, IOException {
	MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
	SOAPMessage message = messageFactory.createMessage();
	SOAPPart part = message.getSOAPPart();
	SOAPEnvelope envelope = part.getEnvelope();
	envelope.addNamespaceDeclaration("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
	envelope.addNamespaceDeclaration("tns", "http://schemas.xmlsoap.org/ws/2005/04/discovery");
	envelope.addNamespaceDeclaration("nns", "http://www.onvif.org/ver10/network/wsdl");
	QName action = envelope.createQName("Action", "wsa");
	QName mid = envelope.createQName("MessageID", "wsa");
	QName to = envelope.createQName("To", "wsa");
	QName probe = envelope.createQName("Probe", "tns");
	QName types = envelope.createQName("Types", "tns");
	QName tramsmitter=envelope.createQName("NetworkVideoTransmitter", "nns");
	SOAPHeader header = envelope.getHeader();
	SOAPElement actionEl = header.addChildElement(action);
	actionEl.setTextContent("http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe");
	SOAPElement messIsEl = header.addChildElement(mid);
	messIsEl.setTextContent("urn:uuid:" + UUID.randomUUID().toString());
	SOAPElement toEl = header.addChildElement(to);
	toEl.setTextContent("urn:schemas-xmlsoap-org:ws:2005:04:discovery");
	SOAPBody body = envelope.getBody();
	SOAPElement probeEl = body.addChildElement(probe);
	SOAPElement typesEl=probeEl.addChildElement(types);
	typesEl.setTextContent("nns:NetworkVideoTransmitter");
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	message.writeTo(out);
	return out.toByteArray();
}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:30,代碼來源:CameraDiscovery.java

示例14: createVerifyEmailSOAPRequest

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
 * createVerifyEmailSOAPRequest
 * 
 * @param emailToVerify
 *            email input
 * @param licenseKey
 *            licenseKey input
 * @return the SOAP Request message
 * @throws Exception
 * 
 *             <SOAP-ENV:Envelope xmlns:SOAP-ENV=
 *             "http://schemas.xmlsoap.org/soap/envelope/" xmlns:example=
 *             "http://ws.cdyne.com/"> <SOAP-ENV:Header/> <SOAP-ENV:Body>
 *             <example:VerifyEmail> <example:email>?</example:email>
 *             <example:LicenseKey>?</example:LicenseKey>
 *             </example:VerifyEmail> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
 */
private SOAPMessage createVerifyEmailSOAPRequest(String emailToVerify, String licenseKey) throws Exception {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

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

    // SOAP Body
    SOAPBody soapBody = envelope.getBody();
    SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
    SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example");
    soapBodyElem1.addTextNode(emailToVerify);

    SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("LicenseKey", "example");
    soapBodyElem2.addTextNode(licenseKey);

    MimeHeaders headers = soapMessage.getMimeHeaders();
    headers.addHeader("SOAPAction", getNamespaceURI() + "VerifyEmail");

    soapMessage.saveChanges();

    ATFHandler.getInstance().getWebServiceAutomation().logSOAPMessage(soapMessage, "Request");

    return soapMessage;
}
 
開發者ID:AgileTestingFramework,項目名稱:atf-toolbox-java,代碼行數:45,代碼來源:VerifyEmailSoapService.java

示例15: create

import javax.xml.soap.SOAPEnvelope; //導入方法依賴的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");

    SOAPElement position = soapBodyElem.addChildElement("position", "codecentric");

    SOAPElement latitude = position.addChildElement("latitude", "codecentric");
    latitude.addTextNode("52.510818");
    SOAPElement longitude = position.addChildElement("longitude", "codecentric");
    longitude.addTextNode("13.372008");

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

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


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