io.github.carlosthe19916.webservices.utils.Util Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sunat-web-services Show documentation
Show all versions of sunat-web-services Show documentation
Sunat Web Services Endpoints
package io.github.carlosthe19916.webservices.utils;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.soap.SOAPFaultException;
import java.util.Optional;
public class Util {
private Util() {
// Just static methods
}
public static Optional getErrorCode(SOAPFaultException exception) {
String errorCode = "";
SOAPFault fault = exception.getFault();
if (fault != null) {
String faultCode = fault.getFaultCode();
if (faultCode != null) {
errorCode = faultCode.replaceAll("soap-env:Client.", "");
}
}
if (!errorCode.matches("-?\\d+")) {
String exceptionMessage = exception.getMessage();
if (exceptionMessage != null) {
errorCode = exceptionMessage.replaceAll("soap-env:Client.", "");
}
}
if (!errorCode.matches("-?\\d+")) {
return Optional.empty();
}
return Optional.of(Integer.parseInt(errorCode));
}
public static String getFileNameWithoutExtension(String fileName) {
int index = fileName.lastIndexOf('.');
if (index != -1) {
return fileName.substring(0, fileName.lastIndexOf('.'));
}
return fileName;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy