Test send email on WSO2 ESB - soap

I want to send emails from esb to some email address.
In order to do so I uncommented this lines in the axis2.xml file:
<transportSender class="org.apache.axis2.transport.mail.MailTransportSender" name="mailto">
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">synapse.demo.0</parameter>
<parameter name="mail.smtp.password">mymailpassword</parameter>
<parameter name="mail.smtp.from">mymail#gmail.com</parameter>
</transportSender>
and
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener">
</transportReceiver>
Then I added this proxy to the WSO2 ESB.
Now I want to send an email from ESB to anymail#gmail.com.
I was thinking on using SoapUI to do so, so I created a new SOAP project and used the link https://localhost:9443/services/MailProxy?wsdl as the Initial WSDL.
Now this appears, but now I don't know what code I should enter in order to send the email. Can anyone help me, please?

You can define the receiver's mail address like below, in the address endpoint of the proxy service configuration.
<send>
<endpoint>
<address uri="mailto:anymail#gmail.com"/>
</endpoint>
</send>

Related

setting up client affinity for db2 purescale

I have a DB2 Purescale environment set up. I am trying to configure client affinity for it on my client machine. I have modified my db2dsdriver.cfg file as follows to include the client affinity parameters:-
<configuration>
<dsncollection>
<dsn alias="sample" name="sample" host="127.0.0.0" port="50000">
<parameter name="Authentication" value="Server"/>
</dsn>
</dsncollection>
<databases>
<database name="sample" host="127.0.0.0" port="50000">
<parameter name="keepAliveTimeout" value="20"/>
<acr>
<parameter name="enableAcr" value="true"/>
<parameter name="enableSeamlessACR" value="true"/>
<parameter name="maxAcrRetries" value="2"/>
<parameter name="acrRetryInterval" value="3"/>
<parameter name="affinityFailbackInterval" value="60"/>
<parameter name="enableAlternateServerListFirstConnect" value="false"/>
<alternateserverlist>
<server name="host-1" hostname="127.0.0.0" port="50000"/>
<server name="host-2" hostname="127.0.0.1" port="50000"/>
<server name="host-3" hostname="127.0.0.2" port="50000"/>
</alternateserverlist>
<affinitylist>
<list name="list1" serverorder="host-1,host-2,host-3">
</list>
</affinitylist>
<clientaffinitydefined>
<client name="ABC" hostname="127.0.0.3" listname="list1">
</client>
</clientaffinitydefined>
</acr>
</database>
</databases>
</configuration>
Please note that all the IPs and the machine names provided here are just made up.
But, when I try the db2clp to connect to my database, I get the following error:-
"SQL5163N A required configuration parameter "listname or serverorder under affinitylist group" is missing from the db2dsdriver.cfg configuration file."I have tried but cannot figure out what is missing as both the listname and the serverorder are present in the file.
Also, if I use the CLPPLUS to access the DB from client machine, I can access the DB on host-1, but if I stop the instance on host-1 to test client affinity, my client machine cannot connect to the DB on host-2. I get the following error:-
Error when instance stopped on host-1 and running on host-2
Can someone please help me understand what might be the problem?
Check the following address:
<client name="ABC" hostname="127.0.0.3" listname="list1">
</client>
This must be your client's address. If it's not correct, you get such an error you mentioned.
As for CLPPLUS. It's a jdbc application, and it doesn't use db2dsdriver.cfg.
You must set the corresponding properties.
Example of enabling client affinities in Java clients for Db2 on Linux, UNIX, and Windows systems connections.

WSO2 REST proxy answer back with SOAP instead of REST

Recently I had a problem with wso2 esb that I cannot resolve (maybe a bug). I will try to explain it as clear as possible.
I use the wso2 ESB with a rest proxy in order to communicate from a frontend application to a backend Rest service.
I defined a rest proxy with an endpoint like this and it worked fine:
<endpoint>
<address uri="http://127.0.0.1:8099/DummyRestServiceWSO2"/>
</endpoint>
But our goal is to integrate WSO2 esb in a container inside an openshift environment. In openshift the ip are set dynamically but accessible through system environment variable. So I tried to solve my endpoint dynamically byusing the header tag:
<endpoint>
<default/>
</endpoint>
<inSequence>
<script language="js">mc.setProperty("url",java.lang.System.getenv("HOST_IP"));</script>
<property name="service_url" expression="fn:concat(get-property(url),'/DummyRestServiceWSO2')"/>
<header name="To" expression="get-property('service_ep')"/>
<send/>
</inSequence>
Where HOST_IP is defined as: http://127.0.0.1:8099
Since I made this change my call to the backend rest service is still working fine but the response to the caller (frontend) is now formatted as soap (I tried to draw the problem, see attachment).
Thanks a lot for your help and I wish a wonderfull day to whoever read this post :)
If by "REST" you mean "JSON" format, just define this property before sending back the reponse to the client :
<property name="messageType" value="application/json" scope="axis2"/>
Use application/xml for plain xml (no SOAP envelope / body)
You also can use a default endpoint in send mediator and define the format :
<send>
<endpoint>
<default format="rest">
<timeout>
<responseAction>fault</responseAction>
</timeout>
</default>
</endpoint>
</send>

