Search in sources :

Example 1 with SOAPFactory

use of javax.xml.soap.SOAPFactory in project quickstarts by jboss-switchyard.

the class ReverseService method reverse.

@POST
@Path("/")
@WebMethod(action = "urn:switchyard-quickstart:camel-soap-proxy:1.0")
@WebResult(name = "text")
public String reverse(@WebParam(name = "text") String text) throws Exception {
    if (text.equals("fault")) {
        SOAPFactory factory = SOAPFactory.newInstance();
        SOAPFault sf = factory.createFault("myfaultstring", new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"));
        sf.setFaultActor("myFaultActor");
        Detail d = sf.addDetail();
        QName entryName = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "order", "PO");
        DetailEntry entry = d.addDetailEntry(entryName);
        QName name = new QName("urn:switchyard-quickstart:camel-soap-proxy:1.0", "symbol");
        SOAPElement symbol = entry.addChildElement(name);
        symbol.addTextNode("SUNW");
        throw new SOAPFaultException(sf);
    }
    return new StringBuilder(text).reverse().toString();
}
Also used : QName(javax.xml.namespace.QName) DetailEntry(javax.xml.soap.DetailEntry) SOAPElement(javax.xml.soap.SOAPElement) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFactory(javax.xml.soap.SOAPFactory) Detail(javax.xml.soap.Detail) Path(javax.ws.rs.Path) WebMethod(javax.jws.WebMethod) POST(javax.ws.rs.POST) WebResult(javax.jws.WebResult)

Example 2 with SOAPFactory

use of javax.xml.soap.SOAPFactory in project webservices-axiom by apache.

the class TestGetOwnerDocument method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFactory factory = saajImplementation.newSOAPFactory(protocol);
    Document doc = factory.createElement(new QName("test")).getOwnerDocument();
    assertThat(doc).isNotInstanceOf(SOAPPart.class);
    assertThat(doc).isNotInstanceOf(javax.xml.soap.Node.class);
    assertThat(doc.createElementNS(null, "test")).isInstanceOf(SOAPElement.class);
}
Also used : QName(javax.xml.namespace.QName) Document(org.w3c.dom.Document) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 3 with SOAPFactory

use of javax.xml.soap.SOAPFactory in project ddf by codice.

the class GuestInterceptor method createAddressing.

private void createAddressing(SoapMessage message, SOAPMessage soapMessage) {
    SOAPFactory soapFactory;
    try {
        soapFactory = SOAPFactory.newInstance();
    } catch (SOAPException e) {
        LOGGER.debug("Could not create a SOAPFactory.", e);
        // can't add anything if we can't create it
        return;
    }
    String addressingProperty = org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND;
    AddressingProperties addressingProperties = new AddressingProperties();
    try {
        SOAPElement action = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_ACTION_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
        action.addTextNode((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
        AttributedURIType attributedString = new AttributedURIType();
        String actionValue = StringUtils.defaultIfEmpty((String) message.get(SoapBindingConstants.SOAP_ACTION), "");
        attributedString.setValue(actionValue);
        addressingProperties.setAction(attributedString);
        soapMessage.getSOAPHeader().addChildElement(action);
    } catch (SOAPException e) {
        LOGGER.debug("Unable to add addressing action.", e);
    }
    try {
        SOAPElement messageId = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_MESSAGEID_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
        String uuid = "urn:uuid:" + UUID.randomUUID().toString();
        messageId.addTextNode(uuid);
        AttributedURIType attributedString = new AttributedURIType();
        attributedString.setValue(uuid);
        addressingProperties.setMessageID(attributedString);
        soapMessage.getSOAPHeader().addChildElement(messageId);
    } catch (SOAPException e) {
        LOGGER.debug("Unable to add addressing messageId.", e);
    }
    try {
        SOAPElement to = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_TO_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
        to.addTextNode((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
        EndpointReferenceType endpointReferenceType = new EndpointReferenceType();
        AttributedURIType attributedString = new AttributedURIType();
        attributedString.setValue((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
        endpointReferenceType.setAddress(attributedString);
        addressingProperties.setTo(endpointReferenceType);
        soapMessage.getSOAPHeader().addChildElement(to);
    } catch (SOAPException e) {
        LOGGER.debug("Unable to add addressing to.", e);
    }
    try {
        SOAPElement replyTo = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_REPLYTO_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
        SOAPElement address = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_ADDRESS_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
        address.addTextNode(org.apache.cxf.ws.addressing.Names.WSA_ANONYMOUS_ADDRESS);
        replyTo.addChildElement(address);
        soapMessage.getSOAPHeader().addChildElement(replyTo);
    } catch (SOAPException e) {
        LOGGER.debug("Unable to add addressing replyTo.", e);
    }
    message.put(addressingProperty, addressingProperties);
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 4 with SOAPFactory

use of javax.xml.soap.SOAPFactory in project webservices-axiom by apache.

the class TestSetParentElement method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFactory factory = saajImplementation.newSOAPFactory(protocol);
    SOAPElement parent = factory.createElement(new QName("parent"));
    SOAPElement child1 = parent.addChildElement(new QName("child1"));
    SOAPElement child2 = (SOAPElement) parent.getOwnerDocument().createElementNS(null, "child2");
    child2.setParentElement(parent);
    NodeList children = parent.getChildNodes();
    assertEquals(2, children.getLength());
    assertSame(child1, children.item(0));
    assertSame(child2, children.item(1));
}
Also used : QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) SOAPElement(javax.xml.soap.SOAPElement) SOAPFactory(javax.xml.soap.SOAPFactory)

Aggregations

SOAPFactory (javax.xml.soap.SOAPFactory)4 QName (javax.xml.namespace.QName)3 SOAPElement (javax.xml.soap.SOAPElement)3 WebMethod (javax.jws.WebMethod)1 WebResult (javax.jws.WebResult)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Detail (javax.xml.soap.Detail)1 DetailEntry (javax.xml.soap.DetailEntry)1 SOAPException (javax.xml.soap.SOAPException)1 SOAPFault (javax.xml.soap.SOAPFault)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1