OxalisCommunity / Oxalis-AS4

PEPPOL AS4 pMode plugin for Oxalis
33 stars 26 forks source link

Container running the Oxalis image return soap error for header StandardBusinessDocument #202

Closed alfchristensen closed 1 year ago

alfchristensen commented 1 year ago

Hi!

I am running the Oxalis docker image as a container on Azure. Everything works as expected with the first test, and I get the document in a folder under /oxalis/inbound. When I try to send the document back with swapped sender and receiver, the Oxalis container shows the stack trace error below regarding the StandardBusinessDocumentHeader having invalid soap version. It is the exact same document I received, with swapped sender and receiver 4 places. Any help or insight would be greatly appreciated.

2023-05-01T22:09:35.676207144Z May 01, 2023 10:09:35 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging 2023-05-01T22:09:35.676249245Z WARNING: Interceptor for has thrown exception, unwinding now 2023-05-01T22:09:35.676261045Z org.apache.cxf.binding.soap.SoapFault: "http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader", the namespace on the "StandardBusinessDocument" element, is not a valid SOAP version. 2023-05-01T22:09:35.676265845Z at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.readVersion(ReadHeadersInterceptor.java:132) 2023-05-01T22:09:35.676271045Z at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:175) 2023-05-01T22:09:35.676275045Z at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:70) 2023-05-01T22:09:35.676278945Z at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) 2023-05-01T22:09:35.676282946Z at org.apache.cxf.transport.MultipleEndpointObserver.onMessage(MultipleEndpointObserver.java:98) 2023-05-01T22:09:35.676286946Z at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265) 2023-05-01T22:09:35.676290546Z at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) 2023-05-01T22:09:35.676306946Z at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) 2023-05-01T22:09:35.676310846Z at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) 2023-05-01T22:09:35.676314446Z at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225) 2023-05-01T22:09:35.676318246Z at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:304) 2023-05-01T22:09:35.676322046Z at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) 2023-05-01T22:09:35.676325846Z at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) 2023-05-01T22:09:35.676329446Z at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:279) 2023-05-01T22:09:35.676333046Z at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290) 2023-05-01T22:09:35.676336747Z at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280) 2023-05-01T22:09:35.676340347Z at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184) 2023-05-01T22:09:35.676345647Z at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:89) 2023-05-01T22:09:35.676349547Z at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85) 2023-05-01T22:09:35.676353347Z at io.opentracing.contrib.web.servlet.filter.TracingFilter.doFilter(TracingFilter.java:189) 2023-05-01T22:09:35.676357047Z at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82) 2023-05-01T22:09:35.676360747Z at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121) 2023-05-01T22:09:35.676364347Z at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133) 2023-05-01T22:09:35.676368047Z at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) 2023-05-01T22:09:35.676371547Z at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) 2023-05-01T22:09:35.676375147Z at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552) 2023-05-01T22:09:35.676378947Z at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) 2023-05-01T22:09:35.676382647Z at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) 2023-05-01T22:09:35.676386347Z at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) 2023-05-01T22:09:35.676390048Z at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505) 2023-05-01T22:09:35.676393848Z at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) 2023-05-01T22:09:35.676397448Z at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) 2023-05-01T22:09:35.676405048Z at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) 2023-05-01T22:09:35.676408748Z at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59) 2023-05-01T22:09:35.676412548Z at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) 2023-05-01T22:09:35.676416348Z at org.eclipse.jetty.server.Server.handle(Server.java:516) 2023-05-01T22:09:35.676419948Z at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) 2023-05-01T22:09:35.676423748Z at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) 2023-05-01T22:09:35.676427248Z at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) 2023-05-01T22:09:35.676430848Z at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) 2023-05-01T22:09:35.676434348Z at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) 2023-05-01T22:09:35.676437948Z at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) 2023-05-01T22:09:35.676441749Z at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) 2023-05-01T22:09:35.676445749Z at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) 2023-05-01T22:09:35.676449549Z at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) 2023-05-01T22:09:35.676453349Z at java.lang.Thread.run(Thread.java:748)

RichardVanMaaren commented 1 year ago

Hi,

That is strange indeed, maybe a typo somewhere ? Did you validate it with an xmlvaliator just to be sure structure is not incorrect ? Error message is clearly referrring to the SBDH.

Regards,

Richard

alfchristensen commented 1 year ago

Hello Richard, thanks for your quick response!

