本文整理汇总了Java中org.apache.axiom.soap.SOAPEnvelope.build方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope.build方法的具体用法?Java SOAPEnvelope.build怎么用?Java SOAPEnvelope.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.soap.SOAPEnvelope
的用法示例。
在下文中一共展示了SOAPEnvelope.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToAxiom
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* Converts a {@link Document} representation of the SOAP Envelope into a Axiom representation.
*
* @param document The standard DOM representation of the SOAP Envelope
* @return An {@link SOAPEnvelope} object containing the Axiom representation of the SOAP envelope, or <br>
* <code>null</code> if the conversion fails
*/
public static SOAPEnvelope convertToAxiom(final Document document) {
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLUtils.outputDOM(document.getDocumentElement(), os, true);
final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray());
final SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(bais, null);
final SOAPEnvelope env = stAXSOAPModelBuilder.getSOAPEnvelope();
env.build();
return env;
} catch (final Exception e) {
// If anything goes wrong converting the document, just return null
return null;
}
}
示例2: testConvertToDOOM
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testConvertToDOOM() throws Exception {
String xml = "<?xml version='1.0' encoding='utf-8'?>" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soapenv:Body><ns1:createAccountRequest xmlns:ns1=\"http://www.wso2.com/types\">" +
"<clientinfo xmlns=\"http://www.wso2.com/types\"><name>bob</name><ssn>123456789</ssn></clientinfo>" +
"<password xmlns=\"\">passwd</password></ns1:createAccountRequest></soapenv:Body></soapenv:Envelope>";
StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(
getTestEnvelope().getXMLStreamReader(),
DOOMAbstractFactory.getSOAP11Factory(),
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
SOAPEnvelope envelope = builder2.getSOAPEnvelope();
envelope.build();
StringWriter writer = new StringWriter();
envelope.serialize(writer);
writer.flush();
String s2 = writer.toString();
assertXMLEqual(s2, xml);
}
示例3: getDocumentFromSOAPEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* Create a DOM Document using the org.apache.axiom.soap.SOAPEnvelope
*
* @param env An org.apache.axiom.soap.SOAPEnvelope instance
* @return the DOM Document of the given SOAP Envelope
*/
public static Document getDocumentFromSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
env.build();
//Check the namespace and find SOAP version and factory
String nsURI;
SOAPFactory factory;
if (env.getNamespace().getNamespaceURI()
.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
factory = DOOMAbstractFactory.getSOAP11Factory();
} else {
nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
factory = DOOMAbstractFactory.getSOAP12Factory();
}
StAXSOAPModelBuilder stAXSOAPModelBuilder =
new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
envelope.build();
Element envElem = (Element)envelope;
return envElem.getOwnerDocument();
}
示例4: toDOOMSOAPEnvelope
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
/**
* Create a DOM Document using the org.apache.axiom.soap.SOAPEnvelope
*
* @param env An org.apache.axiom.soap.SOAPEnvelope instance
* @return the org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl of the given SOAP Envelope
*/
public static org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl
toDOOMSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
env.build();
//Check the namespace and find SOAP version and factory
String nsURI;
SOAPFactory factory;
if (env.getNamespace().getNamespaceURI()
.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
factory = DOOMAbstractFactory.getSOAP11Factory();
} else {
nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
factory = DOOMAbstractFactory.getSOAP11Factory();
}
StAXSOAPModelBuilder stAXSOAPModelBuilder =
new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
envelope.build();
return (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)envelope;
}
示例5: getBSTHeader
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private String getBSTHeader(Request request) throws IOException, XMLStreamException {
org.apache.coyote.Request coyoteReq = request.getCoyoteRequest();
InputBuffer buf = coyoteReq.getInputBuffer();
ByteChunk bc = new ByteChunk();
buf.doRead(bc, coyoteReq);
try (InputStream is = new ByteArrayInputStream(getUTF8Bytes(bc.toString()))) {
XMLStreamReader reader = StAXUtils.createXMLStreamReader(is);
StAXBuilder builder = new StAXSOAPModelBuilder(reader);
SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
envelope.build();
SOAPHeader header = envelope.getHeader();
Iterator headerEls = header.getChildrenWithLocalName("Security");
if (!headerEls.hasNext()) {
return null;
}
OMElement securityHeader = (OMElement) headerEls.next();
Iterator securityHeaderEls = securityHeader.getChildrenWithLocalName("BinarySecurityToken");
if (!securityHeaderEls.hasNext()) {
return null;
}
OMElement bstHeader = (OMElement) securityHeaderEls.next();
bstHeader.build();
return bstHeader.getText();
}
}
示例6: testConvertToDOOM2
import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public void testConvertToDOOM2() throws Exception {
String xml =
"<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><ns1:createAccountRequest xmlns:ns1=\"http://www.wso2.com/types\"><ns1:clientinfo><name xmlns=\"\">bob</name><ssn xmlns=\"\">123456789</ssn></ns1:clientinfo><password xmlns=\"\">passwd</password></ns1:createAccountRequest></soapenv:Body></soapenv:Envelope>";
CreateAccountRequest request = new CreateAccountRequest();
ClientInfo clientInfo = new ClientInfo();
clientInfo.setName("bob");
clientInfo.setSsn("123456789");
request.setClientInfo(clientInfo);
request.setPassword("passwd");
ADBSOAPModelBuilder builder = new ADBSOAPModelBuilder(request
.getPullParser(CreateAccountRequest.MY_QNAME),
OMAbstractFactory.getSOAP11Factory());
SOAPEnvelope env = builder.getEnvelope();
StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(
getTestEnvelope().getXMLStreamReaderWithoutCaching(),
DOOMAbstractFactory.getSOAP11Factory(),
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
SOAPEnvelope envelope = builder2.getSOAPEnvelope();
envelope.build();
StringWriter writer = new StringWriter();
envelope.serialize(writer);
writer.flush();
XMLStreamReader r = StAXUtils.createXMLStreamReader(new StringReader(writer.toString()));
PrintEvents.print(r);
//TODO: FIXME. Simpler test in testPrintEvents2
//assertXMLEqual(writer.toString(),xml);
}