本文整理汇总了Java中org.apache.axiom.soap.SOAPEnvelope.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope.getBody方法的具体用法?Java SOAPEnvelope.getBody怎么用?Java SOAPEnvelope.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.soap.SOAPEnvelope
的用法示例。
在下文中一共展示了SOAPEnvelope.getBody方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processHrefAttributes
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* this method is used to process the href attributes which may comes with the incomming soap mesaage
* <soap:body>
* <operation>
* <arg1 href="#obj1"/>
* </operation>
* <multiref id="obj1">
* <name>the real argument</name>
* <color>blue</color>
* </multiref>
* </soap:body>
* here we assume first child of the soap body has the main object structure and others contain the
* multiref parts.
* Soap spec says that those multiref parts must be top level elements.
*
* @param soapEnvelope
*/
public static void processHrefAttributes(SOAPEnvelope soapEnvelope)
throws AxisFault {
// first populate the multiref parts to a hash table.
SOAPBody soapBody = soapEnvelope.getBody();
// first build the whole tree
soapBody.build();
OMElement omElement = null;
OMAttribute idAttribute = null;
Map idAndOMElementMap = new HashMap();
for (Iterator iter = soapBody.getChildElements(); iter.hasNext();) {
omElement = (OMElement) iter.next();
// the attribute id is an unqualified attribute
idAttribute = omElement.getAttribute(new QName(null, "id"));
if (idAttribute != null) {
// for the first element there may not have an id
idAndOMElementMap.put(idAttribute.getAttributeValue(), omElement);
}
}
// start processing from the first child
processHrefAttributes(idAndOMElementMap, soapBody.getFirstElement(), OMAbstractFactory.getOMFactory());
}
示例2: handleRequest
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private Metadata handleRequest(MessageContext msgContext) throws AxisFault {
Metadata metadata = null;
SOAPEnvelope envelope = msgContext.getEnvelope();
SOAPBody body = envelope.getBody();
OMElement aReq = body.getFirstChildWithName(new QName(
MexConstants.Spec_2004_09.NS_URI,
MexConstants.SPEC.GET_METADATA));
List metadata_request_list;
if (aReq != null) {
mexNamespaceValue = MexConstants.Spec_2004_09.NS_URI;
metadata_request_list = determineMetadataTypes(aReq);
} else {
throw new MexException("Invalid Metadata request");
}
metadata = processRequest(metadata_request_list, msgContext, aReq);
return metadata;
}
示例3: 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);
}
示例4: testCustomBuilder
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testCustomBuilder(){
try{
SOAPEnvelope env = getMockEnvelope();
SOAPHeader header = env.getHeader();
SOAPBody body = env.getBody();
ParserInputStreamCustomBuilder customBuilder = new ParserInputStreamCustomBuilder("UTF-8");
InputStream payload = new ByteArrayInputStream(mockPayload.getBytes());
OMElement om= customBuilder.create("urn:sample", "invokeOp",(OMContainer) body, parser, OMAbstractFactory.getOMFactory(), payload);
assertTrue(om!=null);
assertTrue(om instanceof OMSourcedElement);
OMSourcedElement ose = (OMSourcedElement)om;
assertNotNull(ose.getDataSource());
assertTrue((ose.getDataSource()) instanceof ParserInputStreamDataSource);
}catch(Exception e){
fail(e.getMessage());
}
}
示例5: invoke
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public OMElement invoke(OMElement obj) {
// since this is test code, let's check the inbound obj:
SOAPEnvelope inboundEnv = (SOAPEnvelope)obj;
SOAPBody inboundBody = inboundEnv.getBody();
Iterator it = inboundBody.getChildren();
OMElement el3 = null;
for (;it.hasNext();) {
OMElement el2 = (OMElement)it.next();
Iterator it2 = el2.getChildElements();
for (;it2.hasNext();) {
el3 = (OMElement)it2.next();
assert(el3.getText().equals("SAMPLE REQUEST MESSAGE"));
}
}
assert(el3 != null);
OMElement payload = createPayload();
SOAPFactory factory = new SOAP12Factory();
SOAPEnvelope env = factory.createSOAPEnvelope();
SOAPBody body = factory.createSOAPBody(env);
body.addChild(payload);
return env;
}
示例6: parseOrder
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* @param payload XML message content came inside the JMS message
* @throws XMLStreamException on error
*/
private void parseOrder(String payload) throws XMLStreamException {
InputStream is = new ByteArrayInputStream(payload.getBytes());
javax.xml.stream.XMLStreamReader parser = XMLInputFactory
.newInstance().createXMLStreamReader(is);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser,
null);
SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
// retrieve SOAP body
SOAPBody soapBody = envelope.getBody();
OMElement messageNode = soapBody.getFirstChildWithName(new QName(
FIX_MSG));
Iterator<?> messageElements = (Iterator<?>) messageNode
.getChildElements();
while (messageElements.hasNext()) {
OMElement node = (OMElement) messageElements.next();
if (node.getQName().getLocalPart().equals(FIX_MSG_BODY)) {
Iterator<?> bodyElements = (Iterator<?>) node.getChildElements();
while (bodyElements.hasNext()) {
OMElement bodyNode = (OMElement) bodyElements.next();
String tag = bodyNode
.getAttributeValue(new QName(FIX_MSG_ID));
String value = bodyNode.getText();
if (tag.equals(FIX_MSG_SYMBOL)) {
inSymbol = value;
} else if (tag.equals(FIX_MSG_CLORDID)) {
inClOrderID = value;
} else if (tag.equals(FIX_MSG_ORDQTY)) {
inQty = value;
}
}
}
}
}
示例7: createSoapRequest
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void createSoapRequest(MessageContext msgCtx, Element message, Operation op)
throws AxisFault {
if (op == null) {
throw new NullPointerException("Null operation");
}
// The message can be null if the input message has no part
if (op.getInput().getMessage().getParts().size() > 0 && message == null) {
throw new NullPointerException("Null message.");
}
if (msgCtx == null) {
throw new NullPointerException("Null msgCtx");
}
BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
if (bop == null) {
throw new OdeFault("BindingOperation not found.");
}
BindingInput bi = bop.getBindingInput();
if (bi == null) {
throw new OdeFault("BindingInput not found.");
}
SOAPEnvelope soapEnv = msgCtx.getEnvelope();
if (soapEnv == null) {
soapEnv = soapFactory.getDefaultEnvelope();
msgCtx.setEnvelope(soapEnv);
}
// createSoapHeaders(soapEnv, getSOAPHeaders(bi), op.getInput().getMessage(), message);
SOAPBody soapBody = getSOAPBody(bi);
if (soapBody != null) {
org.apache.axiom.soap.SOAPBody sb = soapEnv.getBody() == null ?
soapFactory.createSOAPBody(soapEnv) : soapEnv.getBody();
createSoapBody(sb, soapBody, op.getInput().getMessage(), message, op.getName());
}
}
示例8: getFirstBodyElement
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private QName getFirstBodyElement(SOAPEnvelope envelope) {
SOAPBody body = envelope.getBody();
if (body != null) {
OMElement firstElement = body.getFirstElement();
if (firstElement != null) {
return firstElement.getQName();
}
}
return null;
}
示例9: testCustomBuilderSOAPENVNamespace
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testCustomBuilderSOAPENVNamespace(){
try{
SOAPEnvelope env = getMockEnvelope();
SOAPHeader header = env.getHeader();
SOAPBody body = env.getBody();
ParserInputStreamCustomBuilder customBuilder = new ParserInputStreamCustomBuilder("UTF-8");
InputStream payload = new ByteArrayInputStream(mockPayload.getBytes());
// If there is no namespace, the customer building should not occur.
OMElement om= customBuilder.create("http://www.w3.org/2003/05/soap-envelope", "Fault",(OMContainer) body, parser, OMAbstractFactory.getOMFactory(), payload);
assertTrue(om==null);
}catch(Exception e){
fail(e.getMessage());
}
}
示例10: run
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void run() {
try {
// send the request and wait for response
MessageContext response = send(msgctx);
// call the callback
if (response != null) {
SOAPEnvelope resenvelope = response.getEnvelope();
if (resenvelope.hasFault()) {
SOAPBody body = resenvelope.getBody();
// If a fault was found, create an AxisFault with a MessageContext so that
// other programming models can deserialize the fault to an alternative form.
AxisFault fault = new AxisFault(body.getFault(), response);
if (axisCallback != null) {
if (options.isExceptionToBeThrownOnSOAPFault()) {
axisCallback.onError(fault);
} else {
axisCallback.onFault(response);
}
}
} else {
if (axisCallback != null) {
axisCallback.onMessage(response);
}
}
}
} catch (Exception e) {
if (axisCallback != null) {
axisCallback.onError(e);
}
} finally {
if (axisCallback != null) {
axisCallback.onComplete();
}
}
}
示例11: run
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void run() {
try {
// send the request and wait for response
final MessageContext response = send(msgctx);
// call the callback
if (response != null) {
final SOAPEnvelope resenvelope = response.getEnvelope();
if (resenvelope.hasFault()) {
final SOAPBody body = resenvelope.getBody();
// If a fault was found, create an AxisFault with a MessageContext so that
// other programming models can deserialize the fault to an alternative form.
final AxisFault fault = new AxisFault(body.getFault(), response);
if (callback != null) {
callback.onError(fault);
} else if (axisCallback != null) {
if (options.isExceptionToBeThrownOnSOAPFault()) {
axisCallback.onError(fault);
} else {
axisCallback.onFault(response);
}
}
} else {
if (callback != null) {
final AsyncResult asyncResult = new AsyncResult(response);
callback.onComplete(asyncResult);
} else if (axisCallback != null) {
axisCallback.onMessage(response);
}
}
}
} catch (final Exception e) {
if (callback != null) {
callback.onError(e);
} else if (axisCallback != null) {
axisCallback.onError(e);
}
} finally {
if (callback != null) {
callback.setComplete(true);
} else if (axisCallback != null) {
axisCallback.onComplete();
}
}
}
示例12: testOMElementDispatchWithParsedEntityReader
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* Test sending a SOAP 1.2 request in MESSAGE mode with
* a Parser that can provide the InputStream for the payload
*/
public void testOMElementDispatchWithParsedEntityReader() throws Exception {
// Subsitute a ParsedEntityReader that will provide the
// payload InputStream. This simulates parsers that provide this
// feature.
ParsedEntityReaderFactory factory = (ParsedEntityReaderFactory)
FactoryRegistry.getFactory(ParsedEntityReaderFactory.class);
ParsedEntityReader per = new ParsedEntityReaderTest();
factory.setParsetEntityReader(per);
try {
// Create the JAX-WS client needed to send the request
Service service = Service.create(QNAME_SERVICE);
service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
Dispatch<OMElement> dispatch = service.createDispatch(
QNAME_PORT, OMElement.class, Mode.MESSAGE);
// Create the OMElement object with the payload contents. Since
// we're in PAYLOAD mode, we don't have to worry about the envelope.
StringReader sr = new StringReader(sampleEnvelope);
XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null);
SOAPEnvelope soap12Envelope = (SOAPEnvelope) builder.getDocumentElement();
// Invoke
OMElement response = dispatch.invoke(soap12Envelope);
SOAPEnvelope responseEnv = (SOAPEnvelope) response;
SOAPBody responseBody = responseEnv.getBody();
OMElement payload = responseBody.getFirstElement();
// At this point, the payload should be an OMSourcedElement
// that was created from the ParsedEntityReader's stream
assertTrue(payload instanceof OMSourcedElement);
// Check to make sure the contents of the message are correct
String responseText = payload.toStringWithConsume();
assertTrue(responseText.contains("TEST RESPONSE"));
} finally {
// Uninstall the Test ParsedEntityReader
factory.setParsetEntityReader(null);
}
}