Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues trying to adapt the rest2soap-json example to HTTPS #779

Closed
necabo opened this issue Oct 31, 2023 · 4 comments
Closed

Issues trying to adapt the rest2soap-json example to HTTPS #779

necabo opened this issue Oct 31, 2023 · 4 comments

Comments

@necabo
Copy link

necabo commented Oct 31, 2023

I'm trying to get something akin to the rest2soap-json example to work.
Since the SOAP service used in that example doesn't seem to be available anymore I tried switching to another public SOAP service.

My first attempt looked like this:

proxies.xml:

<?xml version="1.0" encoding="UTF-8"?>
<spring:beans
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns="http://membrane-soa.org/proxies/1/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd          http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd">
    <router>
        <serviceProxy port="2000">
            <rest2Soap>
                <mapping regex="/nbr/.*" soapAction="" soapURI="/webservicesserver/NumberConversion.wso" requestXSLT="./request.xsl" responseXSLT="./response.xsl" />
            </rest2Soap>
            <target host="www.dataaccess.com" />
        </serviceProxy>
    </router>
</spring:beans>

request.xml:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" version="1.0">
    <xsl:template match="/">
        <s11:Envelope>
            <s11:Body>
                <nbr:NumberToWords
                    xmlns:nbr="http://www.dataaccess.com/webservicesserver/">
                    <nbr:ubiNum>
                        <xsl:value-of select="//path/component[2]" />
                    </nbr:ubiNum>
                </nbr:NumberToWords>
            </s11:Body>
        </s11:Envelope>
    </xsl:template>
</xsl:stylesheet>

Trying to call the API using CURL returns a 301:

$ curl --header "Accept: application/json" http://127.0.0.1:2000/nbr/37050198
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.dataaccess.com:80/webservicesserver/NumberConversion.wso">here</a></body>%

Here is an excerpt from the logs:

17:22:07,850 DEBUG 52 RouterThread /127.0.0.1:48150 XSLTTransformer:79 - applying transformation: ./request.xsl
17:22:07,877 DEBUG 52 RouterThread /127.0.0.1:48150 REST2SOAPInterceptor:72 - soap-env: <?xml version="1.0" encoding="UTF-8"?><s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"><s11:Body><nbr:NumberToWords xmlns:nbr="http://www.dataaccess.com/webservicesserver/"><nbr:ubiNum>37050198</nbr:ubiNum></nbr:NumberToWords></s11:Body></s11:Envelope>
17:22:07,883 DEBUG 52 RouterThread /127.0.0.1:48150 REST2SOAPInterceptor:279 - destination set to: http://www.dataaccess.com:80/webservicesserver/NumberConversion.wso

It seems like the transformation was applied successfully as the SOAP service returns the expected response when called with the XML output:

$ curl --location 'https://www.dataaccess.com/webservicesserver/NumberConversion.wso' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data '<?xml version="1.0" encoding="UTF-8"?><s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"><s11:Body><nbr:NumberToWords xmlns:nbr="http://www.dataaccess.com/webservicesserver/"><nbr:ubiNum>37050198</nbr:ubiNum></nbr:NumberToWords></s11:Body></s11:Envelope>'
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <m:NumberToWordsResponse xmlns:m="http://www.dataaccess.com/webservicesserver/">
      <m:NumberToWordsResult>thirty seven million fifty thousand one hundred and ninety eight </m:NumberToWordsResult>
    </m:NumberToWordsResponse>
  </soap:Body>
</soap:Envelope>

However, api-gateway sends the request to http://www.dataaccess.com:80/webservicesserver/NumberConversion.wso rather than https://www.dataaccess.com/webservicesserver/NumberConversion.wso.

I tried several other configurations like <target host="dataaccess.com" port="443" /> for proxies.xml with no success.
Interestingly enough, even using <target url="https://www.dataaccess.com" />, which according to documentation should effectively override host and port attributes, didn't solve this.
Apparently, it isn't even read properly when determining the request destination:

17:39:54,890 DEBUG 52 RouterThread /127.0.0.1:36582 REST2SOAPInterceptor:279 - destination set to: http://null:80/webservicesserver/NumberConversion.wso

In a last attempt to get it working, I modified the source code:

