use of jakarta.xml.soap.Detail in project metro-jax-ws by eclipse-ee4j.
the class jaxws413Test method test1.
public void test1() throws SOAPException, IOException {
SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
fault.setFaultCode(new QName("http://foo/bar", "mycode", "myprefix"));
fault.setFaultString("Some exception");
Detail detail = fault.addDetail();
detail.addDetailEntry(new QName("http://foo/bar", "soap11detail"));
Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_11, fault);
SOAPMessage sm = faultMsg.readAsSOAPMessage();
Detail det = sm.getSOAPBody().getFault().getDetail();
Iterator iter = det.getDetailEntries();
assertTrue(iter.hasNext());
Element item = (Element) iter.next();
assertEquals(item.getNamespaceURI(), "http://foo/bar");
assertEquals(item.getLocalName(), "soap11detail");
}
use of jakarta.xml.soap.Detail in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method getFaultActionFromSEIModel.
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
String action = null;
if (seiModel == null || wsdlPort == null) {
return action;
}
try {
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
if (sm == null) {
return action;
}
if (sm.getSOAPBody() == null) {
return action;
}
if (sm.getSOAPBody().getFault() == null) {
return action;
}
Detail detail = sm.getSOAPBody().getFault().getDetail();
if (detail == null) {
return action;
}
String ns = detail.getFirstChild().getNamespaceURI();
String name = detail.getFirstChild().getLocalName();
WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl) wsdlOp.getJavaMethod() : null;
if (jm != null) {
for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
if (ce.getDetailType().tagName.getLocalPart().equals(name) && ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
return ce.getFaultAction();
}
}
}
return action;
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.soap.Detail in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method getFaultAction.
String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
if (action != null) {
return action;
}
action = addVer.getDefaultFaultAction();
if (wbo == null) {
return action;
}
try {
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
if (sm == null) {
return action;
}
if (sm.getSOAPBody() == null) {
return action;
}
if (sm.getSOAPBody().getFault() == null) {
return action;
}
Detail detail = sm.getSOAPBody().getFault().getDetail();
if (detail == null) {
return action;
}
String ns = detail.getFirstChild().getNamespaceURI();
String name = detail.getFirstChild().getLocalName();
WSDLOperation o = wbo.getOperation();
WSDLFault fault = o.getFault(new QName(ns, name));
if (fault == null) {
return action;
}
action = fault.getAction();
return action;
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.soap.Detail 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.Detail 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