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)
Related
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 am testing WSO2 Message Broker 3.0 and I miss the functionality of subscribing WS endpoints to topics.
Can this functionality be activated with MB 3.0 as it was in MB 2.x?
I am trying to implement reliable (queued) topic subscription for WS-Endpoints. How can it be implemented using WSO2 MB 3.0?
WS-Eventing removed from WSO2 MB 3.0.0. But you can achieve this by integrating WSO2 MB with WSO2 ESB. This is widely used common integration pattern for reliable messaging and also you could modify/mediate message as necessary in WSO2 ESB before send to actual backend. Let's see how we can do this.
I'll show you how to integrate WSO2 ESB with WSO2 MB in local machine.
Download WSO2 ESB 4.9.0 (latest version) from http://wso2.com/products/enterprise-service-bus/. Hope you have WSO2 MB 3.0.0 (latest version) already in hand.
Once you extract, open wso2esb-4.9.0/repository/conf/carbon.xml file and change <Offset>0</Offset> to <Offset>1</Offset>. This allow you to run multiple carbon servers in single machine. You can access management console https://localhost:9444/carbon
Open wso2esb-4.9.0/repository/conf/axis2/axis2.xml and uncomment section after <!--Uncomment this and configure as appropriate for JMS transport support with WSO2 MB 2.x.x--> for JMS transport receiver and section after <!--uncomment this and configure to use connection pools for sending messages--> for JMS transport sender.
Copy andes-client-3.0.1.jar geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
org.wso2.securevault-1.0.0-wso2v2.jar in wso2mb-3.0.0/client-lib to wso2esb-4.9.0/repository/components/lib
Add below entries to wso2esb-4.9.0/repository/conf/jndi.properties
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5672'
connectionfactory.TopicConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5672'
topic.MyDurableTopic = MyDurbleTopic
First start the WSO2 MB and then start WSO2 ESB by running wso2server.sh or wso2server.bat in bin folder depending on OS you are using
Integration completed.
Let's see how we can create JMS listener proxy which creates durable subscription in WSO2 MB. Go to ESB management console, select Proxy service -> Custom Proxy -> Switch to source view. Then copy and paste below synapse configuration to create the JMS listener.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MyDurableTopicListenerProxy"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<log level="custom">
<property name="STATE" value="dispatch message..."/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myTopicConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">topic</parameter>
<parameter name="transport.jms.SubscriptionDurable">true</parameter>
<parameter name="transport.jms.Destination">MyDurbleTopic</parameter>
<parameter name="transport.jms.DurableSubscriberName">subId-x</parameter>
<parameter name="transport.jms.CacheLevel">consumer</parameter>
<parameter name="transport.jms.DurableSubscriberClientID">subId-x</parameter>
<description/>
</proxy>
You can replace whatever the WS endpoint by changing <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>. Here I was used sample axis2 backend. Once you save the proxy service, it'll create durable subscription with MyDurableTopic in WSO2 MB. You don't need to create MyDurableTopic in WSO2 MB. Subscription will create a durable topic (according to JMS spec.).
Now you can send messages to durable topic and see those messages dispatch to WS endpoint. This is JMS to HTTP (cross protocol) transport. Likewise you can integrate standard pattern with this setup.
Hope this would help!
Cheers!
How to develope a web service in WSO2 using proxy services ?
Applying my Oracle Service Bus knowledge here to create a proxy service which would take a string as an Input and return the same as response, I find it difficult in WSO2 to create a proxy service using my XML Schema.
I found that we can do the same in WSO2 using Custom proxy template.
But I am not sure of defining an Input and output in proxy service ;
In a traditional Oracle Service Bus we can do it by defining our XMl Schemas.
Seems like you need some echo kind of a service. This kind of behavior can be achieved by configuring the wso2 esb as in following manner. However this is not really a web service. I hope you are aware of what is web service and what does a proxy service does. But for your requirement you can try something like follows.
<proxy name="loopBackProxy" startonload="true" statistics="disable" trace="disable" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
<target>
<insequence>
<log level="full"></log>
<header action="remove" name="To"></header>
<property name="RESPONSE" value="true"></property>
<!-- your esb modifications here -->
<send></send>
</insequence>
</target>
<description></description>
</proxy>
This doesnot contains a outsequence, what this does is redirects the input to the client.
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.
We have a legacy application that is only able to upload files through ftp protocol. Our current application has SOAP interface for similar file submissions. Is there any way to configure the WSO2 ESB to transform the uploaded file through ftp to SOAP request for consuming by our current application?
Yes that is a very common approach. You can create a VFS proxy that is reading from an FTP. You may then make a transformation (depends on the input format) (i.e. XSLT) to fit your SOAP Endpoint and then simply make a <send> to your WS.
Here an example (only pseudo-code - not tested), but will give you a good starting point:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ftp_proxy_example" transports="vfs" startOnLoad="true" trace="disable">
<parameter name="transport.PollInterval">10</parameter>
<parameter name="transport.vfs.FileURI">vfs:ftp://user:password#server/path</parameter>
<parameter name="transport.vfs.FileNamePattern">.*[.]xml</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<target faultSequence="errorSequence">
<inSequence>
<!-- maybe a transformation -->
<!-- send to your WS endpoint -->
</inSequence>
</target>
</proxy>