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();
}
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);
}
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);
}
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));
}
Aggregations