change content-type for serviceproxy

283 views
Skip to first unread message

alex.d...@gmail.com

unread,
Jul 8, 2013, 1:45:27 AM7/8/13
to membrane...@googlegroups.com
Hello, dear SOA Proxy guru!

I'm trying to realize scheme with rest2soap-json interception by membrane-esb-cli-3.5.8. 
Local application should call trackstudio local server through membrane soa proxy and stranslation from rest/json into soap12 should be done.

I'm doing it at the same manner as it described on /example/rest2soap-json, my proxies.xml file looks:
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        <serviceProxy port="2000">
                <rest2Soap>
                        <mapping regex="/auth/.*" soapAction=""
                                soapURI="/services/User" requestXSLT="ts.xsl"
                                responseXSLT="strip-env.xsl" />
                </rest2Soap>
                <target host="some_trackstudio_host" port="9999" />
        </serviceProxy>
</proxies>
with such ts.xls file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <xsl:template match="/">
   <soap:Header/>
   <soap:Body>
      <user:authenticate>
         <login>login</login>
         <password>login</password>
      </user:authenticate>
   </soap:Body>
</soap:Envelope>
        </xsl:template>
</xsl:stylesheet>

response xslt file (strip-env.xsl) is the same as in example.

But, when i'm calling http://localhost:2000/auth/2341234 got:
MEMBRANE_HOME variable is not set
MEMBRANE_HOME variable is now set
Membrane Router running...
08:37:48,661 DEBUG Router:64 - loading spring config: file:../../conf/monitor-beans.xml
08:37:48,766  INFO TrackingFileSystemXmlApplicationContext:454 - Refreshing com.predic8.membrane.core.TrackingFileSystemXmlApplicationContext@65a77f: startup date [Mon Jul 08 08:37:48 EEST 2013]; root of context hierarchy
08:37:48,937  INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from com.predic8.membrane.core.TrackingFileSystemXmlApplicationContext$1@982589
08:37:49,480 DEBUG TrackingFileSystemXmlApplicationContext:468 - Bean factory for com.predic8.membrane.core.TrackingFileSystemXmlApplicationContext@65a77f: org.springframework.beans.factory.support.DefaultListableBeanFactory@e020c9: defining beans [router,transport,transformerFactory,memoryExchangeStore]; root of factory hierarchy
08:37:49,537 DEBUG TrackingFileSystemXmlApplicationContext:753 - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@14520eb]
08:37:49,545 DEBUG TrackingFileSystemXmlApplicationContext:777 - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@16c9867]
08:37:49,547  INFO DefaultListableBeanFactory:538 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@e020c9: defining beans [router,transport,transformerFactory,memoryExchangeStore]; root of factory hierarchy
08:37:49,812 DEBUG TrackingFileSystemXmlApplicationContext:804 - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@6e4365]
08:37:49,824 DEBUG AbstractXmlElement:38 - <proxies>
08:37:49,872 DEBUG AbstractXmlElement:38 - <serviceProxy>
08:37:49,897 DEBUG AbstractXmlElement:38 - <rest2Soap>
08:37:49,899 DEBUG AbstractXmlElement:38 - <mapping>
08:37:49,900 DEBUG AbstractXmlElement:47 - </mapping>
08:37:49,901 DEBUG AbstractXmlElement:47 - </rest2Soap>
08:37:49,903 DEBUG AbstractXmlElement:38 - <target>
08:37:49,904 DEBUG AbstractXmlElement:47 - </target>
08:37:49,905 DEBUG AbstractXmlElement:47 - </serviceProxy>
08:37:49,906 DEBUG AbstractXmlElement:47 - </proxies>
08:37:49,922 DEBUG HttpEndpointListener:46 - listening at port 2000
08:37:49,928 DEBUG HotDeploymentThread:43 - Hot Deployment Thread started.
08:37:58,974 DEBUG HttpServerHandler:54 - New ServerThread created. 1
08:37:59,009 DEBUG Request:108 - createBody
08:37:59,010 DEBUG Request:111 - empty body created
08:37:59,023 DEBUG InterceptorFlowController:92 - Invoking request handler: Rule Matching Interceptor on exchange: [time:Jul 8, 2013,requestURI:/auth/2341234]
08:37:59,024 DEBUG RuleManager:171 - Host from rule: *;   Host from parameter rule key: localhost:2000
08:37:59,025 DEBUG RuleMatchingInterceptor:75 - Matching Rule found for RuleKey localhost:2000 GET /auth/2341234:2000
08:37:59,027 DEBUG InterceptorFlowController:92 - Invoking request handler: Exchange Store Interceptor on exchange: [time:Jul 8, 2013,requestURI:/auth/2341234]
08:37:59,028 DEBUG InterceptorFlowController:92 - Invoking request handler: Dispatching Interceptor on exchange: [time:Jul 8, 2013,requestURI:/auth/2341234]
08:37:59,030 DEBUG DispatchingInterceptor:53 - destination: http://dptool.astelit.ukr:9999/auth/2341234
08:37:59,031 DEBUG InterceptorFlowController:92 - Invoking request handler: User Feature on exchange: [time:Jul 8, 2013,requestURI:/auth/2341234]
08:37:59,032 DEBUG InterceptorFlowController:92 - Invoking request handler: REST 2 SOAP Gateway on exchange: [time:Jul 8, 2013,requestURI:/auth/2341234]
08:37:59,033 DEBUG REST2SOAPInterceptor:92 - uri: /auth/2341234
08:37:59,056 DEBUG REST2SOAPInterceptor:159 - 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="/auth/2341234"><path><component>auth</component><component>2341234</component></path></uri><headers><header name="Host">localhost:2000</header><header name="User-Agent">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070530 Red Hat/1.0.9-2.el4 SeaMonkey/1.0.9</header><header name="Accept">text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</header><header name="Accept-Language">en-us,en;q=0.5</header><header name="Accept-Encoding">gzip,deflate</header><header name="Accept-Charset">ISO-8859-1,utf-8;q=0.7,*;q=0.7</header><header name="Keep-Alive">300</header><header name="Connection">keep-alive</header><header name="X-Forwarded-For">127.0.0.1</header></headers><body type="plain"><![CDATA[]]></body></http:request>
08:37:59,063 DEBUG XSLTTransformer:46 - using 8 parallel transformer instances for ts.xsl
08:37:59,268 DEBUG XSLTTransformer:77 - applying transformation: ts.xsl
08:37:59,331 DEBUG REST2SOAPInterceptor:221 - soap-env: <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE soap:Envelope SYSTEM "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<soap:Header/>
<soap:Body>
<user:authenticate>
<login>vas_user</login>
<password>vas_user</password>
</user:authenticate>
</soap:Body>
</soap:Envelope>

