JBoss ESB XML MEP Behviour - jboss

I am using JBoss AS 5.1.0 and Jboss ESB 4.10
I am trying to Invoke a Service which has a single action. I have Set MEP = oneWay for the Service.
When I Invoke the Service Using the Below Method I do not get a reply but an Exception.
new ServiceInvoker("Chapter3Sample", "Chapter3Service").deliverSync(esbMessage, 10000);
WHen I change mep=RequestResponse : I am able to get the Reply
As per my understanding ESB Message has a ReplyTo field (Since I am invkoing a Sync Request) the Message should be returned back by the last Action which is not happening in my case. Please find below the ESB XML:
<?xml version="1.0"?>
<jbossesb parameterReloadSecs="5"
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
<providers>
<jms-provider connection-factory="ConnectionFactory" name="JBossMQ">
<jms-bus busid="chapter3GwChannel">
<jms-message-filter dest-name="queue/chapter3_Request_gw" dest-type="QUEUE"/>
</jms-bus>
<jms-bus busid="chapter3EsbChannel">
<jms-message-filter dest-name="queue/chapter3_Request_esb" dest-type="QUEUE"/>
</jms-bus>
</jms-provider>
</providers>
<services>
<service category="Chapter3Sample"
description="A template for Chapter3" name="Chapter3Service">
<listeners>
<jms-listener busidref="chapter3GwChannel" is-gateway="true" name="Chapter3GwListener"/>
<jms-listener busidref="chapter3EsbChannel" name="Chapter3Listener"/>
</listeners>
<actions mep="OneWay">
<action class="org.jboss.soa.esb.samples.chapter3.MyAction"
name="BodyPrinter">
<property name="process" value="displayMessage"/>
<property name="symbol" value="*"/>
<property name="count" value="50"/>
<property name="propertyName">
<hierarchicalProperty attr="value">
<inner name="myName" random="randomValue"/>
</hierarchicalProperty>
</property>
<property name="exceptionMethod" value="processException"/>
<property name="okMethod" value="processSuccess"/>
</action>
</actions>
</service>
</services>
</jbossesb>

When your are invoking call as synchronus.
new ServiceInvoker("Chapter3Sample", "Chapter3Service").deliverSync(esbMessage, 10000).
set mep=RequestResponse.
when your are invoking call asynchronus.
new ServiceInvoker("Chapter3Sample", "Chapter3Service").deliverASync(esbMessage, 10000).
set mep=oneWay .

Related

Process cxf request with amq

