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


Java SOAPMessage.getSOAPBody方法代碼示例

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


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

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

示例2: xmlStrToSOAPElement

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

示例3: getFaultActionFromSEIModel

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
    String action = null;
    if (seiModel == null || wsdlPort == null) {
        return action;
    }

    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }

        if (sm.getSOAPBody() == null) {
            return action;
        }

        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }

        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }

        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();

        WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
        JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl)wsdlOp.getJavaMethod() : null;
        if (jm != null) {
          for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
              if (ce.getDetailType().tagName.getLocalPart().equals(name) &&
                      ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
                  return ce.getFaultAction();
              }
          }
        }
        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:44,代碼來源:WsaTubeHelper.java

示例4: getFaultAction

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
    String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
    if (action != null) {
        return action;
    }

    action = addVer.getDefaultFaultAction();
    if (wbo == null) {
        return action;
    }

    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }

        if (sm.getSOAPBody() == null) {
            return action;
        }

        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }

        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }

        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();

        WSDLOperation o = wbo.getOperation();

        WSDLFault fault = o.getFault(new QName(ns, name));
        if (fault == null) {
            return action;
        }

        action = fault.getAction();

        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:48,代碼來源:WsaTubeHelper.java


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