use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class JAXBTest method testJAXBElementMarshalling.
public void testJAXBElementMarshalling() throws Exception {
JAXBRIContext jc = (JAXBRIContext) JAXBContext.newInstance(whitebox.jaxb.client.DetailType.class);
DetailType dt = new DetailType();
SOAPFault sf = createFault();
dt.getDetails().add(sf.getDetail());
Marshaller m = jc.createMarshaller();
m.marshal(dt, System.out);
XMLStreamBufferResult sbr = new XMLStreamBufferResult();
m.setProperty(Marshaller.JAXB_FRAGMENT, true);
m.marshal(dt, sbr);
XMLStreamBuffer infoset = sbr.getXMLStreamBuffer();
XMLStreamReader reader = infoset.readAsXMLStreamReader();
if (reader.getEventType() == START_DOCUMENT)
XMLStreamReaderUtil.nextElementContent(reader);
verifyDetail(reader);
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class JAXBTest method createFault.
private static SOAPFault createFault() throws Exception {
SOAPFactory fac = SOAPFactory.newInstance();
SOAPFault sf = fac.createFault("This is a fault.", new QName("http://schemas.xmlsoap.org/wsdl/soap/http", "Client"));
Detail d = sf.addDetail();
SOAPElement de = d.addChildElement(DETAIL1_QNAME);
de.addAttribute(new QName("", "msg1"), "This is the first detail message.");
return sf;
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class WsaTestImpl method createSOAPFault.
SOAPFault createSOAPFault(String message) {
try {
SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
fault.setFaultString(message);
fault.setFaultCode(new QName("http://example.org/echo", "EmptyEchoString"));
return fault;
} catch (SOAPException ex) {
throw new WebServiceException(ex);
}
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class NonAnonymousClientTest method test1194.
/**
* SOAP 1.1 two-way message with a non-anonymous ReplyTo and FaultTo address.
*/
public void test1194() throws Exception {
invokeAsync(createDispatchForNonAnonymousWithWSDLWithoutAddressing(), MESSAGES.getNonAnonymousReplyToMessage(), S11_NS, getNonAnonymousEndpointAddress(), clientAddress, ECHO_IN_ACTION, "fault-test1194");
// Lets see we get a response in 60 s
SOAPMessage m = respMsgExchanger.exchange(null, TestConstants.CLIENT_MAX_TIMEOUT, TimeUnit.SECONDS);
// System.out.println("****************************");
// m.writeTo(System.out);
// System.out.println("\n****************************");
SOAPFault f = m.getSOAPBody().getFault();
assertNotNull(f);
assertEquals(USER_FAULT_CODE, f.getFaultCodeAsQName());
}
use of jakarta.xml.soap.SOAPFault in project openmq by eclipse-ee4j.
the class UMSService method createSOAPFaultMessage.
/**
* Create a soap fault message and set its error code and error string as specified in the parameter.
*/
public static SOAPMessage createSOAPFaultMessage(Throwable t, String faultCode, String faultString) {
SOAPMessage soapFault = null;
try {
MessageFactory mf = MessageFactory.newInstance();
soapFault = mf.createMessage();
SOAPEnvelope env = soapFault.getSOAPPart().getEnvelope();
SOAPBody body = env.getBody();
SOAPFault faultElement = body.addFault();
String soapNs = env.getElementName().getPrefix();
String fcode = soapNs + ":" + faultCode;
faultElement.setFaultCode(fcode);
faultElement.setFaultString(faultString);
Detail detail = faultElement.getDetail();
if (detail == null) {
detail = faultElement.addDetail();
}
Name stname = MessageUtil.createJMSName("StackTrace");
SOAPElement entryEle = detail.addDetailEntry(stname);
// get stack trace
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
t.printStackTrace(ps);
ps.close();
String trace = baos.toString("utf8");
entryEle.setValue(trace);
soapFault.saveChanges();
} catch (Exception e) {
e.printStackTrace();
}
return soapFault;
}
Aggregations