08:37:59,337 DEBUG REST2SOAPInterceptor:208 - destination set to: http://dptool.astelit.ukr:9999/services/User
08:37:59,339 DEBUG InterceptorFlowController:92 - Invoking request handler: HTTPClient on exchange: [time:Jul 8, 2013,requestURI:/services/User]
08:37:59,356 DEBUG HttpClient:137 - try # 0 to http://dptool.astelit.ukr:9999/services/User
08:37:59,367 DEBUG ConnectionManager:111 - connection requested for host: dptool.astelit.ukr/10.1.60.21 and port: 9999
08:37:59,369 DEBUG ConnectionManager:113 - Number of connections in pool: 0
08:37:59,404 DEBUG Connection:62 - Opened connection on localPort: 15411
08:37:59,420 DEBUG Response:285 - empty body created
08:37:59,422 DEBUG InterceptorFlowController:114 - Invoking response handler: REST 2 SOAP Gateway on exchange: [time:Jul 8, 2013,requestURI:/services/User]
08:37:59,424 DEBUG REST2SOAPInterceptor:109 - restURL: com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor$Mapping@1fa681c
08:37:59,428 DEBUG XSLTTransformer:46 - using 8 parallel transformer instances for null
08:37:59,431 DEBUG XSLTTransformer:77 - applying transformation: null
ERROR:  'Premature end of file.'
08:37:59,459 DEBUG InterceptorFlowController:133 - Invoking abortion handler: Reverse Proxy on exchange: [time:Jul 8, 2013,requestURI:/services/User]
08:37:59,460 DEBUG InterceptorFlowController:133 - Invoking abortion handler: Exchange Store Interceptor on exchange: [time:Jul 8, 2013,requestURI:/services/User]
08:37:59,468  WARN AbstractHttpHandler:86 - An exception occured while handling a request:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:735)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:336)
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:90)
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:72)
        at com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.handleResponse(REST2SOAPInterceptor.java:114)
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeResponseHandlers(InterceptorFlowController.java:116)
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeHandlers(InterceptorFlowController.java:68)
        at com.predic8.membrane.core.transport.http.AbstractHttpHandler.invokeHandlers(AbstractHttpHandler.java:69)
        at com.predic8.membrane.core.transport.http.HttpServerHandler.process(HttpServerHandler.java:182)
        at com.predic8.membrane.core.transport.http.HttpServerHandler.run(HttpServerHandler.java:87)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1056)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:627)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:723)
        ... 12 more