diff --git a/core/src/main/java/com/predic8/membrane/core/interceptor/rest/REST2SOAPInterceptor.java b/core/src/main/java/com/predic8/membrane/core/interceptor/rest/REST2SOAPInterceptor.java
index 1b2ed8f55..0cc83e9eb 100644
--- a/core/src/main/java/com/predic8/membrane/core/interceptor/rest/REST2SOAPInterceptor.java
+++ b/core/src/main/java/com/predic8/membrane/core/interceptor/rest/REST2SOAPInterceptor.java
@@ -280,9 +280,7 @@ public class REST2SOAPInterceptor extends SOAPRESTHelper {
        }

        private String getNewDestination(AbstractExchange exc) {
-               return "http://" + ((AbstractServiceProxy) exc.getRule()).getTargetHost() + ":"
-                               + ((AbstractServiceProxy) exc.getRule()).getTargetPort()
-                               + exc.getRequest().getUri();
+    return ((AbstractServiceProxy) exc.getRule()).getTargetURL();
        }

        private String getURI(AbstractExchange exc) {

If I understand the logs correctly, I believe I got to the response transformation part which then failed because my transformation is somehow null (the file exists in the same directory, I checked several times):

17:43:16,524 DEBUG 52 RouterThread /127.0.0.1:60272 XSLTTransformer:79 - applying transformation: ./request.xsl
17:43:16,550 DEBUG 52 RouterThread /127.0.0.1:60272 REST2SOAPInterceptor:72 - soap-env: <?xml version="1.0" encoding="UTF-8"?><s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"><s11:Body><nbr:NumberToWords xmlns:nbr="http://www.dataaccess.com/webservicesserver/"><nbr:ubiNum>37050198</nbr:ubiNum></nbr:NumberToWords></s11:Body></s11:Envelope>
17:43:16,555 DEBUG 52 RouterThread /127.0.0.1:60272 REST2SOAPInterceptor:279 - destination set to: https://www.dataaccess.com
17:43:16,556 DEBUG 52 RouterThread /127.0.0.1:60272 InterceptorFlowController:108 - Invoking request handler: HTTPClient on exchange: [time:Oct 31, 2023,requestURI:/webservicesserver/NumberConversion.wso]
17:43:16,556 DEBUG 52 RouterThread /127.0.0.1:60272 HttpClient:211 - try # 0 to https://www.dataaccess.com
17:43:16,559 DEBUG 52 RouterThread /127.0.0.1:60272 ConnectionManager:118 - connection requested for www.dataaccess.com:443
17:43:16,559 DEBUG 52 RouterThread /127.0.0.1:60272 ConnectionManager:120 - Number of connections in pool: 0
17:43:16,715 DEBUG 52 RouterThread /127.0.0.1:60272 Connection:116 - Opened connection on localPort: 42042
17:43:17,276 DEBUG 52 RouterThread /127.0.0.1:60272 Message:157 - createBody
17:43:17,277 DEBUG 52 RouterThread /127.0.0.1:60272 InterceptorFlowController:129 - Invoking response handler: REST 2 SOAP Gateway on exchange: [time:Oct 31, 2023,requestURI:]
17:43:17,277 DEBUG 52 RouterThread /127.0.0.1:60272 REST2SOAPInterceptor:174 - restURL: com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor$Mapping@2ca5b6bd
17:43:17,278 DEBUG 52 RouterThread /127.0.0.1:60272 XSLTTransformer:48 - using 64 parallel transformer instances for null
17:43:17,300 DEBUG 52 RouterThread /127.0.0.1:60272 Connection:146 - Closing HTTP connection LocalPort: 42042
17:43:17,301 DEBUG 52 RouterThread /127.0.0.1:60272 XSLTTransformer:79 - applying transformation: null
17:43:17,306 DEBUG 52 RouterThread /127.0.0.1:60272 InterceptorFlowController:148 - Invoking abortion handler: Reverse Proxy on exchange: [time:Oct 31, 2023,requestURI:]
17:43:17,306 DEBUG 52 RouterThread /127.0.0.1:60272 InterceptorFlowController:148 - Invoking abortion handler:   Store Interceptor on exchange: [time:Oct 31, 2023,requestURI:]
17:43:17,307 DEBUG 52 RouterThread /127.0.0.1:60272 InterceptorFlowController:148 - Invoking abortion handler: com.predic8.membrane.core.interceptor.LoggingContextInterceptor on exchange: [time:Oct 31, 2023,requestURI:]
17:43:17,307  WARN 52 RouterThread /127.0.0.1:60272 AbstractHttpHandler:80 - An exception occured while handling a request:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId.
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:793) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:395) ~[?:?]
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:92) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.handleResponse(REST2SOAPInterceptor.java:179) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeResponseHandlers(InterceptorFlowController.java:131) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeHandlers(InterceptorFlowController.java:83) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.transport.http.AbstractHttpHandler.invokeHandlers(AbstractHttpHandler.java:61) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.transport.http.HttpServerHandler.process(HttpServerHandler.java:227) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at com.predic8.membrane.core.transport.http.HttpServerHandler.run(HttpServerHandler.java:128) ~[service-proxy-core-5.2.1-SNAPSHOT.jar:5.2.1-SNAPSHOT]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) ~[?:?]
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanExternalID(XMLScanner.java:1065) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.scanDoctypeDecl(XMLDocumentScannerImpl.java:645) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:908) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:114) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224) ~[?:?]
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:667) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:781) ~[?:?]
        ... 11 more
