I've got a service A which is a RESTful client and can send requests periodically, and another service B which is a TCP socket server and can receive tcp socket message. So, my question is whether there's solution to transfer the message from A to B, viz, switching message from http to tcp socket with WSO2 ESB/EI. Actually, I found a guide about how switching from TCP to HTTP/S but not from http to tcp.
The following proxy will work, provided the tcp sender is configured in axis configuration as specified here
<proxy name="TestProxy" transports="http">
<target>
<endpoint>
<address uri="tcp://localhost:6060/TestService"/>
</endpoint>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
</inSequence>
</target>
</proxy>
Related
I am trying to collect data every minute from a REST API and send data to an MQTT Broker.
To realized this I've create a task and some sequences.
I have a sequence that retrieve the API Token from the Restfull API with credentials then call another sequence that call the Restfull API with the token to make a request to the API.
The API then return my the result of the request.
I've manage to create a Proxy Service that send dummy data to an MQTT Broker, but I'm not able to call this Proxy Service after the Rest API return me the data.
How can I call the proxy service after the Token and the data is return to me?
I'm really new to WSO2 so if you know a better way to organize this process please feel free to share your knowledge.
I'm using WSO2 Entreprise Integrator 7.1.0, WSO2 Micro Integrator 1.2.0.
Thanks
The simplest way is to create sequence for send data to MQTT, like below, and call it.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="send.mqtt">
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"/>
<property name="target.endpoint" value="StockReqEndPoint"/>
<send>
<endpoint>
<address uri="mqtt:/SampleProxy?mqtt.server.host.name=localhost&mqtt.server.port=1883&mqtt.client.id=esb.test.sender&mqtt.topic.name=esb.test2&mqtt.subscription.qos=2&mqtt.blocking.sender=true"/>
</endpoint>
</send>
</sequence>
I'm using WSO2 EI 6.3.0 and WSO2 Developer Studio 3.8.0.
I'm working with an ESB Project and a Proxy Service inside it.
The Proxy service is a simple pass through service;
it receives a request from a webapp and forward it to a
Soap Web Service, gets the response from the WS and gives
it back to the web app.
I realized this configuration following this tutorial:
https://youtu.be/3OsuGhEMQgc
The setup is very simple, everything worked fine until I found
a web service whose endpoint has http basic authentication.
I made it work thanks to this article:
https://medium.com/#Jenananthan/wso2-esb-how-to-invoke-basic-auth-protected-endpoint-service-5bcdd8290cb4
Here follows the xml that describes the proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="ProxyWithBasicAuth" startOnLoad="true" trace="disable" transports="https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<endpoint name="endpoint_urn_uuid_xxxxxxxx-yyyy-zzzz-1111-234567892345">
<address trace="disable" uri="https://here.goes.the.uri.of.the.ws.endpoint"/>
</endpoint>
<inSequence>
<property value="this_is_the_username" name="username" scope="default" type="STRING"/>
<property value="this_is_the_password" name="password" scope="default" type="STRING"/>
<property expression="fn:concat($ctx:username,':',$ctx:password)" name="credentials" scope="default" type="STRING"/>
<property expression="fn:concat('Basic ', base64Encode($ctx:credentials))" name="Authorization" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
So, this configuration (xml file) is working, but I wrote all
the section that enables basic auth without using any visual or drag and drop element of the gui.
My questions are:
1) is this the right way to setup basic auth on a proxy service?
2) is there any gui (drag and drop) element that allows to do this setup visually?
Note: I do not need to struggle with basic authentication between
"clients" and the ESB Proxy Service; this question is about basic
authentication between ESB Proxy Service and an "external" web service.
What you have done is correct. To invoke a service secured with Basic Auth, we just have to set the Authorization header to the message. You could use Header Mediator[1] or the Property mediator (as you have already used) to do that. There is no special Mediator (or a GUI element in the Tool) specifically designed for setting the Authorization header.
Btw, you could consider storing passwords in the secure-vault[2] rather than having it in plain text in the Synapse configuration.
[1] https://docs.wso2.com/display/EI640/Header+Mediator
[2] https://docs.wso2.com/display/EI640/Working+with+Passwords+in+the+ESB+profile
I have been trying to do a poc and WSO2 ESB as a JMS producer and consumer. First thing a could not understand is that how our proxy service will consume the message, do we need to initiate or run the service using tryit or soap ui, or it will consume message every time whenever there is a new message in the queue.
can anyone suggest a link or provide a step by step example for this.
below are my proxy service source:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="NewJMSQueue" transports="jms" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">NewJMSQueue</parameter>
<description></description>
</proxy>
You can find several examples from here where ESB is used as a JMS consumer and a producer.
When you put the message into the queue the proxy will automatically pick it from the queue. That is by default ESB will be listening on a JMS queue with the same name as the proxy service and when there is a message proxy service will pick that. Note that you have to configure the JMS transport listener in order achieve that.
You need to copy the required libraries to ESB_HOME/repository/components/lib folder (activemq-core-5.7.0.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar, and geronimo-jms_1.1_spec-1.1.1.jar)
I successfully installed WSO2 EBS and WSO2 Application server in same machine and also i resolved the port conflict issue. I installed backend services in app server mentioned in wso2 portal. My question is how to create a sequence between ebs to appserver in ebs sequence option for message flow between ebs - appserver - ebs.
note: Refer
http://wso2.com/library/articles/2011/01/wso2-esb-by-example-service-chaining.
If it is not possible the above condition means please tell how to make a message flow between ebs to app server mentioned in above URL.
Could you please send any document, video, screen shot regarding this issue as soon as possible.
Thank you.
In this service chaining scenario (in the link you mentioned) what happens is that the services are hosted in Application Server (AS). This hosted URL of the service is then defined as an endpoint in ESB. So when the proxy service in ESB receives a request, mediation is performed on the message and then sent to the endpoint that is defined in the send mediator. The response received from this endpoint, is then through the ESB to the consumer.
If you are looking at how to implement a service chaining scenario, this document will provide more detailed information.
http://wso2.com/library/articles/2012/11/enterprise-service-integration-wso2-esb
Hope this helps.....
In this example I had a proxy service that receives an incoming message from a client.
With this incoming message I extract the information I need from it, in this case the offset and limit using the property mediator as you can see in this line:
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" name="offset" expression="//p:listarPersonas/p:offset"/>
I use the log mediator in this sequence because I need to see the values stored in the properties to debug stuff.
After that I create a new message using the payloadFactory because I need to send this message to the Application Server with that format.
<payloadFactory>
<format>
<p:listar_persona_paginado xmlns:p="http://ws.wso2.org/dataservice">
<p:offset>$1</p:offset>
<p:limit>$2</p:limit>
</p:listar_persona_paginado>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" expression="//p:listarPersonas/p:offset"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" expression="//p:listarPersonas/p:limit"/>
</args>
</payloadFactory>
Then I send the created message to an endpoint in the Application Server using the send mediator:
<send>
<endpoint>
<address uri="http://127.0.0.1:9765/services/buscarPersona"/>
</endpoint>
</send>
All the pieces together:
<sequence xmlns="http://ws.apache.org/ns/synapse">
<log>
<property name="SECUENCIA" value="ENTRADA DEL LISTADO DE PERSONAS"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" name="offset" expression="//p:listarPersonas/p:offset"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" name="limit" expression="//p:listarPersonas/p:limit"/>
</log>
<payloadFactory>
<format>
<p:listar_persona_paginado xmlns:p="http://ws.wso2.org/dataservice">
<p:offset>$1</p:offset>
<p:limit>$2</p:limit>
</p:listar_persona_paginado>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" expression="//p:listarPersonas/p:offset"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://ejemplos.cuba.cu/Persona" expression="//p:listarPersonas/p:limit"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://127.0.0.1:9765/services/buscarPersona"/>
</endpoint>
</send>
</sequence>
You can define your own sequences within the ESB as much as you need. But when you access these sequences from a client, you need to implement a proxy service within the ESB. That proxy service allows you to call any number of sequences within that proxy service. In your case you need to access the backend services which are located in WSO2 application server. You can access these services from mediator. For a list of examples, please refer the below link
http://docs.wso2.org/wiki/display/ESB460/Proxy+Service+Samples
I create a simple WSDL proxy in WSO2 to allow Soap 1.2 enabled applications to work with Soap 1.1 only external web service. Everything is fine except WSO2 doesn't transform soap11 replies back to soap12 when I send request via Soap12 WSO endpoint.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MySOAP" transports="http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<endpoint>
<wsdl service="ExtService" port="ExtPort" uri="https://my.local/wsdl/current
/ExtService.wsdl"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
</endpoint>
</target>
<publishWSDL uri="file:///home/sysadmin/MySOAP.wsdl"/>
<description></description>
</proxy>
Has anybody faced anything similar? WSO2 ESB version 4.6.0
You need to add the format as following.
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11" />
</endpoint>
Format - The message format for the endpoint. The available values are:
[format="soap11|soap12|pox|get"]
Leave As-Is - No transformation is done to the outgoing message.
SOAP 1.1 - Transforming message to SOAP 1.1.
SOAP 1.2 - Transforming message to SOAP 1.2.
Plain Old XML (POX) - Transforming to plain old XML format
Representational State Transfer (REST) - Transforming to HTTP Get
Request
GET
http://docs.wso2.org/wiki/display/ESB460/Default+Endpoint
This has been an issue for a while now. See jira https://wso2.org/jira/browse/ESBJAVA-1994.
If you don't want to manually transform your response from the backend, uncomment the relevant NHTTP transport entries in axis2.xml and comment out the HTTP PassThrough transport entries.