I just tested again and got the same response. The XML is attached to this comment. The validator at anskaffelser.dev return the following error: SYSTEM-003 Configuration for 'xml.sbdh::http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader::StandardBusinessDocument' not found.

I find this strange, as the testbed states the following for the current step:

The AccessPoint under test is expected to return the same document that was sent to the AP in the previous test case. Before the document is sent it needs to be modified in terms of sender and receiver. Sender will now be 0192:810418052, and receiver will be 0088:TBCNTRL00002. The changes needs to be applied both in the SBDH envelope as in the payload of the SBDH, no other changes should be made to the document and it is essential that the Document ID (Invoice number or Order number of the payload) is kept intact.

peppol-test.zip

RichardVanMaaren commented 1 year ago

Hi,

If I copy paste your xml it is valid in my situation, however, it seems your file is in UTF-8 encoding, please try saving it as ASCII and could you please try again ?

Regards,

Richard

alfchristensen commented 1 year ago

Hello again, just tried ASCII charset with the same result. Also tried using as2 instead of as4, tried the following Content types in the API headers for the POST call: "Application/xml", "Application/xml+soap", "Text/xml" and "Text/xml+soap". Just to be clear, I am building the Oxalis Access Point from the norstella/oxalis:latest image on dockerhub. Google and ChatGPT both suggests using soap specific envelop prefixes, but that would violate the format of all the Peppob Bis 3.0 documents I have seen.

RichardVanMaaren commented 1 year ago

Could you give us some more background, version of oxalis used, command used for sending etc.

Regards,

Richard

alfchristensen commented 1 year ago

Judging by the oxalis-standalone-5.5.1-SNAPSHOT.jar, I'd assume it is version 5.5.1.

My code for reading the content from the xml file and sending it to the oxalis API is pasted below. One question: is there some way I can configure the access point to automatically process files placed in the outbound folder?

Here is my code for sending. It is Java 20. If you want my sender and receiver addresses as well as the real URL for my endpoint I can send it to you directly.

`import java.io.*; import java.net.HttpURLConnection; import java.net.URL;

public class SendPeppolDocument {

public static void main(String[] args) throws IOException {
    String oxalisEndpoint = "https://myurl"; // Replace with your Oxalis Access Point endpoint URL
    String filePath = "0126a2e7-83c7-45c2-b5eb-32c1f6ca8b5c_ip-10-10-131-116.eu-west-1.compute.internal.doc.xml"; // Replace with your PEPPOL document file path

    sendPeppolDocument(oxalisEndpoint, new File(filePath));
}

public static void sendPeppolDocument(String endpointUrl, File document) throws IOException {
    URL url = new URL(endpointUrl);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("POST");
    connection.setDoOutput(true);
    connection.setRequestProperty("Content-Type", "Application/xml");
    connection.setRequestProperty("AS4-From", "0192:000000000"); // Replace with your sender ID
    connection.setRequestProperty("AS4-To", "0088:ABCDEFG00000"); // Replace with your receiver ID

    try (OutputStream os = connection.getOutputStream();
         FileInputStream fis = new FileInputStream(document)) {
        byte[] buffer = new byte[1024];
        int bytesRead;
        while ((bytesRead = fis.read(buffer)) != -1) {
            os.write(buffer, 0, bytesRead);
        }
    }

    System.out.println(connection.getOutputStream());

    int responseCode = connection.getResponseCode();
    System.out.println("Response Code: " + responseCode);
    System.out.println(connection);

    try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
        String inputLine;
        StringBuilder content = new StringBuilder();
        while ((inputLine = in.readLine()) != null) {
            content.append(inputLine);
        }
        System.out.println(content.toString());
    }

    connection.disconnect();
}

} `

RichardVanMaaren commented 1 year ago

Does it work via the stand-alone integration ? Oxalis 5.5.x is only compatible with java8.

https://github.com/OxalisCommunity/oxalis/blob/master/doc/installation.md

aaron-kumar commented 1 year ago

@alfchristensen : First of all it is Not an issue but discussion topic. So I am changing it to discussion, unless you will pin-point it as bug.

As a guidance, I have following suggestion:

Note: I recommend please go through instructions, previously posted issues and zero-in on issue before posting anything as bug. Though you are free to open it as discussion item and community will reply back.

Thanks for using Oxalis. Wishing you best of luck for Testbed certification !!! Oxalis community will help you through discussion wherever possible.