17:43:17,318 DEBUG 52 RouterThread /127.0.0.1:60272 HttpServerHandler:245 - exchange set completed

I'm a bit out of ideas on how to further debug this and get the example working.
Let me know if you need any more information.

@predic8
Copy link
Member

predic8 commented Nov 2, 2023

Try:

<serviceProxy port="2000">
            <rest2Soap>
                <mapping regex="/nbr/.*" soapAction="" soapURI="/webservicesserver/NumberConversion.wso" requestXSLT="./request.xsl" responseXSLT="./response.xsl" />
            </rest2Soap>
            <target host="www.dataaccess.com">
                <ssl/>
            </target>
        </serviceProxy>

See: https://www.membrane-soa.org/api-gateway-doc/current/configuration/reference/ssl.htm

@necabo
Copy link
Author

necabo commented Nov 2, 2023

Try:

<serviceProxy port="2000">
            <rest2Soap>
                <mapping regex="/nbr/.*" soapAction="" soapURI="/webservicesserver/NumberConversion.wso" requestXSLT="./request.xsl" responseXSLT="./response.xsl" />
            </rest2Soap>
            <target host="www.dataaccess.com">
                <ssl/>
            </target>
        </serviceProxy>

See: https://www.membrane-soa.org/api-gateway-doc/current/configuration/reference/ssl.htm

Unfortunately, that also doesn't work. CURL also responds with a 301 here:

$ curl -i --header "Accept: application/json" http://127.0.0.1:2000/nbr/37050198
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Location: http://www.dataaccess.com/webservicesserver/NumberConversion.wso
Server: Server
X-Powered-By: ASP.NET
Date: Thu, 02 Nov 2023 18:13:14 GMT
Content-Length: 187
Connection: close

