use of com.helger.peppol.wsclient2.WSDVSService in project peppol-practical by phax.
the class MainWSDVSClient method main.
public static void main(final String[] args) throws ValidateFaultError {
WSHelper.enableSoapLogging(true);
LOGGER.info("Starting the engines");
final String sXML = StreamHelper.getAllBytesAsString(new ClassPathResource("ws/invoice1.xml"), StandardCharsets.UTF_8);
final WSDVSService aService = new WSDVSService(new FileSystemResource("src/main/webapp/WEB-INF/wsdl/pp-dvs.wsdl").getAsURL());
final WSDVSPort aPort = aService.getWSDVSPort();
final WSClientConfig aWsClientConfig = new WSClientConfig(URLHelper.getAsURL(true ? "https://peppol.helger.com/wsdvs" : "http://localhost:8080/wsdvs"));
aWsClientConfig.applyWSSettingsToBindingProvider((BindingProvider) aPort);
LOGGER.info("Starting validation process");
final RequestType aRequest = new RequestType();
aRequest.setVESID(PeppolValidation3_13_0.VID_OPENPEPPOL_INVOICE_V3.getAsSingleID());
aRequest.setXML(sXML);
aRequest.setDisplayLocale("en");
final ResponseType aResponse = aPort.validate(aRequest);
if (false)
LOGGER.info("Result:\n" + new GenericJAXBMarshaller<>(ResponseType.class, com.helger.peppol.wsclient2.ObjectFactory._ValidateResponseOutput_QNAME).getAsString(aResponse));
LOGGER.info("Success: " + aResponse.isSuccess());
LOGGER.info("Interrupted: " + aResponse.isInterrupted());
LOGGER.info("Most severe error level: " + aResponse.getMostSevereErrorLevel());
int nPos = 1;
final int nMaxPos = aResponse.getResultCount();
for (final ValidationResultType aResult : aResponse.getResult()) {
LOGGER.info(" [" + nPos + "/" + nMaxPos + "] " + aResult.getArtifactType() + " - " + aResult.getArtifactPath());
++nPos;
LOGGER.info(" Success: " + aResult.getSuccess());
for (final ItemType aItem : aResult.getItem()) {
LOGGER.info(" Error Level: " + aItem.getErrorLevel());
if (aItem.getErrorID() != null)
LOGGER.info(" Error ID: " + aItem.getErrorID());
if (aItem.getErrorFieldName() != null)
LOGGER.info(" Error Field: " + aItem.getErrorFieldName());
LOGGER.info(" Error Text: " + aItem.getErrorText());
if (aItem.getErrorLocation() != null)
LOGGER.info(" Location: " + aItem.getErrorLocation());
if (aItem.getTest() != null)
LOGGER.info(" Test: " + aItem.getTest());
LOGGER.info("--");
}
}
LOGGER.info("Done");
}
Aggregations