本文整理汇总了Java中org.apache.axiom.soap.SOAPEnvelope类的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope类的具体用法?Java SOAPEnvelope怎么用?Java SOAPEnvelope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SOAPEnvelope类属于org.apache.axiom.soap包,在下文中一共展示了SOAPEnvelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSOAPHeader
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
private void removeSOAPHeader(MessageDataSource messageDataSource) throws SOAPException {
SOAPEnvelope soapEnvelope = (SOAPEnvelope) messageDataSource.getDataObject();
SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader != null) {
for (Iterator iter = soapHeader.examineAllHeaderBlocks(); iter.hasNext(); ) {
Object o = iter.next();
if (o instanceof SOAPHeaderBlock) {
SOAPHeaderBlock headerBlk = (SOAPHeaderBlock) o;
if (name.equals(headerBlk.getLocalName())) {
headerBlk.detach();
}
} else if (o instanceof OMElement) {
OMElement headerElem = (OMElement) o;
if (name.equals(headerElem.getLocalName())) {
headerElem.detach();
}
}
}
}
}
示例2: createDefaultSOAPEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) {
String soapNamespace = inMsgCtx.getEnvelope().getNamespace()
.getNamespaceURI();
SOAPFactory soapFactory = null;
if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else if (soapNamespace
.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
log.error("Unknown SOAP Envelope");
}
if (soapFactory != null) {
return soapFactory.getDefaultEnvelope();
}
return null;
}
示例3: buildSoapEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader();
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.createOMNamespace(
"http://ws.apache.org/ns/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
SOAPBody body = soapFactory.createSOAPBody();
envelope.addChild(body);
OMElement valueElement = soapFactory.createOMElement("Value", null);
valueElement.setText(value);
body.addChild(valueElement);
return envelope;
}
示例4: buildSoapEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader();
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.
createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
SOAPBody body = soapFactory.createSOAPBody();
envelope.addChild(body);
OMElement valueElement = soapFactory.createOMElement("Value", null);
valueElement.setText(value);
body.addChild(valueElement);
return envelope;
}
示例5: getValue
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
@Override
public Object getValue(String xPath) {
try {
OMElement eval = null;
CarbonXPathImpl carbonXPath = new CarbonXPathImpl(xPath);
if (omElement instanceof SOAPEnvelope) {
eval = ((SOAPEnvelope) omElement).getBody().getFirstElement();
return carbonXPath.evaluate(eval);
} else {
return carbonXPath.evaluate(omElement);
}
} catch (JaxenException e) {
LOGGER.error("Error occurred while evaluating xpath", e);
}
return null;
}
示例6: checkSOAP12
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
protected void checkSOAP12() throws XdsWSException {
if (MessageContext.getCurrentMessageContext().isSOAP11()) {
throwFault("SOAP 1.1 not supported");
}
SOAPEnvelope env = MessageContext.getCurrentMessageContext().getEnvelope();
if (env == null)
throwFault("No SOAP envelope found");
SOAPHeader hdr = env.getHeader();
if (hdr == null)
throwFault("No SOAP header found");
if ( !hdr.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing","Action")).hasNext()) {
throwFault("WS-Action required in header");
}
}
示例7: sendSOAPResponse
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public static String sendSOAPResponse(HttpServletResponse response, OMElement resultElements) {
try {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope responseEnvelope = soapFactory.createSOAPEnvelope();
SOAPBody responseBody = soapFactory.createSOAPBody();
responseBody.addChild(resultElements);
responseEnvelope.addChild(responseBody);
// log the response message
if (Debug.infoOn()) {
Debug.logInfo("SOAP Response Message:\n" + responseEnvelope + "\n", module);
}
response.setContentType(SoapService.XML_TYPE);
OutputStream out = response.getOutputStream();
responseEnvelope.serialize(out);
out.flush();
}
catch (Exception ex) {
Debug.logError("Error invoking soap service " + ex.getMessage(), module);
return "error";
}
return "success";
}
示例8: invoke
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
if (msgContext == null) {
return InvocationResponse.CONTINUE;
}
SOAPEnvelope envelope = msgContext.getEnvelope();
if (envelope.getHeader() == null) {
return InvocationResponse.CONTINUE;
}
// Passing in null will get headers targeted for NEXT and ULTIMATE RECEIVER
Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
while (headerBlocks.hasNext()) {
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
headerBlock.setProcessed();
}
return InvocationResponse.CONTINUE;
}
示例9: setEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
/**
* @param envelope
*/
public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
this.envelope = envelope;
if (this.envelope != null) {
String soapNamespaceURI = envelope.getNamespace().getNamespaceURI();
if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI
.equals(soapNamespaceURI)) {
isSOAP11 = false;
} else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
.equals(soapNamespaceURI)) {
isSOAP11 = true;
} else {
throw new AxisFault(
"Unknown SOAP Version. Current Axis handles only SOAP 1.1 and SOAP 1.2 messages");
}
// Inform the listeners of an attach envelope event
if (getAxisService() != null) {
getAxisService().attachEnvelopeEvent(this);
}
}
}
示例10: testPopulate2
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public void testPopulate2() throws Exception{
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
XMLStreamReader reader2 = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString2.getBytes()));
SOAPFactory soap11Factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope defaultEnvelope = soap11Factory.getDefaultEnvelope();
OMElement documentElement = new StAXOMBuilder(reader).getDocumentElement();
defaultEnvelope.getBody().addChild(documentElement);
OMElement documentElement2 = new StAXOMBuilder(reader2).getDocumentElement();
defaultEnvelope.getHeader().addChild(documentElement2);
XMLStreamReader xmlStreamReader = defaultEnvelope.getBody().getFirstElement().getXMLStreamReader();
while(xmlStreamReader.hasNext()){
System.out.println("event " + xmlStreamReader.next());
System.out.println("text " + (xmlStreamReader.hasText()?xmlStreamReader.getText():""));
System.out.println("localName " + (xmlStreamReader.hasName()?xmlStreamReader.getLocalName():""));
}
}
示例11: XMLSpineImpl
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
/**
* Create a lightweight representation of this protocol (i.e. the Envelope, Header and Body)
*
* @param protocol Protocol
* @param style Style
* @param indirection (0 or 1) indicates location of body blocks
* @param initialPayload (OMElement or null...used to add rest payload)
*/
public XMLSpineImpl(Protocol protocol, Style style, int indirection, OMElement payload) {
super();
this.protocol = protocol;
this.style = style;
this.indirection = indirection;
soapFactory = _getFactory(protocol);
root = _createEmptyEnvelope(style, soapFactory);
if (payload != null) {
((SOAPEnvelope)root).getBody().addChild(payload);
}
}
示例12: invokeBusinessLogic
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public final void invokeBusinessLogic(MessageContext mc) throws AxisFault {
try {
processMessage(mc);
} catch (WSEventException e) {
log.error("An exception occured. Unable to Process Request", e);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String details = sw.toString();
pw.close();
SOAPEnvelope soapEnvelope = BuilderUtils.genFaultResponse(
EventingConstants.WSE_FAULT_CODE_RECEIVER, "EventSourceUnableToProcess",
e.getMessage(), details, mc.isSOAP11());
dispatchResponse(soapEnvelope, EventingConstants.WSA_FAULT, mc, true);
}
}
示例13: createXMLFault
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public static XMLFault createXMLFault(Block b, Protocol p) {
// Because of the requirement that we have a full SOAP envelope structure as
// the input to the StAXSOAPModelBuilder, we have to have a dummy envelope
// that wraps our fault. This will allow the Axiom SOAPFault object to
// be created.
Message m = null;
try {
MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
m = mf.create(p);
m.setBodyBlock(b);
} catch (XMLStreamException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
SOAPEnvelope dummyEnv = (SOAPEnvelope) m.getAsOMElement();
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
SOAPEnvelope newEnv = (SOAPEnvelope) builder.getDocumentElement();
SOAPBody body = newEnv.getBody();
SOAPFault fault = body.getFault();
Block[] details = getDetailBlocks(fault);
return XMLFaultUtils.createXMLFault(fault, details);
}
示例14: testSoapOMSerialization
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
public void testSoapOMSerialization() throws Exception {
TestLogger.logger.debug("---------------------------------------");
TestLogger.logger.debug("test: " + getName());
OMElement payload = createPayload();
SOAPFactory factory = new SOAP11Factory();
SOAPEnvelope env = factory.createSOAPEnvelope();
SOAPBody body = factory.createSOAPBody(env);
body.addChild(payload);
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
format.setSOAP11(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
env.serializeAndConsume(baos, format);
TestLogger.logger.debug("==================================");
TestLogger.logger.debug(baos.toString());
TestLogger.logger.debug("==================================");
}
示例15: handleResponse
import org.apache.axiom.soap.SOAPEnvelope; //导入依赖的package包/类
/**
* If there is a fault then need to handle that
* @param responseMessageContext responseMessageContext
* @throws AxisFault
*/
protected void handleResponse(MessageContext responseMessageContext) throws AxisFault {
SOAPEnvelope envelope = responseMessageContext.getEnvelope();
if (envelope == null) {
// If request is REST we assume the responseMessageContext is REST, so
// set the variable
InputStream inStream = (InputStream) responseMessageContext.
getProperty(MessageContext.TRANSPORT_IN);
if (inStream != null && checkContentLength(responseMessageContext)) {
envelope = TransportUtils.createSOAPMessage(
responseMessageContext);
responseMessageContext.setEnvelope(envelope);
}
responseMessageContext.setEnvelope(envelope);
}
if (envelope != null) {
if (envelope.hasFault()|| responseMessageContext.isProcessingFault()) {
//receiving a fault
AxisEngine.receive(responseMessageContext);
throw Utils.getInboundFaultFromMessageContext(responseMessageContext);
}
}
}