本文整理汇总了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();
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}