Search in sources :

Example 11 with SOAPMessage

use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.

the class AxiomSoapMessageFactoryTest method testCreateWebServiceMessage.

/**
 * Regression test for <a href="https://issues.apache.org/jira/browse/AXIOM-444">AXIOM-444</a>.
 *
 * @throws Exception
 */
public void testCreateWebServiceMessage() throws Exception {
    AxiomSoapMessageFactory mf = new AxiomSoapMessageFactory();
    mf.afterPropertiesSet();
    AxiomSoapMessage swsMessage = mf.createWebServiceMessage();
    SOAPMessage message = swsMessage.getAxiomMessage();
    // Spring-WS uses SOAPFactory#createSOAPMessage(OMXMLParserWrapper) with a null argument.
    // We need to make sure that we nevertheless get a SOAPMessage that is in state complete.
    assertTrue(message.isComplete());
}
Also used : AxiomSoapMessageFactory(org.springframework.ws.soap.axiom.AxiomSoapMessageFactory) AxiomSoapMessage(org.springframework.ws.soap.axiom.AxiomSoapMessage) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 12 with SOAPMessage

use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.

the class TestCreateSOAPModelBuilderFromSAXSource method runTest.

@Override
protected void runTest() throws Throwable {
    SAXParserFactory parserFactory = SAXImplementation.XERCES.newSAXParserFactory();
    parserFactory.setNamespaceAware(true);
    XMLReader reader = parserFactory.newSAXParser().getXMLReader();
    SOAPSample sample = SOAPSampleSet.SIMPLE_FAULT.getMessage(spec);
    InputStream in = sample.getInputStream();
    InputSource is = new InputSource(in);
    is.setEncoding(sample.getEncoding());
    SOAPMessage message = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new SAXSource(reader, is)).getSOAPMessage();
    assertAbout(xml()).that(xml(OMDocument.class, message)).ignoringWhitespaceInPrologAndEpilog().hasSameContentAs(sample.getEnvelope());
    assertThat(message.getSOAPEnvelope().getBody().getFault()).isNotNull();
}
Also used : InputSource(org.xml.sax.InputSource) SAXSource(javax.xml.transform.sax.SAXSource) InputStream(java.io.InputStream) SOAPSample(org.apache.axiom.ts.soap.SOAPSample) SOAPMessage(org.apache.axiom.soap.SOAPMessage) XMLReader(org.xml.sax.XMLReader) SAXParserFactory(javax.xml.parsers.SAXParserFactory) OMDocument(org.apache.axiom.om.OMDocument)

Example 13 with SOAPMessage

use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.

the class TestLazySOAPFactorySelection method runTest.

@Override
protected void runTest() throws Throwable {
    // Create a SOAP model builder without specifying the SOAP version.
    SOAPMessage message = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, SOAPSampleSet.NO_HEADER.getMessage(spec).getInputStream(), null).getSOAPMessage();
    // In some Axiom versions, this failed because at this stage, the SOAPFactory instance
    // has not yet been determined.
    ((Document) message).createElementNS("urn:test", "p:test");
}
Also used : Document(org.w3c.dom.Document) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 14 with SOAPMessage

use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.

the class TestSerialize method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPMessage soapMessage = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, message.getInputStream(), null).getSOAPMessage();
    expansionStrategy.apply(soapMessage);
    assertAbout(xml()).that(serializationStrategy.serialize(soapMessage).getInputSource()).ignoringRedundantNamespaceDeclarations().hasSameContentAs(message.getInputStream());
    soapMessage.close(false);
}
Also used : SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 15 with SOAPMessage

use of org.apache.axiom.soap.SOAPMessage in project webservices-axiom by apache.

the class WSS4JTest method testSignature.

private void testSignature(String file, Vector<WSEncryptionPart> parts) throws Exception {
    WSSecSignature sign = new WSSecSignature();
    sign.setUserInfo("key1", "password");
    sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
    sign.setParts(parts);
    SOAPMessage message = load(file);
    Document doc = (Document) message;
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);
    Document signedDoc = sign.build(doc, crypto, secHeader);
    WSSecurityEngine secEngine = new WSSecurityEngine();
    assertThat(secEngine.processSecurityHeader(signedDoc, null, null, crypto)).hasSize(2);
}
Also used : WSSecHeader(org.apache.ws.security.message.WSSecHeader) WSSecSignature(org.apache.ws.security.message.WSSecSignature) WSSecurityEngine(org.apache.ws.security.WSSecurityEngine) Document(org.w3c.dom.Document) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Aggregations

SOAPMessage (org.apache.axiom.soap.SOAPMessage)16 OMDocument (org.apache.axiom.om.OMDocument)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)4 Document (org.w3c.dom.Document)4 OMElement (org.apache.axiom.om.OMElement)3 SOAPSampleAdapter (org.apache.axiom.ts.soap.SOAPSampleAdapter)3 OMCloneOptions (org.apache.axiom.om.OMCloneOptions)2 OMInformationItem (org.apache.axiom.om.OMInformationItem)2 OMNode (org.apache.axiom.om.OMNode)2 WSSecHeader (org.apache.ws.security.message.WSSecHeader)2 InputSource (org.xml.sax.InputSource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Vector (java.util.Vector)1 QName (javax.xml.namespace.QName)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 DOMSource (javax.xml.transform.dom.DOMSource)1 SAXSource (javax.xml.transform.sax.SAXSource)1 OMComment (org.apache.axiom.om.OMComment)1