How to invoke a REST Proxy service running on the ESB from a BPEL process on the BPS

情到浓时终转凉″ 提交于 2020-01-04 09:13:22

问题


I have setup BPS and have created a few BPEL processes which i can use to invoke services on the Application Server. I have created a REST proxy service on the ESB which uses an endpoint to a Labview server. In Labview i have a very basic REST service which generates a random value every second. I can access the REST service as follows http://localhost:8000/Maths/random. This generates the follwing output with a random value

RValue:19.000000

I have had success in accessing this service through the Gadget server and displaying the value as a graph using the WSO2 graphics framework.

But I am having problems when I try to invoke the same proxy service from a BPEL process. I have generated a wsdl file for the proxy service from the ESB. This wsdl file is used for the port connections etc. It only has one operation the "mediate" operation with no parameters or elements. I have followed a few of the tutorials for the BPS server to invoke the service but i have had no success so far. Can anyone show me how this can be done or point me to a similar tutorial? Many thanks.

U Raza below is the BPS error i get

[2012-03-15 18:22:33,265] INFO - BpelServerImpl - Registered process {http://areasearvice.bpel.bps}AreaService-14. [2012-03-15 18:22:42,282] INFO - CarbonAuthenticationUtil - 'admin' logged in at [2012-03-15 18:22:42,0282] from IP address 143.53.207.235 [2012-03-15 18:23:09,041] ERROR - BpelObjectFactory$BOMSAXErrorHandler - null:file:///D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/RestfulProxy.bpel:88:56:cvc-complex-type.3.2.2: Attribute 'xml:space' is not allowed to appear in element 'bpel:literal'. [2012-03-15 18:23:09,043] WARN - BpelObjectFactory - Validation errors during parsing, continuing due to -Dorg.apache.ode.compiler.failOnValidationErrors=false switch [2012-03-15 18:23:09,046] INFO - BpelC - info: [CompilingProcess] Compiling BPEL process. [2012-03-15 18:23:09,116] INFO - WSDLRegistry - WSDL at file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/GetLVRandomProxy.wsdl is a duplicate import, your documents should all be in different namespaces (its's not nice but will still work). [2012-03-15 18:23:09,116] INFO - WSDLRegistry - WSDL at file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/GetLVRandomProxy.wsdl is already imported, this denotes a circular reference. [2012-03-15 18:23:09,134] ERROR - BpelC - file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/RestfulProxy.bpel:72: error: [CopyToMessageFromNonMessage] Copy to message variable RestProxyPLRequest requires a message for the r-value. [2012-03-15 18:23:09,139] ERROR - BpelC - file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/RestfulProxy.bpel:95: error: [CopyFromMessageToNonMessage] Copy from message variable RestProxyPLResponse requires a message for the l-value. [2012-03-15 18:23:09,143] ERROR - BPELUploadExecutor - BPEL Process Compilation Failure. org.apache.ode.bpel.compiler.api.CompilationException: error: [CompilationErrors] Compilation completed with 2 error(s): file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/RestfulProxy.bpel:72: error: [CopyToMessageFromNonMessage] Copy to message variable RestProxyPLRequest requires a message for the r-value. file:/D:/ESB/WSO2/wso2bps-2.1.0/tmp/work/bpelTemp/1.33183578879275E12/BPELREST/RestfulProxy.bpel:95: error: [CopyFromMessageToNonMessage] Copy from message variable RestProxyPLResponse requires a message for the l-value. at org.apache.ode.bpel.compiler.BpelCompiler.compile(BpelCompiler.java:815) at org.apache.ode.bpel.compiler.BpelC.compile(BpelC.java:278) at org.apache.ode.bpel.compiler.BpelC.compile(BpelC.java:364) at org.apache.ode.store.DeploymentUnitDir$5.run(DeploymentUnitDir.java:213) at org.apache.ode.utils.InternPool.runBlock(InternPool.java:57) at org.apache.ode.store.DeploymentUnitDir.compile(DeploymentUnitDir.java:210) at org.apache.ode.store.DeploymentUnitDir.compile(DeploymentUnitDir.java:169) at org.wso2.carbon.bpel.ui.fileupload.BPELUploadExecutor.validateBPELPackage(BPELUploadExecutor.java:262) at org.wso2.carbon.bpel.ui.fileupload.BPELUploadExecutor.execute(BPELUploadExecutor.java:101) at org.wso2.carbon.ui.transports.fileupload.AbstractFileUploadExecutor.executeGeneric(AbstractFileUploadExecutor.java:105) at org.wso2.carbon.ui.transports.fileupload.FileUploadExecutorManager$CarbonXmlFileUploadExecHandler.execute(FileUploadExecutorManager.java:392) at org.wso2.carbon.ui.transports.fileupload.FileUploadExecutorManager$FileUploadExecutionHandlerManager.startExec(FileUploadExecutorManager.java:276) at org.wso2.carbon.ui.transports.fileupload.FileUploadExecutorManager.execute(FileUploadExecutorManager.java:125) at org.wso2.carbon.ui.transports.FileUploadServlet.doPost(FileUploadServlet.java:57) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:36) at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:155) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.wso2.carbon.server.TomcatServer$1.invoke(TomcatServer.java:241) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399) at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)


回答1:


I tried this and here I have provided a BPEL sample to invoke the following proxy service. Please find the sample artifacts from here. Note - You have to get a api key from goodreads and replace with MyKeyHere.

<proxy name="GetProxy" transports="https http" startOnLoad="true" trace="disable">
        <target>
            <inSequence>
                <log level="full"/>
                <property name="HTTP_METHOD" value="GET" scope="axis2"/>
                <property name="REST_URL_POSTFIX" value="/4776766.xml?key=MyKeyHere" scope="axis2"/>
                <send>
                    <endpoint>
                        <address uri="http://www.goodreads.com/author/list"/>
                    </endpoint>
                </send>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
    </proxy>



回答2:


Here's an ESB proxy configuration that worked for me for a GET request.

<proxy name="GetProxy" transports="https http" startOnLoad="true" trace="disable">
        <target>
            <inSequence>
                <log level="full"/>
                <property name="HTTP_METHOD" value="GET" scope="axis2"/>
                <property name="REST_URL_POSTFIX" value="/4776766.xml?key=MyKeyHere" scope="axis2"/>
                <send>
                    <endpoint>
                        <address uri="http://www.goodreads.com/author/list"/>
                    </endpoint>
                </send>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
    </proxy>

This is for a POST request

<proxy name="TestProxy" transports="https http" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <log level="full"/>
            <property name="messageType" value="application/xml" scope="axis2"/>
            <property name="ContentType" value="application/xml" scope="axis2"/>
            <send>
                <endpoint>
                    <address uri="http://localhost:8080/TestServlet/emal/xml_api"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <property name="messageType" value="text/xml" scope="axis2"/>
            <property name="ContentType" value="text/xml" scope="axis2"/>
            <send/>
        </outSequence>
    </target>
</proxy>

BTW did you mean to say that you successfully accessed that proxy service via Gadget Server, but not via BPS? Can you post the ESB proxy configuration and the error logs you got from BPS?



来源:https://stackoverflow.com/questions/9707851/how-to-invoke-a-rest-proxy-service-running-on-the-esb-from-a-bpel-process-on-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!