WSO2 - Forward response from REST (called from WSO2) to JMS queue - api

I've faced an issue, with trying to forward message, returned from my custom REST end-point, into JMS queue.
I wanted to implement something like:
SMTH CUSTOM IS PUSHING MESSAGE TO WSO2 JMS QUEUE called testQueue
WSO2 is retrieving this message, and once there is an message, it's pushing this message next to custom REST service:
Becasue I've defined receive to testResponse inside send section, I'm able to log reponse from REST API inside testResponse.
Now I'm stuck, as I'm trying to somehow push response from REST API next, to let say second JMS queue, called testQueue2.
I've already tried with call tags inside my custom sequence (called testReponse), but it's just not executing at all (I've also tried for test, just to execute second REST API inside, to be just sure, if it's not something with executing of JMS itself...):
Any ideas, how I can move response from called REST API on to JMS queue?
Thanks.
<proxy name="testQueue" startOnLoad="true" transports="jms">
<target>
<inSequence>
<send receive="testResponse">
<endpoint>
<http format="rest" method="POST" uri-template="http://localhost/customRestAPI?message=test" />
</endpoint>
</send>
</inSequence>
<outSequence />
</target>
</proxy>
<sequence name="testResponse">
<log level="full" />
</sequence>

Try adding an "Out Flow" mediation extension as explained here.

Related

WSO2 ESB 5.0.0 BETA WebSocket InboundEndPoint

I'm testing the beta release of wso2 esb 5.0.0 which has an interesting feature for me, websockets.
I declare de inbound endpoint,like the documentation define (https://docs.wso2.com/display/ESB500/WebSocket+Inbound+Protocol) but i am only be capable of receive empty messages from my client (the connection is done) and i can not be capable to send any message to my cliente.
Have any one try this feature?
Thanks.
PD: this is my ws inbound enpoint
<inboundEndpoint name="testws" onError="errorsq" protocol="ws"
sequence="testwssq" suspend="false">
<parameters>
<parameter name="inbound.ws.port">9091</parameter>
<parameter name="ws.outflow.dispatch.sequence">testbesq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence">errorsq</parameter>
<parameter name="ws.client.side.broadcast.level">1</parameter>
</parameters>
</inboundEndpoint>
and these are my sequences
<sequence name="testbesq">
<log level="full"/>
</sequence>
<sequence name="testwssq">
<log level="full"/>
<log level="custom">
<property name="request" value="message receive"/>
</log>
</sequence>
Unlike HTTP, which is an application-level protocol, in the WebSocket protocol there is no enough information in an incoming message to process these messages, these messages are either text or binary low-level frames. Because of this, we had to define some custom subprotocol over WebSocket. This will allow both client and server parties to know the content type of frames they communicate.
By default every Inbound endpoint support following Synapse subprotocols.
synapse(contentType='application/json')
synapse(contentType='application/xml')
synapse(contentType='text/xml')
I used Netty WebSocket client and below command to test this. And once client connected(handshake), I put message <Test>message</Test> and I could see the backend response on websocket client side.
java -DsubProtocol="synapse(contentType='application/xml')" -DclientPort=9091 -cp netty-example-4.0.30.Final.jar:lib/*:. io.netty.example.http.websocketx.client.WebSocketClient

Wso2 esb tryit tool works but testing with SOAP UI for same proxy does not work

Iteration mediator works with WSo2 Tryit tool but when the same message is sent through SOAP UI the proxy it does not iterate. My proxy service is very simple it has a xslt mediator and then does the iteration. Do I need to change the content type?
Can you paster your proxy service source code.
Try it tool is a evolving tool, but you should always do your testing from SOAP UI.
This is the sample format :-
<iterate expression="//m0:getQuote/m0:request" preservePayload="true"
attachPath="//m0:getQuote"
xmlns:m0="http://services.samples">
<target>
<sequence>
<send>
<endpoint>
<address
uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</sequence>
</target>

wso2 : ESB faultsequence

how to use faultsequence of proxy in esb
i want to use faultsequence when occur a fault in EndPoint. for example i stop service1 using jconsole and want to route message to service2 when call proxy service. but when i call proxy using soapui it show fault this message : The system is attempting to access an inactive service..
<target>
<inSequence >
<send>
<endpoint name="cal" >
<address uri="http://localhost:9763/services/service1/"/>
</endpoint>
</send>
</inSequence>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured for service"/>
<property name="message" expression="get-property('ERROR_MESSAGE')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9763/services/service2/"/>
</endpoint>
</send>
</faultSequence>
please guide me!
When your endpoint 1 is inactive it returns a soap fault and you want it to go to the fault sequence. But at the moment that fault sequence is considered as a response and it is sent to the client (soap ui).
In WSO2 ESB 4.5.0 onwards, there is a new property FORCE_ERROR_ON_SOAP_FAULT added. By setting this property, soap faults will be directed to fault sequence. You can do your next logics when you are in the fault sequence (for example invoking another sequence).
Refer [1] for a sample proxy service.
[1] http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html
I believe your exact scenario is apart of your main end point if it faild you need to route the message to secondary endpoint.
Correct approach to your implementation is not using the fault sequence right approach is using fail over endpoint. You can find reference document at [1][2].
For sample you can refer "Sample 53: Failover sending among 3 endpoints" [3].
[1].http://wso2.org/project/esb/java/3.0.1/docs/endpoint_guide.html#FoEp
[2].http://docs.wso2.org/wiki/display/ESB403/Failover+Endpoint
[3].http://wso2.org/project/esb/java/3.0.1/docs/samples/endpoint_mediation_samples.html
Thank You,
Dharshana.

Error accesing published WS proxy in WSO2 ESB 4.6: EPR not found

I deployed exactly the same WS-proxy in 4.5.1 and 4.6. With 4.5.1 it works correctly, but with 4.6 I get:
ERROR - AxisEngine The endpoint reference (EPR) for the Operation not found is /services/registro.registroHttpSoap11Endpoint and the WSA Action = . If this EPR was previously reachable, please contact the server administrator.
The source is the following:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="registro" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:15080/SIGEM_RegistroPresencialWS/services/ServicioRegistroWebService"/>
</endpoint>
</target>
<publishWSDL uri="http://localhost:15080/SIGEM_RegistroPresencialWS/services/ServicioRegistroWebService?wsdl"/>
<description></description>
</proxy>
What do I have to do for 4.6. to make it work?
Thanx.
To enhance ESB performance pass-through transport has been enabled by default starting from ESB 4.6.0 version that is not the case for ESB 4.5.1. It seems your proxy service depends on SOAP body based dispatching but pass-through transport does not support for SOAP body based dispatching. SOAP body based dispatching build the message body and use first element's local name for dispatching which effect to proxy performance badly that is the reason it was not supported in pass-through transport. We are in a process to fix this limitation for future ESB releasees without loosing any advantage of pass-through transport.
BTW for the moment you can use one of the following workarounds.
When sending a messages to the proxy service append operation name to the endpoint URL
e.g - http://serverName/app/serviceName/operationName
Modify client level code to send expected SOAPAction value ( like Try-It case)
I'm not sure your backend service's WSDL defined "" as the value of SOAPAction if that is the case you may modified the backend service to have value other than "" per each operation. AS an example for JAX-WS services you can use #WebMethod annotation for this.
e.g - #WebMethod(action="XXXX")
Note : In case if your backend WSDL defining a value other than "" for SOAPAction while your client send message with SOAPAction="" then it's a violation of service contract by the client and need to be fixed on client level.
I have faced the same problem with wso2 ESB 4.7 and the web service is also developed by me for the company.
What worked for me is adding soapAction attribute to wsdl soap:operation element like below.
<soap:operation soapAction="http://localhost:8080/MyWebApp/services/hello" style="document"/>

Why do I get transport error in WSO2 ESB if I remove the filter?

I have the following proxy:
<proxy name="expedientes" transports="https http" startOnLoad="true" trace="enable" statistics="enable">
<target inSequence="main" outSequence="main" faultSequence="main">
<endpoint>
<address uri="https://someweb/somepath/"/>
<property name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"/>
</endpoint>
</target>
</proxy>
with the this default main sequence:
<sequence name="main">
<in>
<log level="full"/>
<filter source="get-property('To')" regex="http://localhost:9000.*">
<send/>
</filter>
</in>
<out>
<send/>
</out>
</sequence>
When I remove the filter and leave it as:
<sequence name="main">
<in>
<log level="full"/>
<send/>
</in>
<out>
<send/>
</out>
</sequence>
I get the following error "Unexpected error during sending message out: org.apache.axis2.AxisFault: The system cannot infer the transport information from the /services/expedientes/indice.xml":
TID: [] [WSO2 ESB] [2013-02-15 12:42:05,531] ERROR
{org.apache.synapse.core.axis2.Axis2Sender} - Unexpected error during sending message out
{org.apache.synapse.core.axis2.Axis2Sender}org.apache.axis2.AxisFault: The system cannot infer the transport information from the /services/expedientes/indice.xml URL. at
...
The out message should (obviously) use the same transport to answer the request (HTTP GET). But what has this to do with "filter"?
Basically in the segment of configuration above (the one with filter mediator) it checks the "TO" header property of your message weather it is equals to "http://localhost:9000.*" or not.
If that condition fired, it simply send your message to the destination. Else the message send inside the "out" mediator.
When you remove the expression what happened is, it trying to send the all messages which are coming inside "in" mediator without knowing weather there is a "To" property or not.
In your case the incoming messages aren't containing a valid "To" property.
The default mediator inside main sequence to send message out is the "out" mediator. The "in" mediator doesn't know the message is expected to send as a response otherwise you did not say it is a resonance message explicitly.You can do it by using configuration like this
<header action="remove" name="To"/>
<property action="set" name="RESPONSE" scope="default" type="STRING" value="true"/>
But It strongly depend on your usecase though
I suggest you to go through some references regarding message mediation with WSO2 ESB.
Following are good references which I found hope you can find more
Configuring the ESB to Perform Message Mediation
Message Mediation
Thanks,