The endpoint reference (EPR) for the Operation not found using glassfish n wso2esb

I am new to wso2 esb.
I am trying a simple web service program.
package testmart;
import javax.jws.WebService;
#WebService
public class testone {
public String testMethod()
{
return "success";
}
}
I am using glassfish server, created a proxy on wso2 esb by giving following details:
web service url: http://localhost:8080/testmart/testoneService
wsdl url :http://localhost:8080/testmart/testoneService?wsdl
After creating its showing "success" msg. But when I test it, the following error comes up:
<soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:axis2ns7="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Code>
<soapenv:Value>axis2ns7:Client</soapenv:Value>
</soapenv:Code>
<soapenv:Reason>
<soapenv:Text xml:lang="en-US" xmlns:xml="http://www.w3.org/XML/1998/namespace">
The endpoint reference (EPR) for the Operation not found is /services/testmart1.testmart1HttpSoap12Endpoint and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
</soapenv:Text>
</soapenv:Reason>
<soapenv:Detail/>
</soapenv:Fault>
Below is my esb source view code:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
<parameter name="cachableDuration">15000</parameter>
</registry>
<proxy name="testmart1"
transports="https http local"
startOnLoad="true"
trace="disable">
<description/>
<target>
<endpoint>
<address uri="http://localhost:8080/testmart/testoneService"/>
</endpoint>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://localhost:8080/testmart/testoneService?wsdl"/>
</proxy>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<in>
<log level="full"/>
<filter source="get-property('To')" regex="http://localhost:9000.*">
<send/>
</filter>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
</definitions>
I read all post about this error but could not solve this problem.
Any sort of help would be highly appreciated as this was the first example I tried and stuck from hours.
Thanks in advance.
When you send the request check if the SOAPAction is set. If not, you can specify it in two ways:
ESB level
Set the property before the send mediator
<property name="SOAPAction" value="urn:SOAPAction" scope="transport"/>
Client level
You can specify the SOAPAction in the client side code. Specify it in the options as shown below.
options.setAction("urn:SOAPAction");
in web interface from WSO2 ESB click "Source View" for your proxy and put this lines:
...
<parameter name="serviceType">proxy</parameter>
<parameter name="disableOperationValidation">true</parameter>
...
before the tag:<description/>
On Websphere Application Server, in the same situation, it helped deleting the Temp folders while the server was stopped.
You are using Wso2ESB, so you must need to specify like this:
#WebMethod(action = "testMethod", operationName = "testMethod")
public String testMethod()
The above annotation has to be used in the Web service implementation class.

PostgreSql Connection in Custom Mediator WSO2

I write my own custom mediator in WSO2 ESB. I use spring jdbc with postgresql in my custom mediator. My question here, I called my custom mediator from the proxy service in WSO2, something like this :
<proxy name="MyProxy"
transports="vfs"
startOnLoad="true"
trace="disable">
<target>
<inSequence>
<class name="com.test.CustomMediatorWithPostgres"/>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///test</parameter>
<parameter name="transport.vfs.FileURI">file:///test1</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
I declare the connection in the init method of my custom mediator. My question here, if I make for example 1000 proxy that called the class CustomMediatorWithPostgres, It will create about 1000 connection to postgre, so if I make 100000 proxy service than it will create 100000 connection too. Is this bad or is there something I can do to make for example a global connection that I can use in my whole proxy service? thanks....
i think it is better if you use dataservice server to handle DB logic, and call that from your proxies. In the DS you can provide connection settings
Or have the logic to handle DifferentFileURIs in the custom mediator. Then you can use the connection pool to handle

How to encode ¿ to ISO-8859 with WSO2 ESB

During the evaluation of sample data I discovered the following problem. When the content in the JMS contains the "upside down question mark" <test>Inverted¿QuestionMark</test>, the proxy crashes - in fact hangs and the CPU goes up to 100%.
Here the code of the proxy to reproduce easily:
Just add <test>Inverted¿QuestionMark</test> into a queue named "test_qEncoding" and see how the CPU goes up and the proxy hangs.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="test_encoding_crash_jms" transports="jms" startOnLoad="true" trace="disable">
<parameter name="transport.jms.Destination">test_qEncoding</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml;charset="iso-8859-15"</default>
</rules>
</parameter>
<target>
<inSequence>
<log level="custom">
<property name="Context" value="Proxy test_encoding_crash_jms called"/>
</log>
<log level="full"/>
</inSequence>
</target>
</proxy>
When I use a vfs proxy and read as ISO-8859 it works. When I don't specify ;charset="iso-8859-15"then it works also, but the content is then not in the correct endoding for my output.
How should I get the message from the JMS when I want to send it then as ISO-8859?
Why does the above proxy hangs and blocks the whole WSO2 ESB?
This was reported sometime back [1]. Seems to be an issue existing. Please refer the JIRA for more details. Further if you can reproduce it consistently please mention that so we can raise the priority.
[1] https://wso2.org/jira/browse/ESBJAVA-1751