---------
org.xml.sax.SAXParseException: Premature end of file.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1056)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:627)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:723)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:336)
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:90)
        at com.predic8.membrane.core.interceptor.xslt.XSLTTransformer.transform(XSLTTransformer.java:72)
        at com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.handleResponse(REST2SOAPInterceptor.java:114)
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeResponseHandlers(InterceptorFlowController.java:116)
        at com.predic8.membrane.core.interceptor.InterceptorFlowController.invokeHandlers(InterceptorFlowController.java:68)
        at com.predic8.membrane.core.transport.http.AbstractHttpHandler.invokeHandlers(AbstractHttpHandler.java:69)
        at com.predic8.membrane.core.transport.http.HttpServerHandler.process(HttpServerHandler.java:182)
        at com.predic8.membrane.core.transport.http.HttpServerHandler.run(HttpServerHandler.java:87)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
08:37:59,498 DEBUG HttpServerHandler:199 - exchange set completed

I was tracing http request and http response of trackstudio local server and noticed:
Request:

POST /services/User HTTP/1.1
Host: some_sharepoint_host:9999
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070530 Red Hat/1.0.9-2.el4 SeaMonkey/1.0.9
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
X-Forwarded-For: 127.0.0.1
Content-Length: 394
SOAPAction: 
Content-Type: text/xml;charset=UTF-8

<?xml version="1.0" encoding="utf-8"?>
<soap:Header/>
<soap:Body>
<user:authenticate>
<login>login</login>
<password>password</password>
</user:authenticate>
</soap:Body>
</soap:Envelope>

Reply:
HTTP/1.1 415 Unsupported Media Type
Date: Mon, 08 Jul 2013 05:37:59 GMT
Content-Length: 0
Server: Jetty(6.1.26)

I was trying soap ua with the same parameters and Content-Type: application/xml changed without error. Could You help me and provide information how to change Content-type for specified interception scheme?
Thanks in advance for reply!

BR,
Alex

Thomas Bayer

unread,
Jul 8, 2013, 11:33:13 AM7/8/13
to membrane...@googlegroups.com
Hi Alex,
looks like you are sending a SOAP request using SOAP version 1.2. Version 1.2 is more than 10 years old but not very often used. It is recommended to use SOAP 1.1. For SOAP 1.1 the Content-Type is text/xml. I assume that your backend will work with SOAP 1.1. too. To change the request you have to modify the namespace for the soap prefix to http://schemas.xmlsoap.org/soap/envelope/ .



   <soap:Header/>
   <soap:Body>
      <user:authenticate>
         <login>login</login>
         <password>login</password>
      </user:authenticate>
   </soap:Body>
</soap:Envelope>

I created an issue at github so we can fix this in a future version


Please tell me if you really need SOAP 1.2 than we can speed things up. But as I said most use still SOAP 1.1. A quickfix would be to use a one line Groovy interceptor that change the content-type after the rest2soap interceptor. 

Thanks for a really detailed bug report including the cause of the problem,
Thomas

Alex

unread,
Jul 8, 2013, 11:55:57 AM7/8/13
to membrane...@googlegroups.com
Dear Thomas,

Thanks a lot for reply! Our system could work only with soap 1.1 or soap 1.2. I have performed recommended changes by self for soap 1.1 and it is working as expected. 
But, for a correct work of BE soap 1.2 should be suported as well.
Please, add this feature into roadmap of next version.
I will check groovy workaround and provide update. Also, I will track the status of issue 125.

Thanks a lot for a fast support!

BR,
Alex

Alex

unread,
Jul 12, 2013, 5:17:55 AM7/12/13
to membrane...@googlegroups.com
Dear Thomas, 

I've tried to use groovy (by adding header), but, header has applied only to get favion.ico request. Hope You may fix issue on upcoming release at the nearest time.
BR,
Alex

Thomas Bayer

unread,
Jul 12, 2013, 8:58:16 AM7/12/13
to membrane...@googlegroups.com
Hi Alex,
please post your configuration so I can have a look at it.

Thx,
Thomas

Am 7/12/13 11:17 AM, schrieb Alex:
--
You received this message because you are subscribed to the Google Groups "membrane-monitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to membrane-monit...@googlegroups.com.
To post to this group, send email to membrane...@googlegroups.com.
Visit this group at http://groups.google.com/group/membrane-monitor.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages