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


Java SOAPMessage.getSOAPPart方法代碼示例

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


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

示例1: addSoapHeader

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

示例2: parseSoapResponseForUrls

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
private void parseSoapResponseForUrls(byte[] data) {
//			System.out.println(new String(data));
			try {
				MessageFactory factory= MessageFactory.newInstance(WS_DISCOVERY_SOAP_VERSION);
				final MimeHeaders headers = new MimeHeaders();
//				headers.addHeader("Content-type", WS_DISCOVERY_CONTENT_TYPE);
				SOAPMessage message = factory.createMessage(headers, new ByteArrayInputStream(data));
				SOAPPart part=message.getSOAPPart();
				SOAPEnvelope env=part.getEnvelope();
				SOAPBody body=message.getSOAPBody();
				NodeList list=body.getElementsByTagNameNS("http://schemas.xmlsoap.org/ws/2005/04/discovery", "XAddrs");
				int items=list.getLength();
				if(items<1)return;
				for (int i = 0; i < items; i++) {
					Node n=list.item(i);
					String raw=n.getTextContent();
					//may contain several
					String []addrArray=raw.split(" ");
					for (String string : addrArray) {
						URL url=new URL(string);
						discovered.add(url);						
					}
				}
			} catch (Exception e) {
				System.out.println("Parse failed");
				e.printStackTrace();
			}

		}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:30,代碼來源:CameraDiscovery.java

示例3: createProbeXML

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

示例4: readAsSOAPMessageSax2Dom

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
    SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
    SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
    try {
        message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
    } catch (SAXException e) {
        throw new SOAPException(e);
    }
    addAttachmentsToSOAPMessage(msg, message);
    if (msg.saveRequired())
        msg.saveChanges();
    return msg;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:SAAJFactory.java

示例5: deserialize

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * Deserializes the given SOAPMessage object to ServiceResponse object. If
 * service producer's namespace URI is given, then it's used for finding the
 * response from the SOAP mesagge's body. Value "*" means that the namespace
 * is ignored.
 *
 * @param message SOAP message to be deserialized
 * @param producerNamespaceURI service producer's namespace URI
 * @param processingWrappers Indicates if "request" and "response" wrappers
 * should be processed
 * @return ServiceResponse object that represents the given SOAPMessage
 * object; if the operation fails, null is returned
 */
