本文整理汇总了Java中org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder类的典型用法代码示例。如果您正苦于以下问题:Java StAXSOAPModelBuilder类的具体用法?Java StAXSOAPModelBuilder怎么用?Java StAXSOAPModelBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StAXSOAPModelBuilder类属于org.apache.axiom.soap.impl.builder包,在下文中一共展示了StAXSOAPModelBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBuilder
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Creates an OMBuilder for a plain XML message.
*
* @param inStream InputStream for a XML message
* @param charSetEnc Character set encoding to be used
* @return Handler to a OMBuilder implementation instance
* @throws javax.xml.stream.XMLStreamException
*/
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
示例2: getSOAPBuilder
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Creates an OMBuilder for a SOAP message. Default character set encording is used.
*
* @param inStream InputStream for a SOAP message
* @return Handler to a OMBuilder implementation instance
* @throws javax.xml.stream.XMLStreamException
*/
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream) , "UTF-8") + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
示例3: testConvertToDOOM
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的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);
}
示例4: createXMLFault
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的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);
}
示例5: toOM
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
private org.apache.axiom.soap.SOAPEnvelope toOM(String xml)
throws WebServiceException {
if (log.isDebugEnabled()) {
log.debug("Converting SAAJ SOAPEnvelope String to an OM SOAPEnvelope");
log.debug("The conversion occurs due to " + JavaUtils.stackToString());
}
XMLStreamReader reader;
try {
reader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xml.getBytes()));
} catch (XMLStreamException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
// Get a SOAP OM Builder. Passing null causes the version to be automatically triggered
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);
// Create and return the OM Envelope
return builder.getSOAPEnvelope();
}
示例6: getBuilder
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Creates an OMBuilder for a plain XML message.
*
* @param inStream InputStream for a XML message
* @param charSetEnc Character set encoding to be used
* @return Handler to a OMBuilder implementation instance
* @throws XMLStreamException
*/
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc)
throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
示例7: getSOAPBuilder
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Creates an OMBuilder for a SOAP message. Default character set encording is used.
*
* @param inStream InputStream for a SOAP message
* @return Handler to a OMBuilder implementation instance
* @throws XMLStreamException
*/
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
try {
return new StAXSOAPModelBuilder(xmlReader);
} catch (OMException e) {
log.info("OMException in getSOAPBuilder", e);
try {
log.info("Remaining input stream :[" +
new String(IOUtils.getStreamAsByteArray(inStream)) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
示例8: testOMElementDispatchMessageMode
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Test sending a SOAP 1.2 request in MESSAGE mode
*/
public void testOMElementDispatchMessageMode() throws Exception {
// Create the JAX-WS client needed to send the request
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
Dispatch<OMElement> dispatch = service.createDispatch(
portName, 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(SOAP11_ENVELOPE_HEAD+request+SOAP11_ENVELOPE_TAIL);
XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null);
SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
OMElement response = dispatch.invoke(om);
String responseText = response.toStringWithConsume();
assertTrue(responseText.contains("soap"));
assertTrue(responseText.contains("Body"));
assertTrue(responseText.contains("Envelope"));
assertTrue(responseText.contains("Hello Dispatch OM"));
}
示例9: testOMElementDispatchMessageModeSOAPFaultException
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
/**
* Test sending a SOAP 1.2 request in MESSAGE mode
*/
public void testOMElementDispatchMessageModeSOAPFaultException() throws Exception {
// Create the JAX-WS client needed to send the request
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
Dispatch<OMElement> dispatch = service.createDispatch(
portName, OMElement.class, Mode.MESSAGE);
StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null);
SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
OMElement response = null;
try{
response = dispatch.invoke(om);
String responseText = response.toStringWithConsume();
}catch(Exception e){
assertTrue(e instanceof SOAPFaultException);
}
assertTrue(response ==null);
}
示例10: testOMElementDispatchMessageModeSOAPFault
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
public void testOMElementDispatchMessageModeSOAPFault() throws Exception {
// Create the JAX-WS client needed to send the request
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
Dispatch<OMElement> dispatch = service.createDispatch(
portName, OMElement.class, Mode.MESSAGE);
BindingProvider bp = (BindingProvider)dispatch;
bp.getRequestContext().put(Constants.THROW_EXCEPTION_IF_SOAP_FAULT, Boolean.FALSE);
StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null);
SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
OMElement response = null;
try{
response = dispatch.invoke(om);
String responseText = response.toStringWithConsume();
}catch(Exception e){
fail();
}
assertTrue(response !=null);
assertTrue(response instanceof OMElement);
}
示例11: invoke
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
public OMElement invoke(OMElement om) throws SOAPFaultException{
try{
StringReader sr = null;
if(om!=null){
String requestText = om.toStringWithConsume();
if(requestText.contains("SOAPFault")){
throwSOAPFaultException();
}
if((requestText.contains("Hello Provider OM"))){
sr = new StringReader(SOAP11_ENVELOPE_HEAD+response+SOAP11_ENVELOPE_TAIL);
}
if((!requestText.contains("Hello Provider OM"))){
sr = new StringReader(SOAP11_ENVELOPE_HEAD+"ack:received OM"+SOAP11_ENVELOPE_TAIL);
}
}else{
sr = new StringReader(SOAP11_ENVELOPE_HEAD+"null request"+SOAP11_ENVELOPE_TAIL);
}
XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null);
SOAPEnvelope responseOM = (SOAPEnvelope) builder.getDocumentElement();
return responseOM;
}catch(Exception e){
throw new WebServiceException(e);
}
}
示例12: getDocumentFromSOAPEnvelope
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的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();
}
示例13: toDOOMSOAPEnvelope
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的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;
}
示例14: assertSoapyEquals
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
private void assertSoapyEquals(String expected, String actual) throws Exception{
XMLStreamReader expectedParser = XMLInputFactory.newInstance()
.createXMLStreamReader(
new TestServletInputStream(expected));
StAXSOAPModelBuilder expectedBuilder = new StAXSOAPModelBuilder(expectedParser);
XMLStreamReader actualParser = XMLInputFactory.newInstance()
.createXMLStreamReader(
new TestServletInputStream(expected));
StAXSOAPModelBuilder actualBuilder = new StAXSOAPModelBuilder(actualParser);
assertHeaders(expectedBuilder.getSOAPEnvelope().getHeader(), actualBuilder.getSOAPEnvelope().getHeader());
assertBody(expectedBuilder.getSOAPEnvelope().getBody(), actualBuilder.getSOAPEnvelope().getBody());
try {
xmlTestCase.assertXMLEqual(expected, actual);
}
catch (AssertionFailedError afe) {
StringBuilder sb = new StringBuilder();
sb.append("Expected:\n" + expected + "\n");
sb.append("Actual:\n"+actual+"\n");
sb.append(afe.getMessage());
throw new AssertionFailedError(sb.toString());
}
}
示例15: buildSoapEnvelope
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入依赖的package包/类
private static SOAPEnvelope buildSoapEnvelope() {
String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">\n" +
" <soapenv:Body>\n" +
" <ns1:Project xmlns:ns1=\"http://axis2.apache.org/sample\">\n" +
" <ns1:Developer>\n" +
" <ns1:name>AAA</ns1:name>\n" +
" <ns1:location>Colombo</ns1:location>\n" +
" </ns1:Developer>\n" +
" </ns1:Project>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
SOAPEnvelope soapEnvelope = null;
try {
XMLStreamReader xmlStreamReader =
StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(xmlStreamReader);
soapEnvelope = stAXSOAPModelBuilder.getSOAPEnvelope();
} catch (XMLStreamException e) {
e.printStackTrace();
}
return soapEnvelope;
}