use of org.apache.axiom.soap.SOAPFaultText in project webservices-axiom by apache.
the class TestGetFaultReasonTextCaseSensitivity method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFaultReason reason = soapFactory.createSOAPFaultReason();
SOAPFaultText text = soapFactory.createSOAPFaultText(reason);
text.setLang("EN-US");
text.setText("Some reason");
assertThat(reason.getFaultReasonText(Locale.ENGLISH)).isEqualTo("Some reason");
}
use of org.apache.axiom.soap.SOAPFaultText in project webservices-axiom by apache.
the class TestGetLangWithParser method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPFaultText faultText = envelope.getBody().getFault().getReason().getFirstSOAPText();
assertTrue("SOAP 1.2 Fault Text Test With Parser : - getLang method returns incorrect string", faultText.getLang().equals("en"));
OMAttribute langAttribute = faultText.getAllAttributes().next();
assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME));
assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX));
assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace uri mismatch", langAttribute.getNamespace().getNamespaceURI().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI));
}
use of org.apache.axiom.soap.SOAPFaultText in project wso2-synapse by wso2.
the class MessageHelper method cloneSOAPFault.
/**
* Clones the SOAPFault, fault cloning is not the same as cloning the OMElement because if the
* Fault is accessed through the SOAPEnvelope.getBody().getFault() method it will lead to a
* class cast because the cloned element is just an OMElement but not a Fault.
*
* @param fault that needs to be cloned
* @return the cloned fault
*/
public static SOAPFault cloneSOAPFault(SOAPFault fault) {
SOAPFactory fac;
int soapVersion;
final int SOAP_11 = 1;
final int SOAP_12 = 2;
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(fault.getNamespace().getNamespaceURI())) {
fac = OMAbstractFactory.getSOAP11Factory();
soapVersion = SOAP_11;
} else {
fac = OMAbstractFactory.getSOAP12Factory();
soapVersion = SOAP_12;
}
SOAPFault newFault = fac.createSOAPFault();
SOAPFaultCode code = fac.createSOAPFaultCode();
SOAPFaultReason reason = fac.createSOAPFaultReason();
switch(soapVersion) {
case SOAP_11:
code.setText(fault.getCode().getTextAsQName());
reason.setText(fault.getReason().getText());
break;
case SOAP_12:
SOAPFaultValue value = fac.createSOAPFaultValue(code);
value.setText(fault.getCode().getTextAsQName());
for (Object obj : fault.getReason().getAllSoapTexts()) {
SOAPFaultText text = fac.createSOAPFaultText();
text.setText(((SOAPFaultText) obj).getText());
reason.addSOAPText(text);
}
break;
}
newFault.setCode(code);
newFault.setReason(reason);
if (fault.getNode() != null) {
SOAPFaultNode soapfaultNode = fac.createSOAPFaultNode();
soapfaultNode.setNodeValue(fault.getNode().getNodeValue());
newFault.setNode(soapfaultNode);
}
if (fault.getRole() != null) {
SOAPFaultRole soapFaultRole = fac.createSOAPFaultRole();
soapFaultRole.setRoleValue(fault.getRole().getRoleValue());
newFault.setRole(soapFaultRole);
}
if (fault.getDetail() != null) {
SOAPFaultDetail soapFaultDetail = fac.createSOAPFaultDetail();
for (Iterator itr = fault.getDetail().getAllDetailEntries(); itr.hasNext(); ) {
Object element = itr.next();
if (element instanceof OMElement) {
soapFaultDetail.addDetailEntry(((OMElement) element).cloneOMElement());
}
}
newFault.setDetail(soapFaultDetail);
}
return newFault;
}
Aggregations