本文整理汇总了Java中javax.xml.soap.SOAPMessage.saveChanges方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPMessage.saveChanges方法的具体用法?Java SOAPMessage.saveChanges怎么用?Java SOAPMessage.saveChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPMessage
的用法示例。
在下文中一共展示了SOAPMessage.saveChanges方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
private SOAPMessage createMessage(MessageFactory mf) throws SOAPException, IOException {
SOAPMessage msg = mf.createMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
Name name = envelope.createName("hello", "ex", "http://example.com");
envelope.getBody().addChildElement(name).addTextNode("THERE!");
String s = "<root><hello>THERE!</hello></root>";
AttachmentPart ap = msg.createAttachmentPart(
new StreamSource(new ByteArrayInputStream(s.getBytes())),
"text/xml"
);
msg.addAttachmentPart(ap);
msg.saveChanges();
return msg;
}
示例2: toString
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public static String toString(SOAPMessage soapMessage, String encoding) throws TransformerConfigurationException, TransformerException, SOAPException, IOException, ParserConfigurationException, SAXException {
soapMessage.saveChanges();
if (encoding == null) { // #3803
Engine.logEngine.warn("(SOAPUtils) encoding is null. Set encoding to UTF-8 for toString.");
encoding = "UTF-8";
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
soapMessage.writeTo(out);
String s = new String(out.toByteArray(), encoding);
s = XMLUtils.prettyPrintDOMWithEncoding(s, encoding);
// Ticket #2678: fix empty "xmlns"
s = s.replaceAll("\\sxmlns=\"\"", "");
return s;
}
示例3: handleMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
/**
* The method is invoked for normal processing of outbound messages.
*
* @param context
* the message context.
* @return An indication of whether handler processing should continue for
* the current message. Return <code>true</code> to continue
* processing.
*
* @throws Exception
* Causes the JAX-WS runtime to cease fault message processing.
**/
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean request_p = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (request_p.booleanValue()) {
try {
SOAPMessage msg = context.getMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader hdr = env.getHeader();
if (hdr == null) {
hdr = env.addHeader();
}
QName qname_user = new QName("http://com/auth/", "auth");
SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
helem_user.setActor(VERSION);
if (version != null && version.trim().length() != 0) {
helem_user.addTextNode(version);
}
msg.saveChanges();
message = soapMessage2String(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}
示例4: handleMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
/**
* The method is invoked for normal processing of outbound messages.
*
* @param context
* the message context.
* @return An indication of whether handler processing should continue for
* the current message. Return <code>true</code> to continue
* processing.
*
* @throws Exception
* Causes the JAX-WS runtime to cease fault message processing.
**/
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean request_p = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (request_p.booleanValue()) {
try {
SOAPMessage msg = context.getMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader hdr = env.getHeader();
if (hdr == null) {
hdr = env.addHeader();
}
QName qname_user = new QName("http://com/auth/", "auth");
SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
helem_user.setActor(VERSION);
if (version == null || version.trim().length() == 0) {
helem_user.addTextNode(apiVersionInfo.getProperty(VERSION));
} else {
helem_user.addTextNode(version);
}
msg.saveChanges();
message = soapMessage2String(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}
示例5: processSoapMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
private SOAPMessage processSoapMessage(Object request, boolean needAuthentification) throws Exception {
// get new each time?
SOAPMessage soapMessage = messageFactory.createMessage();
Document document = documentBuilder.newDocument();
// get new each time?
Marshaller marshaller = getMarshaller(request.getClass());
marshaller.marshal(request, document);
soapMessage.getSOAPBody().addDocument(document);
if (needAuthentification) {
addSoapHeader(soapMessage);
}
soapMessage.saveChanges();
return soapMessage;
}
示例6: transportHeaders
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
private void transportHeaders(Packet packet, boolean inbound, SOAPMessage msg) throws SOAPException {
Map<String, List<String>> headers = getTransportHeaders(packet, inbound);
if (headers != null) {
addSOAPMimeHeaders(msg.getMimeHeaders(), headers);
}
if (msg.saveRequired()) msg.saveChanges();
}
示例7: readAsSOAPMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
/**
* Reads Message as SOAPMessage. After this call message is consumed.
* @param soapVersion SOAP version
* @param message Message
* @return Created SOAPMessage
* @throws SOAPException if SAAJ processing fails
*/
public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
SaajStaxWriter writer = new SaajStaxWriter(msg);
try {
message.writeTo(writer);
} catch (XMLStreamException e) {
throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
}
msg = writer.getSOAPMessage();
addAttachmentsToSOAPMessage(msg, message);
if (msg.saveRequired())
msg.saveChanges();
return msg;
}
示例8: 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;
}
示例9: searchUDDI
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public static void searchUDDI(String name, String url) throws Exception {
// Create the connection and the message factory.
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
MessageFactory msgFactory = MessageFactory.newInstance();
// Create a message
SOAPMessage msg = msgFactory.createMessage();
// Create an envelope in the message
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
// Get hold of the the body
SOAPBody body = envelope.getBody();
javax.xml.soap.SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("find_business", "",
"urn:uddi-org:api"));
bodyElement.addAttribute(envelope.createName("generic"), "1.0")
.addAttribute(envelope.createName("maxRows"), "100")
.addChildElement("name")
.addTextNode(name);
URLEndpoint endpoint = new URLEndpoint(url);
msg.saveChanges();
SOAPMessage reply = connection.call(msg, endpoint);
//System.out.println("Received reply from: " + endpoint);
//reply.writeTo(System.out);
connection.close();
}
示例10: readAsSOAPMessage
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
/**
* Reads Message as SOAPMessage. After this call message is consumed.
* @param soapVersion SOAP version
* @param message Message
* @return Created SOAPMessage
* @throws SOAPException if SAAJ processing fails
*/
public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
SaajStaxWriter writer = new SaajStaxWriter(msg, soapVersion.nsUri);
try {
message.writeTo(writer);
} catch (XMLStreamException e) {
throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
}
msg = writer.getSOAPMessage();
addAttachmentsToSOAPMessage(msg, message);
if (msg.saveRequired())
msg.saveChanges();
return msg;
}