本文整理汇总了Java中javax.xml.soap.SOAPHeaderElement.addTextNode方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPHeaderElement.addTextNode方法的具体用法?Java SOAPHeaderElement.addTextNode怎么用?Java SOAPHeaderElement.addTextNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPHeaderElement
的用法示例。
在下文中一共展示了SOAPHeaderElement.addTextNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的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;
}
示例2: handleMessage
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的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;
}
示例3: writeTo
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(av.faultDetailTag);
she = header.addHeaderElement(new QName(av.nsUri, wrapper));
she.addTextNode(problemValue);
}
示例4: writeTo
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(name);
if(mustUnderstand) {
she.setMustUnderstand(true);
}
she.addTextNode(value);
}
示例5: writeTo
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart()));
she.addChildElement(actionLocalName);
she.addTextNode(action);
if (soapAction != null) {
she.addChildElement(soapActionLocalName);
she.addTextNode(soapAction);
}
}
示例6: writeTo
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(name);
if (type != null)
she.addAttribute(typeAttributeName, type);
she.addTextNode(value);
}
示例7: sendJaxmMsg
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private void sendJaxmMsg (String aMsg, String u) {
try {
System.setProperty("javax.net.ssl.trustStore", u);
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope envelope = sp.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
SOAPHeaderElement headerElement = header.addHeaderElement(envelope.createName("OSCAR", "DT", "http://www.oscarhome.org/"));
headerElement.addTextNode("header");
SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("Service"));
bodyElement.addTextNode("compete");
AttachmentPart ap1 = message.createAttachmentPart();
ap1.setContent(aMsg, "text/plain");
message.addAttachmentPart(ap1);
URLEndpoint endPoint = new URLEndpoint (URLService); //"https://67.69.12.115:8443/OscarComm/DummyReceiver");
SOAPMessage reply = connection.call(message, endPoint);
connection.close();
} catch (Exception e) {
MiscUtils.getLogger().error("Error", e);
}
}
示例8: handleMessage
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (isRequest) {
try {
SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnv.getHeader();
if (soapHeader == null) {
soapHeader = soapEnv.addHeader();
}
QName qname = new QName("http://www.2n.cz/2013/event", "SubscriptionId");
SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(qname);
soapHeaderElement.addAttribute(
new QName("http://www.w3.org/2005/08/addressing", "IsReferenceParameter"), "true");
if (handler.getSubscriptionID() != null) {
soapHeaderElement.addTextNode(handler.getSubscriptionID());
}
soapMsg.saveChanges();
} catch (Exception e) {
logger.debug("An exception occurred while formatting a SOAP header : '{}'", e.getMessage());
}
}
return true;
}
示例9: sendJaxmMsg
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private void sendJaxmMsg (String aMsg, String u) {
try {
System.setProperty("javax.net.ssl.trustStore", u);
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope envelope = sp.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
SOAPHeaderElement headerElement = header.addHeaderElement(envelope.createName("OSCAR", "DT", "http://www.oscarhome.org/"));
headerElement.addTextNode("header");
SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("Service"));
bodyElement.addTextNode("compete");
AttachmentPart ap1 = message.createAttachmentPart();
ap1.setContent(aMsg, "text/plain");
message.addAttachmentPart(ap1);
URLEndpoint endPoint = new URLEndpoint (URLService); //"https://67.69.12.115:8443/OscarComm/DummyReceiver");
SOAPMessage reply = connection.call(message, endPoint);
connection.close();
} catch (Throwable e) {
MiscUtils.getLogger().error("Error", e);
}
}
示例10: handleMessage
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext messageContext) {
HeaderDetails cd = config.getClientDetails();
HeaderDetails sd = config.getServiceDetails();
if (config.getRequestIdGenerator() != null) {
requestIdGenerator = config.getRequestIdGenerator();
}
Boolean outboundProperty = (Boolean) messageContext
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
SOAPMessage soapMsg = messageContext.getMessage();
SOAPEnvelope soapEnv;
if (outboundProperty.booleanValue()) {
try {
soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPHeader header = soapEnv.getHeader();
if (header == null) {
header = soapEnv.addHeader();
}
String id = requestIdGenerator.generateId();
JAXBElement<String> idElement = factory.createId(id);
SOAPHeaderElement idHeaderElement = header
.addHeaderElement(idElement.getName());
idHeaderElement.addTextNode(idElement.getValue());
JAXBElement<String> protocolVersionElement = factory.createProtocolVersion("4.0");
SOAPHeaderElement protocolVersionHeaderElement = header.addHeaderElement(protocolVersionElement.getName());
protocolVersionHeaderElement.addTextNode(protocolVersionElement.getValue());
JAXBElement<String> userIdElement = factory
.createUserId(userId);
SOAPHeaderElement uidHeaderElement = header
.addHeaderElement(userIdElement.getName());
uidHeaderElement.addTextNode(userIdElement.getValue());
XRoadClientIdentifierType clientHeaderType = factory.createXRoadClientIdentifierType();
JAXBElement<XRoadClientIdentifierType> clientElement = factory.createClient(clientHeaderType);
clientHeaderType.setObjectType(XRoadObjectType.SUBSYSTEM);
clientHeaderType.setXRoadInstance(cd.getXRoadInstance());
clientHeaderType.setMemberClass(cd.getMemberClass());
clientHeaderType.setMemberCode(cd.getMemberCode());
clientHeaderType.setSubsystemCode(cd.getSubsystemCode());
Marshaller marshaller;
marshaller = JAXBContext.newInstance(
XRoadClientIdentifierType.class).createMarshaller();
marshaller.marshal(clientElement, header);
XRoadServiceIdentifierType serviceHeaderType = factory
.createXRoadServiceIdentifierType();
JAXBElement<XRoadServiceIdentifierType> serviceElement = factory
.createService(serviceHeaderType);
serviceHeaderType.setObjectType(XRoadObjectType.SERVICE);
serviceHeaderType.setXRoadInstance(sd.getXRoadInstance());
serviceHeaderType.setMemberClass(sd.getMemberClass());
serviceHeaderType.setMemberCode(sd.getMemberCode());
serviceHeaderType.setSubsystemCode(sd.getSubsystemCode());
serviceHeaderType.setServiceVersion(sd.getVersion());
serviceHeaderType.setServiceCode(serviceDetails.getXRoadServiceCode());
marshaller = JAXBContext.newInstance(
XRoadServiceIdentifierType.class).createMarshaller();
marshaller.marshal(serviceElement, header);
soapMsg.saveChanges();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return true;
}
示例11: testHeaders
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
@Validated @Test
public void testHeaders() {
try {
// Create message factory and SOAP factory
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPFactory soapFactory = SOAPFactory.newInstance();
// Create a message
SOAPMessage message = messageFactory.createMessage();
// Get the SOAP header from the message and
// add headers to it
SOAPHeader header = message.getSOAPHeader();
String nameSpace = "ns";
String nameSpaceURI = "http://gizmos.com/NSURI";
Name order =
soapFactory.createName("orderDesk", nameSpace, nameSpaceURI);
SOAPHeaderElement orderHeader = header.addHeaderElement(order);
orderHeader.setActor("http://gizmos.com/orders");
Name shipping =
soapFactory.createName("shippingDesk", nameSpace, nameSpaceURI);
SOAPHeaderElement shippingHeader =
header.addHeaderElement(shipping);
shippingHeader.setActor("http://gizmos.com/shipping");
Name confirmation =
soapFactory.createName("confirmationDesk", nameSpace,
nameSpaceURI);
SOAPHeaderElement confirmationHeader =
header.addHeaderElement(confirmation);
confirmationHeader.setActor("http://gizmos.com/confirmations");
Name billing =
soapFactory.createName("billingDesk", nameSpace, nameSpaceURI);
SOAPHeaderElement billingHeader = header.addHeaderElement(billing);
billingHeader.setActor("http://gizmos.com/billing");
// Add header with mustUnderstand attribute
Name tName =
soapFactory.createName("Transaction", "t",
"http://gizmos.com/orders");
SOAPHeaderElement transaction = header.addHeaderElement(tName);
transaction.setMustUnderstand(true);
transaction.addTextNode("5");
// Get the SOAP body from the message but leave
// it empty
SOAPBody body = message.getSOAPBody();
message.saveChanges();
// Display the message that would be sent
//System.out.println("\n----- Request Message ----\n");
//message.writeTo(System.out);
// Look at the headers
Iterator allHeaders = header.examineAllHeaderElements();
while (allHeaders.hasNext()) {
SOAPHeaderElement headerElement =
(SOAPHeaderElement)allHeaders.next();
Name headerName = headerElement.getElementName();
//System.out.println("\nHeader name is " +
// headerName.getQualifiedName());
//System.out.println("Actor is " + headerElement.getActor());
//System.out.println("mustUnderstand is " +
// headerElement.getMustUnderstand());
}
} catch (Exception e) {
fail("Enexpected Exception " + e);
}
}