I want to make such a solution:
cxf https soap service gets a request and sends it to activemq queue
1
service implementation gets message from queue 1, process it and
puts to queue 2
endpoint gets response from queue 2 and sends
response to a client
Now, I came with a kind of a solution but I'm not sure how to process response from activemq and send back as SOAP response. My camel blueprints below. Endpoint blueprint:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://cxf.apache.org/blueprint/bindings/soap http://cxf.apache.org/schemas/configuration/blueprint/soap.xsd">
<bean id="cardServiceEndpoint" class="com.endpoint.card.CardEndpoint">
<argument>
<reference interface="com.card.CardService" />
</argument>
</bean>
<cxf:cxfEndpoint
id="cardEndpoint"
address="https://host:port/soa/card"
serviceClass="com.card.CardService">
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
</cxf:properties>
</cxf:cxfEndpoint>
<bean id="jaxB" class="org.apache.camel.model.dataformat.JaxbDataFormat">
<property name="prettyPrint" value="true" />
<property name="contextPath" value="com.type.card" />
</bean>
<camelContext id="endpoint-card-cxf" xmlns="http://camel.apache.org/schema/blueprint">
<route id="endpoint-soap-in">
<from uri="cxf:bean:cardEndpoint"/>
<transform>
<simple>${body[0]}</simple>
</transform>
<marshal ref="jaxB"/>
<setHeader headerName="JMSType">
<simple>${headers.operationName}</simple>
</setHeader>
<to uri="amq:q.in"/>
</route>
<route id="endpoint-soap-out">
<from uri="amq:q.out" />
<unmarshal ref="jaxB" />
<!-- STUCK HERE :( -->
</route>
</camelContext>
</blueprint>
Service processor blueprint:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="cardService" class="com.card.impl.DefaultCardService">
<argument>
<reference interface="com.base.StashService"/>
</argument>
</bean>
<service interface="com.card.CardService" ref="cardService" />
<bean id="amqCardServiceEndpoint" class="com.card.endpoint.AmqCardEndpoint">
<argument ref="cardService" />
</bean>
<bean id="jaxB" class="org.apache.camel.model.dataformat.JaxbDataFormat">
<property name="prettyPrint" value="true" />
<property name="contextPath" value="com.type.base:com.type.card" />
</bean>
<camelContext id="service-card-cx" xmlns="http://camel.apache.org/schema/blueprint">
<route id="card-rq-broker">
<from uri="amq:queue:q.in?asyncConsumer=true" />
<unmarshal ref="jaxB" />
<doTry>
<bean ref="amqCardServiceEndpoint" method="invoke" />
<doCatch>
<exception>com.type.base.BaseException</exception>
<setBody>
<simple>${exception.getFaultInfo()}</simple>
</setBody>
</doCatch>
</doTry>
<marshal ref="jaxB" />
<to uri="amq:q.out" />
</route>
</camelContext>
</blueprint>
Any help or advice?
Use jmsReplyTo to specify the name of the reply queue (if you want a fixed queue name) that Camel should use for listening for the response. See more about request/reply on the Camel JMS documentation.
<to uri="amq:q.in?jmsReplyTo=q.out"/>
// continue here when reply is back
http://camel.apache.org/jms

Error when sending Email in WSO2 ESB

I send Mail with WSO2 ESB 5.0.0
1. I have uncommented the following line in Axis2.xml file
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<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">lmphuong</parameter>
<parameter name="mail.smtp.password">password</parameter>
<parameter name="mail.smtp.from">lmphuong#gmail.com</parameter>
</transportSender>
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener">
<!-- configure any optional POP3/IMAP properties
check com.sun.mail.pop3 and com.sun.mail.imap package documentation for more details-->
</transportReceiver>
2. Add content at messageFormatters in axis2.xml
<messageFormatter contentType="text/html" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
3. I have create Proxy Service in WSO2 ESB
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="EmailSender"
transports="http https"
startOnLoad="true">
<description/>
<target>
<inSequence>
<log/>
<property name="messageType"
value="text/html"
scope="axis2"
type="STRING"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<property name="Subject" value="Testing ESB" scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<payloadFactory media-type="xml">
<format>
<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
</format>
<args>
<arg value="Hello WSO2 ESB.....!"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<address uri="mailto:ledung123#gmail.com"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
</target>
</proxy>
4. I recieved error
ERROR - MailTransportSender Error creating mail message or sending it to the configured server
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
...
[2017-09-15 08:04:05,945] ERROR - MailTransportSender Error generating mail message
...
Please help me out how to soved this error
Looks like there´s something wrong with your credentials (AuthenticationFailedException). Do you have any special chracters in your credentials? Or is there are proxy server between esb and gmail?
What you could do is start esb in debug/enable wire log to see the complete traffic. More info can be found here.
https://docs.wso2.com/display/ESB500/Debugging+Mediation#DebuggingMediation-Viewingwirelogs
Another option might be to use the GMail connector which can be found here.
https://docs.wso2.com/display/ESBCONNECTORS/Gmail+Connector
https://store.wso2.com/store/pages/top-assets?q=%22_default%22%3A%22gmail%22

Restore task class in WSO2 ESB

When i use a task in WSO2 ESB it always returns the same error with every web service:
"Unable to handle request. The action '(mySoapAction)' was not recognized"
where (mySoapAction) is every SOAP action used, for EVERY action, for EVERY proxy service i use for task implementation.
What could i do in order to fix this error? I thought a task class error in org.apache.synapse.startup.tasks.MessageInjector.
Obvoiusly the task implementation is correct, because the same tasks some day ago were perfectly working. Suggestions?
Here come a sample with the weather webservice (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL)
Proxy service :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestSOF"
transports="https http"
startOnLoad="true"
trace="disable">
<target>
<endpoint>
<wsdl service="Weather"
port="WeatherSoap12"
uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</endpoint>
<outSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<property name="transport.vfs.ReplyFileName" value="weather.xml" scope="transport"/>
<send>
<endpoint>
<address uri="vfs:file:///E:/temp"/>
</endpoint>
</send>
</outSequence>
</target>
<publishWSDL uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</proxy>
Task :
<?xml version="1.0" encoding="UTF-8"?>
<task xmlns="http://ws.apache.org/ns/synapse"
name="TestSOFTask"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger count="1" interval="1"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="proxyName"
value="TestSOF"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="soapAction"
value="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<weat:GetCityWeatherByZIP xmlns:weat="http://ws.cdyne.com/WeatherWS/">
<weat:ZIP>11010</weat:ZIP>
</weat:GetCityWeatherByZIP>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="format"
value="soap12"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="proxy"/>
</task>
Schedule the task and you will find the service response in a file name weather.xml
If you want to change from soap12 to soap11 :
Change the value of property "format" in the task def to : soap11
Change the endpoint def in the proxy service using port "WeatherSoap" rather than "WeatherSoap12"
Hope it will help you to find what is going wrong with your conf...

WSO2 ESB How to send an email from a JMS message to a custom email address?

I'm wondering if someone can help me with the following setup.
I want to send a message from my application via JMS to WSO2 ESB so the ESB can send it as en email. I'm using ActiveMQ as queue. Until now, when I send a message via the ActiveMQ interface to the queue, wso2 esb gets it. Then, wso2 esb send the message as email to a specific email address.
So I could configure ActiveMQ and WSO2 esb to send the JMS message to a specific email address (eg. specificaddress#test.com).
And here is my question. How can I modify the receiver address for the email? In the ESB sequence configuration, I currently use a specific address. But the address is dependant on the user that uses my application. So I have to change the "To" property, dependant on the user that has to receive the email.
So how can I pass the values for the properties "To", but also for "Subject", through a JMS message to WSO2 esb sequence?
That's the configuration of the sequence I have:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendMail">
<property name="messageType" value="text/html" scope="axis2" type="STRING"></property>
<property name="ContentType" value="text/html" scope="axis2"></property>
<property name="Subject" value="This is the subject." scope="transport"></property>
<property name="To" value="specificaddress#test.com" scope="transport"></property>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property>
<log level="full"></log>
<send>
<endpoint>
<address uri="mailto:"></address>
</endpoint>
</send>
</sequence>
And this is my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sendToMailIn"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="sendMail"/>
<description/>
</proxy>
I hope someone has a clue.
UPDATE
I think I have the solution!!! Wow :-) Maybe, at first, I was stupid, but here it is ...
What you can do is sending a SOAP envelop through a JMS message to WSO2 ESB. And then, with an XPath expression, you can get the passed values. A little bit has to changed at the proxy and the sequence.
This is the new sequence:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendMail">
<property name="messageType" value="text/html" scope="axis2" type="STRING"></property>
<property name="ContentType" value="text/html" scope="axis2"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Subject" expression="$body/subject" scope="transport"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="To" expression="$body/to" scope="transport"></property>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property>
<log level="full"></log>
<send>
<endpoint>
<address uri="mailto:"></address>
</endpoint>
</send>
</sequence>
And this is the new proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sendToMailIn"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="sendMail"/>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/xml</default>
</rules>
</parameter>
<description/>
</proxy>
And this was my SOAP Envelop that WSO2 ESB receives from my ActiMQ queue as JMS message:
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/">
<soapenv:Body>
<subject>Email subject comes here.</subject>
<to>address#test.com</to>
</soapenv:Body>
</soapenv:Envelope>
you have couple of options here.
you can use http headers and send the "to", "subject" values to ESB.
Send it as a payload value and extract using XPath expression
I solved it with using JSON in a JMS message. Here is my setup that works for me.
This is my JSON message:
{"to":"mail#test.com","subject":"TestSubject","mailbody":"Some body text ..."}
This is my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sendToMailIn"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="sendMail"/>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/json</default>
</rules>
</parameter>
<parameter name="transport.mail.ContentType">application/xml</parameter>
<description/>
</proxy>
And this is my sequence:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendMail">
<property name="messageType" value="text/plain" scope="axis2" type="STRING"></property>
<property name="ContentType" value="text/plain" scope="axis2"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Subject" expression="json-eval($.subject)" scope="transport"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="To" expression="json-eval($.to)" scope="transport"></property>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property>
<script language="js">
<![CDATA[var mailbody = mc.getPayloadJSON().mailbody.toString(); mc.setPayloadXML(
<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">{mailbody}</ns:text>);]]>
</script>
<log level="full"></log>
<send>
<endpoint>
<address uri="mailto:"></address>
</endpoint>
</send>
</sequence>

Configure Spring.Web.Services.WebServiceProxyFactory for SOAP MTOM

I create proxy object for WCF servise with Spring.NEt frwm - Spring.Web.Services.WebServiceProxyFactory.
WCF service use SOAP MTOM. Configuration is here:
<basicHttpBinding>
<binding name="MTOM_BINDING"
maxReceivedMessageSize="10000000000"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferSize="10000000000"
maxBufferPoolSize="524288"
bypassProxyOnLocal="true"
messageEncoding="Mtom">
<readerQuotas
maxArrayLength="10000000000"
maxBytesPerRead="10000000000"
maxDepth="10000000000"
maxNameTableCharCount="10000000000"
maxStringContentLength="10000000000"/>
</binding>
</basicHttpBinding>
<service name="TestService"
behaviorConfiguration="DefaultBehavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="MTOM_BINDING"
contract="TestService.ITestService"
bindingNamespace="http://test.com/TEST"
behaviorConfiguration="SimpleWSDLBehavior"/>
<endpoint
contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex"/>
</service>
Confuguration for Spring.Web.Services.WebServiceProxyFactory proxy object:
<object id="testProxy"
type="Spring.Web.Services.WebServiceProxyFactory, Spring.Services">
<property name="ServiceUri" value="http://localhost/TestService.svc?wsdl"/>
<property name="ServiceInterface" value="TestService.ITestService, TestService"/>
<property name="ProductTemplate">
<object>
<property name="Timeout" value="2147483646" />
</object>
</property>
</object>
I could’t find how can I specify for Spring.Web.Services.WebServiceProxyFactory that WCF service use not SOAP but SOAP MTOM.
Because this configuration of Spring.Web.Services.WebServiceProxyFactory except SOAP mesage which has data serialized to text not binnary.
WebServiceProxyFactory is for .asmx Web service.
For WCF support, see:
http://www.springframework.net/doc-latest/reference/html/wcf.html