@Override
public final ServiceResponse deserialize(final SOAPMessage message, final String producerNamespaceURI, boolean processingWrappers) {
    try {
        LOGGER.debug("Deserialize SOAP message. Producer namespace URI \"{}\".", producerNamespaceURI);
        SOAPPart mySPart = message.getSOAPPart();
        SOAPEnvelope envelope = mySPart.getEnvelope();

        // Deserialize header
        ServiceResponse response = this.deserializeHeader(envelope.getHeader());
        response.setSoapMessage(message);

        // Setting "request" and "response" wrappers processing
        response.setProcessingWrappers(processingWrappers);

        try {
            // Deserialize body
            this.deserializeBody(response, producerNamespaceURI);
        } catch (XRd4JMissingMemberException ex) {
            LOGGER.warn(ex.getMessage(), ex);
            this.deserializeSOAPFault(response);
        }
        LOGGER.debug("SOAP message was succesfully deserialized.");
        return response;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:42,代碼來源:AbstractResponseDeserializer.java

示例6: deserialize

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * Deserializes the given SOAPMessage object to ServiceRequest object. Only
 * SOAP header is deserialized. An application specific serializer is needed
 * for SOAP body.
 *
 * @param message SOAP message to be deserialized
 * @return ServiceRequest object that represents the given SOAPMessage
 * object or null if the operation failed
 * @throws SOAPException if there's a SOAP error
 * @throws XRd4JException if there's a XRd4J error
 */
@Override
public final ServiceRequest deserialize(final SOAPMessage message) throws XRd4JException, SOAPException {
    LOGGER.debug("Deserialize SOAP message.");
    SOAPPart mySPart = message.getSOAPPart();
    SOAPEnvelope envelope = mySPart.getEnvelope();

    // Desearialize header
    ServiceRequest request = this.deserializeHeader(envelope.getHeader());
    request.setSoapMessage(message);

    LOGGER.debug("SOAP message header was succesfully deserialized.");
    return request;
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:25,代碼來源:ServiceRequestDeserializerImpl.java

示例7: testEnvelope

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
public void testEnvelope(String[] args) throws Exception {
    String xmlString =
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
        "                   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
        "                   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
        " <soapenv:Header>\n" +
        "  <shw:Hello xmlns:shw=\"http://localhost:8080/axis/services/MessageService\">\n" +
        "    <shw:Myname>Tony</shw:Myname>\n" +
        "  </shw:Hello>\n" +
        " </soapenv:Header>\n" +
        " <soapenv:Body>\n" +
        "  <shw:process xmlns:shw=\"http://message.samples\">\n" +
        "    <shw:City>GENT</shw:City>\n" +
        "  </shw:process>\n" +
        " </soapenv:Body>\n" +
        "</soapenv:Envelope>";

    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage smsg =
            mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
    SOAPPart sp = smsg.getSOAPPart();
    SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();

    SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = conn.call(smsg, "http://localhost:8080/axis/services/MessageService2");
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:TestMsg.java

示例8: getStockQuote

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
public String getStockQuote(String tickerSymbol) throws Exception {
    SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection con = scFactory.createConnection();

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();

    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();

    SOAPHeader header = envelope.getHeader();
    SOAPBody body = envelope.getBody();

    header.detachNode();

    Name bodyName = envelope.createName("getQuote", "n", "urn:xmethods-delayed-quotes");
    SOAPBodyElement gltp = body.addBodyElement(bodyName);

    Name name = envelope.createName("symbol");
    SOAPElement symbol = gltp.addChildElement(name);
    symbol.addTextNode(tickerSymbol);

    URLEndpoint endpoint = new URLEndpoint("http://64.124.140.30/soap");
    SOAPMessage response = con.call(message, endpoint);
    con.close();

    SOAPPart sp = response.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();
    Iterator it = sb.getChildElements();
    while (it.hasNext()) {
        SOAPBodyElement bodyElement = (SOAPBodyElement) it.next();
        Iterator it2 = bodyElement.getChildElements();
        while (it2.hasNext()) {
            SOAPElement element2 = (SOAPElement) it2.next();
            return element2.getValue();
        }
    }
    return null;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:41,代碼來源:DelayedStockQuote.java

示例9: echoUsingSAAJ

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * This method sends a file as an attachment then 
 *  receives it as a return.  The returned file is
 *  compared to the source. Uses SAAJ API.
 *  @param The filename that is the source to send.
 *  @return True if sent and compared.
 */
public boolean echoUsingSAAJ(String filename) throws Exception {
    String endPointURLString =  "http://localhost:" +opts.getPort() + "/axis/services/urn:EchoAttachmentsService";

    SOAPConnectionFactory soapConnectionFactory =
            javax.xml.soap.SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection =
            soapConnectionFactory.createConnection();

    MessageFactory messageFactory =
            MessageFactory.newInstance();
    SOAPMessage soapMessage =
            messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope requestEnvelope =
            soapPart.getEnvelope();
    SOAPBody body = requestEnvelope.getBody();
    SOAPBodyElement operation = body.addBodyElement
            (requestEnvelope.createName("echo"));

    Vector dataHandlersToAdd = new Vector();
    dataHandlersToAdd.add(new DataHandler(new FileDataSource(new
            File(filename))));

    if (dataHandlersToAdd != null) {
        ListIterator dataHandlerIterator =
                dataHandlersToAdd.listIterator();

        while (dataHandlerIterator.hasNext()) {
            DataHandler dataHandler = (DataHandler)
                    dataHandlerIterator.next();
            javax.xml.soap.SOAPElement element =
                    operation.addChildElement(requestEnvelope.createName("source"));
            javax.xml.soap.AttachmentPart attachment =
                    soapMessage.createAttachmentPart(dataHandler);
            soapMessage.addAttachmentPart(attachment);
            element.addAttribute(requestEnvelope.createName
                                 ("href"), "cid:" + attachment.getContentId());
        }
    }
    javax.xml.soap.SOAPMessage returnedSOAPMessage =
            soapConnection.call(soapMessage, endPointURLString);
    Iterator iterator = returnedSOAPMessage.getAttachments();
    if (!iterator.hasNext()) {
        //The wrong type of object that what was expected.
        System.out.println("Received problem response from server");
        throw new AxisFault("", "Received problem response from server", null, null);

    }
    //Still here, so far so good.
    //Now lets brute force compare the source attachment
    // to the one we received.
    DataHandler rdh = (DataHandler) ((AttachmentPart)iterator.next()).getDataHandler();

    //From here we'll just treat the data resource as file.
    String receivedfileName = rdh.getName();//Get the filename. 

    if (receivedfileName == null) {
        System.err.println("Could not get the file name.");
        throw new AxisFault("", "Could not get the file name.", null, null);
    }


    System.out.println("Going to compare the files..");
    boolean retv = compareFiles(filename, receivedfileName);

    java.io.File receivedFile = new java.io.File(receivedfileName);

    receivedFile.delete();

    return retv;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:79,代碼來源:EchoAttachment.java

示例10: handleMTOMUploads

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
private void handleMTOMUploads(String sessionID, SOAPMessage requestMessage) throws SOAPException, FileNotFoundException, IOException {
	SOAPPart sp = requestMessage.getSOAPPart();
	SOAPEnvelope se = sp.getEnvelope();
	SOAPBody sb = se.getBody();
	handleMTOMUploads(sessionID, sb.getChildElements());
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:7,代碼來源:WebServiceServlet.java

示例11: buildOutputData

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
public Object buildOutputData(Context context, Object convertigoResponse) throws Exception {
       Engine.logBeans.debug("[WebServiceTranslator] Encoding the SOAP response...");
       
       SOAPMessage responseMessage = null;
       String sResponseMessage = "";
	String encodingCharSet = "UTF-8";
	if (context.requestedObject != null)
		encodingCharSet = context.requestedObject.getEncodingCharSet();
       
       if (convertigoResponse instanceof Document) {
		Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is a XML document.");
           Document document = Engine.theApp.schemaManager.makeResponse((Document) convertigoResponse);
           
   		//MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
           MessageFactory messageFactory = MessageFactory.newInstance();
           responseMessage = messageFactory.createMessage();
           
           responseMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encodingCharSet);

           SOAPPart sp = responseMessage.getSOAPPart();
           SOAPEnvelope se = sp.getEnvelope();
           SOAPBody sb = se.getBody();

           sb.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");

       	//se.addNamespaceDeclaration(prefix, targetNameSpace);
           se.addNamespaceDeclaration("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
           se.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
           se.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
           
           // Remove header as it not used. Seems that empty headers causes the WS client of Flex 4 to fail 
           se.getHeader().detachNode();
           
           addSoapElement(context, se, sb, document.getDocumentElement());
           
   		sResponseMessage = SOAPUtils.toString(responseMessage, encodingCharSet);

           // Correct missing "xmlns" (Bug AXA POC client .NET)
   		//sResponseMessage = sResponseMessage.replaceAll("<soapenv:Envelope", "<soapenv:Envelope xmlns=\""+targetNameSpace+"\"");
       }
       else {
		Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is not a XML document.");
       	sResponseMessage = convertigoResponse.toString();
       }
       
       if (Engine.logBeans.isDebugEnabled()) {
		Engine.logBeans.debug("[WebServiceTranslator] SOAP response:\n" + sResponseMessage);
       }
       
       return responseMessage == null ? sResponseMessage.getBytes(encodingCharSet) : responseMessage; 
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:52,代碼來源:WebServiceTranslator.java


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