<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="http://www.dataaccess.com/webservicesserver/NumberConversion.wso">[here](http://www.dataaccess.com/webservicesserver/NumberConversion.wso)</a></body>%

Judging by the logs, it sends the request to http://www.dataaccess.com:443/webservicesserver/NumberConversion.wso:

19:13:13,502 DEBUG 52 RouterThread /127.0.0.1:60234 XSLTTransformer:79 - applying transformation: ./request.xsl
19:13:13,534 DEBUG 52 RouterThread /127.0.0.1:60234 REST2SOAPInterceptor:72 - soap-env: <?xml version="1.0" encoding="UTF-8"?><s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"><s11:Body><nbr:NumberToWords xmlns:nbr="http://www.dataaccess.com/webservicesserver/"><nbr:ubiNum>37050198</nbr:ubiNum></nbr:NumberToWords></s11:Body></s11:Envelope>
19:13:13,540 DEBUG 52 RouterThread /127.0.0.1:60234 REST2SOAPInterceptor:279 - destination set to: http://www.dataaccess.com:443/webservicesserver/NumberConversion.wso

For completeness sake, here's the full log:

MEMBRANE_HOME variable is not set
MEMBRANE_HOME variable is now set
Membrane Router running...
19:36:26,922 DEBUG 1 main Router:141 - loading spring config: file:/home/necabo/projects/membrane-soap-proxy/membrane-api-gateway-5.2.0/numberconversion-test/proxies.xml
19:36:27,434  INFO 1 main HttpEndpointListener:105 - listening at '*:2000'
19:36:27,439 DEBUG 51 Membrane Hot Deployment Thread HotDeploymentThread:69 - Spring Hot Deployment Thread started.
19:36:27,440  INFO 1 main Router:324 - Membrane API Gateway 5.2.0 up and running!
19:36:36,173 DEBUG 50 Connection Acceptor '*:2000' HttpEndpointListener:123 - Accepted connection from /127.0.0.1:47684
19:36:36,178 DEBUG 52 RouterThread /127.0.0.1:47684 HttpServerHandler:81 - New ServerThread created. 1
19:36:36,183 DEBUG 52 RouterThread /127.0.0.1:47684 Message:157 - createBody
19:36:36,183 DEBUG 52 RouterThread /127.0.0.1:47684 Message:160 - empty body created
19:36:36,184 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: Rule Matching Interceptor on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,185 DEBUG 52 RouterThread /127.0.0.1:47684 RuleManager:226 - Host from rule: *;   Host from parameter rule key: 127.0.0.1:2000
19:36:36,188 DEBUG 52 RouterThread /127.0.0.1:47684 RuleMatchingInterceptor:81 - Matching Rule found for RuleKey 127.0.0.1:2000 GET /nbr/37050198 2000 127.0.0.1
19:36:36,189 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: com.predic8.membrane.core.interceptor.LoggingContextInterceptor on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,197 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler:   Store Interceptor on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,199 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: Dispatching Interceptor on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,199 DEBUG 52 RouterThread /127.0.0.1:47684 DispatchingInterceptor:79 - destination: https://dataaccess.com:443/nbr/37050198
19:36:36,200 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: Reverse Proxy on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,200 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: User Feature on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,200 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: REST 2 SOAP Gateway on exchange: [time:Nov 2, 2023,requestURI:/nbr/37050198]
19:36:36,200 DEBUG 52 RouterThread /127.0.0.1:47684 REST2SOAPInterceptor:157 - uri: /nbr/37050198
19:36:36,203 DEBUG 52 RouterThread /127.0.0.1:47684 REST2SOAPInterceptor:54 - http-xml: <?xml version="1.0" ?><http:request xmlns:http="http://membrane-soa.org/schemas/http/v1/" method="GET" http-version="1.1"><uri value="/nbr/37050198"><path><component>nbr</component><component>37050198</component></path></uri><headers><header name="Host">127.0.0.1:2000</header><header name="User-Agent">curl/8.4.0</header><header name="Accept">application/json</header><header name="X-Forwarded-For">127.0.0.1</header><header name="X-Forwarded-Proto">http</header><header name="X-Forwarded-Host">127.0.0.1:2000</header></headers><body type="plain"><![CDATA[]]></body></http:request>
19:36:36,207 DEBUG 52 RouterThread /127.0.0.1:47684 XSLTTransformer:48 - using 64 parallel transformer instances for ./request.xsl
19:36:36,252 DEBUG 52 RouterThread /127.0.0.1:47684 XSLTTransformer:79 - applying transformation: ./request.xsl
19:36:36,277 DEBUG 52 RouterThread /127.0.0.1:47684 REST2SOAPInterceptor:72 - soap-env: <?xml version="1.0" encoding="UTF-8"?><s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"><s11:Body><nbr:NumberToWords xmlns:nbr="http://www.dataaccess.com/webservicesserver/"><nbr:ubiNum>37050198</nbr:ubiNum></nbr:NumberToWords></s11:Body></s11:Envelope>
19:36:36,283 DEBUG 52 RouterThread /127.0.0.1:47684 REST2SOAPInterceptor:279 - destination set to: http://dataaccess.com:443/webservicesserver/NumberConversion.wso
19:36:36,283 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:108 - Invoking request handler: HTTPClient on exchange: [time:Nov 2, 2023,requestURI:/webservicesserver/NumberConversion.wso]
19:36:36,283 DEBUG 52 RouterThread /127.0.0.1:47684 HttpClient:211 - try # 0 to http://dataaccess.com:443/webservicesserver/NumberConversion.wso
19:36:36,284 DEBUG 52 RouterThread /127.0.0.1:47684 ConnectionManager:118 - connection requested for dataaccess.com:443
19:36:36,285 DEBUG 52 RouterThread /127.0.0.1:47684 ConnectionManager:120 - Number of connections in pool: 0
19:36:36,416 DEBUG 52 RouterThread /127.0.0.1:47684 Connection:116 - Opened connection on localPort: 33732
19:36:36,986 DEBUG 52 RouterThread /127.0.0.1:47684 Message:157 - createBody
19:36:36,986 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:129 - Invoking response handler: REST 2 SOAP Gateway on exchange: [time:Nov 2, 2023,requestURI:/webservicesserver/NumberConversion.wso]
19:36:36,987 DEBUG 52 RouterThread /127.0.0.1:47684 REST2SOAPInterceptor:174 - restURL: com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor$Mapping@600cd13c
19:36:36,987 DEBUG 52 RouterThread /127.0.0.1:47684 XSLTTransformer:48 - using 64 parallel transformer instances for null
19:36:36,994 DEBUG 52 RouterThread /127.0.0.1:47684 XSLTTransformer:79 - applying transformation: null
19:36:36,998 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:148 - Invoking abortion handler: Reverse Proxy on exchange: [time:Nov 2, 2023,requestURI:/webservicesserver/NumberConversion.wso]
19:36:36,998 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:148 - Invoking abortion handler:   Store Interceptor on exchange: [time:Nov 2, 2023,requestURI:/webservicesserver/NumberConversion.wso]
19:36:36,999 DEBUG 52 RouterThread /127.0.0.1:47684 InterceptorFlowController:148 - Invoking abortion handler: com.predic8.membrane.core.interceptor.LoggingContextInterceptor on exchange: [time:Nov 2, 2023,requestURI:/webservicesserver/NumberConversion.wso]
19:36:36,999  WARN 52 RouterThread /127.0.0.1:47684 AbstractHttpHandler:80 - An exception occured while handling a request:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 2; The markup in the document following the root element must be well-formed.
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:793) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:395) ~[?:?]
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:92) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.handleResponse(REST2SOAPInterceptor.java:179) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeResponseHandlers(InterceptorFlowController.java:131) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeHandlers(InterceptorFlowController.java:83) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.transport.http.AbstractHttpHandler.invokeHandlers(AbstractHttpHandler.java:61) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.transport.http.HttpServerHandler.process(HttpServerHandler.java:227) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at com.predic8.membrane.core.transport.http.HttpServerHandler.run(HttpServerHandler.java:128) ~[service-proxy-core-5.2.0.jar:5.2.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) ~[?:?]
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(XMLDocumentScannerImpl.java:1398) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:114) ~[?:?]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:?]
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224) ~[?:?]
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:667) ~[?:?]
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:781) ~[?:?]
        ... 11 more
19:36:37,009 DEBUG 52 RouterThread /127.0.0.1:47684 HttpServerHandler:245 - exchange set completed

One thing I noticed is that this line

19:36:36,199 DEBUG 52 RouterThread /127.0.0.1:47684 DispatchingInterceptor:79 - destination: https://dataaccess.com:443/nbr/37050198

contains "https" but that information seemingly gets lost later on.

Uneducated guess/question

Looking at what I believe to be a relevant file in the source code most code was written almost 9 years ago (or even earlier given the "CRLF -> LF" commit message). Is it possible that the REST2SOAP interceptor simply doesn't handle HTTPS correctly yet and no one noticed or at least didn't submit an issue? To me, line 293 looks especially suspicious effectively hard coding "http://".

@predic8
Copy link
Member

predic8 commented Nov 3, 2023

Hi,
actually the REST2SOAP interceptor is not used often cause it is based on XSLT. You guessed right, it does not handle correctly HTTPS. I created a PR to fix this ( #782 ). The change should be integrated into the next release. Till then you can use a second API as target and configure there outgoing SSL as a quickfix. Or use a build of a snapshop release.

@predic8
Copy link
Member

predic8 commented Nov 6, 2023

Fix is merged into main branch.

@predic8 predic8 closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants