WSO2 EI - RelayUtils Error while building Passthrough stream - java

I'm using WSO2 EI 6.3.0 and i want to get data from specific webservice and push this data to an other webservice.
In the first time, i have to get the JWT Token from a first webservice to put it in the second call to get data.
So, i created several sequence to have reusable sequences.
I have the error when i want to inject bearer token header into my endpoint to get data.
STEP OF IN SEQUENCE
During the LogincheckSeq, i call the login_check api to get the JWT Token.
Then during the createBearerTokenSeq, i only create a property with the token recovered from LoginCheckSeq
Then we pass in the CreateBearerTokenSeq, to create a property with the token recovered before from the json response of the LoginCheckEP
Finally, we pass in the last sequence GetCustomerSeq to get customers informations from the webservice in json thanks to the jwt token given in the header (Authorization: Bearer token)
This is my CustomerAPI.xml :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/customers" name="CustomersAPI"
xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET" uri-template="/">
<inSequence>
<log level="custom" separator="
">
<property name="API CUSTOMER" value="START"/>
</log>
<sequence key="LoginCheckSeq"/>
<sequence key="CreateBearerTokenSeq"/>
<sequence key="GetCustomersSeq"/>
</inSequence>
<outSequence>
<log>
<property expression="$axis2:HTTP_SC" name="Status Code" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
</outSequence>
<faultSequence>
<log level="full"/>
</faultSequence>
</resource>
</api>
LoginCheckSeq.xml
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="LoginCheckSeq" trace="disable"
xmlns="http://ws.apache.org/ns/synapse">
<log level="custom" separator="
">
<property name="Login SEQUENCE" value="START"/>
</log>
<property expression="json-eval($.username)" name="uri.var.username" scope="default" type="STRING"/>
<property expression="json-eval($.password)" name="uri.var.password" scope="default" type="STRING"/>
<log level="custom" separator=",">
<property expression="fn:concat('Username : ', get-property('uri.var.username'), ' / Password : ',get-property('uri.var.password')) " name="PARAMS"/>
</log>
<call>
<endpoint key="LoginCheckEP"/>
</call>
</sequence>
CreateBearerToken.xml
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="CreateBearerTokenSeq" trace="disable"
xmlns="http://ws.apache.org/ns/synapse">
<log level="custom" separator="
">
<property name="Create Bearer Token SEQUENCE" value="START"/>
</log>
<payloadFactory media-type="json">
<format>{"token":"$1"}</format>
<args>
<arg evaluator="json" expression="$.token"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<property expression="json-eval($.token)" name="uri.var.jwt.token" scope="default" type="STRING"/>
</sequence>
GetCustomerSeq.xml
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="GetCustomersSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log description="" level="custom" separator="
">
<property name="Get Customer SEQUENCE" value="START"/>
</log>
<log description="" level="custom" separator="##">
<property expression="fn:concat('Bearer ', get-property('uri.var.jwt.token'))" name="JWT Token Created"/>
</log>
<header name="Authorization" expression="fn:concat('Bearer ', get-property('uri.var.jwt.token'))" scope="transport"/>
<send>
<endpoint key="GetCustomersEP"/>
</send>
</sequence>
I get well the JWT Token from LoginCechkSeq but i have an error in the getCustomerSeq.
This is the error :
[2018-08-14 15:14:07,510] [EI-Core] INFO - LogMediator API CUSTOMER = START
[2018-08-14 15:14:07,511] [EI-Core] INFO - LogMediator Login SEQUENCE = START
[2018-08-14 15:14:07,511] [EI-Core] INFO - LogMediator PARAMS = Username : test#test.fr / Password : Azerty123
[2018-08-14 15:14:08,586] [EI-Core] INFO - LogMediator Create Bearer Token SEQUENCE = START
[2018-08-14 15:14:08,591] [EI-Core] INFO - LogMediator Get Customer SEQUENCE = START
[2018-08-14 15:14:08,591] [EI-Core] INFO - LogMediator JWT Token Created = Bearer eyJhbGciOiJSUzI1NiJ9.eyJyb2xlcyI6WyJST0xFX1VTRVJfTUFUT09NQSIsIlJPTEVfVVNFUiJdLCJ1c2VybmFtZSI6InRlc3RAdGVzdC5mciIsImZpcnN0TmFtZSI6I kxvXHUwMGVmYyIsImxhc3ROYW1lIjoiQ2FyaW91IiwiaWQiOjIwLCJpYXQiOjE1MzQyNTI0NDgsImV4cCI6MTUzNDI2Njg0OH0.Gx_cSwXE0rm1EZSPeI64cbOdysjXcLwj2NYjtNE4eh_gtUSwbCE2EUPL6sB-Rt_ayQOeOEx-w07Bkbh-Rr6rUd-mqnKXHuUCe76pOXWWW5ejV7k8n_ Tf3gk4upbzn77VMsyNALWJYNBSO4S8dDCyp413SRvnRaKuhkF1GgvkbZx7aJNUwkDA_ZuxG3IfOKQdao7GgDhWH9pltH9zIjXtjagbjRPgBaekcZiB2bxglQLF7RUMky2MVG_WEbcLFms14LiIEooG3lXao73Z2foYXSMxReHHAmhGPfSipw_wA9ohMolB_X5Ck13O0tSDUvsqvqdZHPZ w8ITmn_4pKnJhTiCK6U58Ub_Nr6Royeiwf3_WN7ooqOczF0hbJr7ZFONo3BwKEhCj6gPv9gknK0ahSotnsRvQS56VsquWJm9ZwtXAI2D0J8tNjSmxMP9FWbmFMWap2wOayUEGpauYD3WA5W-CZexqulJTbLSPcMF92QWaKMoVtL5blgGt9vTb1YIVnQi4KALK9psJETgcvHCIbfsN E_IcYMlotIHRuO4RR-j0I7WAxQVko9YNkIRpuDUftpUq95TbIxn5NeTFhWL_NoC2F3jO4khGYR-Hk2P2ZudygrrdmDMfezn7d5yArV7mlukSB6chwq38T261ktzqx_G_rHt1pjt0jXVhz1DPsY4
[2018-08-14 15:14:10,087] [EI-Core] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:165)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:163)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:116)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:145)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:94)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:351)
at org.apache.synapse.rest.API.process(API.java:338)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:56)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:570)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:193)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 24 more
I tried several thing like add this line :
<messageBuilder contentType="application/json" class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/>
Or add property with name "messageType" with value "application/json"
But nothing resolve my problem...
If someone has already encountered this problem, I'm taking the solution =)

I found the response.
The Content-Type of the server response is : application/ld+json.
So WSO2 didn't recognize the encoding.
I just added this line into the axis2.xml :
<messageFormatter contentType="application/ld+json" class="org.wso2.carbon.integrator.core.json.JsonStreamFormatter"/>
....
<messageBuilder contentType="application/ld+json"
class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/>
And it's work fine ! =)

Related

how to rejected request missing header or wrong header in wso2

I have code in API WSO2 like this
<api context="/request" name="Request" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/Executionreport/{vtid}/{token}">
<inSequence>
<property expression="get-property('uri.var.vtid')" name="Vtid" scope="default" type="STRING"/>
<property expression="get-property('uri.var.token')" name="token" scope="default" type="STRING"/>
<filter regex="1234" source="$ctx:token">
<then>
<log>
<property name="sukses masuk token" value="0"/>
</log>
<sequence key="select_Execution_report"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
</then>
<else/>
</filter>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
so for this request I will use like this one
http://localhost:8280/request/Executionreport/1100/1234
so if the token is wrong I will replay this one
HTTP/1.1 200 OK
soapaction: urn:mediate
Host: localhost:8280
Accept-Encoding: gzip,deflate
cache-control:
Content-Type: application/json; charset=UTF-8
Date: Thu, 23 Jul 2020 07:51:59 GMT
Transfer-Encoding: chunked
Connection: Keep-Alive
{ "status":"401 Not Authenticated" }
i want to change the logic like the request is like
http://localhost:8280/request/Executionreport/1100 with methods GET and have header token=1234
so if token wrong in header request wso2 will rejected so status will be HTTP/1.1 401 unauthorized.
so my question how to create API methods GET and need header in WSO2 ?
You can read the incoming header as below.
<property name="Token" expression="get-property('token')" scope="transport" type="STRING" />
Based on that you can perform any action.

Sending message on wso2 socket, getting exception

I am trying to send a message over TCP in wso2 framework. I am getting this exception in log:
[2015-08-20 12:21:50,098] ERROR - TCPWorker Error while processing TCP request through the Axis2 engine
java.lang.NullPointerException
at org.wso2.carbon.tenant.dispatcher.MultitenantDispatcher.findService(MultitenantDispatcher.java:47)
at org.apache.axis2.engine.AbstractDispatcher.invoke(AbstractDispatcher.java:94)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
at org.apache.axis2.transport.tcp.TCPWorker.run(TCPWorker.java:68)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Following is the axis2 conf to start TCP:
<transportReceiver name="local" class="org.wso2.carbon.core.transports.local.CarbonLocalTransportReceiver"/>
<transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportListener">
<parameter name="transport.tcp.port">6060</parameter>
</transportReceiver>
And wso2.xml:
<definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="fault">
<makefault>
<code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
<reason value="Mediation failed."/>
</makefault>
<send/>
</sequence>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TCPProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="transport.tcp.port">6060</parameter>
<parameter name="transport.tcp.contentType">application/xml</parameter>
<description/>
</proxy>
</definitions>
It sounds like no proxy service can be found in the ESB when a message is received on tcp port 6060.
I'm not used to tcp transport in WSO2 but I wonder if the "transports" attribute in you proxy definition should contain "tcp" instead of "https,http" :
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TCPProxy"
transports="tcp"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="transport.tcp.port">6060</parameter>
<parameter name="transport.tcp.contentType">application/xml</parameter>
<description/>
</proxy>

Facing "unqualified type in strict mode for: MessageExchangePattern" while trying to integrate Mule with Drools

i am trying to integrate mule with drools, i have mainly followed the tutorial here but i am getting this error :
(1,22) unqualified type in strict mode for: MessageExchangePattern
(1,30) unqualified type in strict mode for: ONE_WAY '
it seems impossible to find the solution to me, can any one help me? thanks.
this is my .drl file :
global org.mule.module.bpm.MessageService mule;
import com.hamgam.hit.esb.*;
rule "La Vita Ebela"
dialect "mvel"
when
$x:XMLDTO( inputXML == "inputXML" )
then
mule.generateMessage("emc", "KeyValueMatched", null, MessageExchangePattern.ONE_WAY);
end
and this is mules flow :
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/bpm http://www.mulesoft.org/schema/mule/bpm/3.6/mule-bpm.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.6/mule-vm.xsd ">
<http:listener-config name="HTTP_Listener_Configuration"
host="localhost" port="8084" doc:name="HTTP Listener Configuration" />
<spring:beans>
<spring:bean id="dto" class="com.hamgam.hit.esb.XMLDTO" scope="singleton" />
<spring:bean id="dto-convertor" class="com.hamgam.hit.esb.XMLToDTO" scope="singleton" />
<spring:bean id="rule-convertor" class="com.hamgam.hit.esb.RuleXMLToDRL" scope="singleton" />
</spring:beans>
<bpm:drools />
<flow name="basic_tutorialFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/{name}" doc:name="HTTP" />
<vm:endpoint name = "emc" path="drool.msg" />
<set-variable variableName="name" value="#[message.inboundProperties['http.uri.params']['name']]" />
<set-variable variableName="msg" value="#[payload]"/>
<logger level="DEBUG" doc:name="Logger" message="Current path is flowVars['name']" />
<expression-component>
app.registry['dto'] = app.registry['dto-convertor'].convert(flowVars['name']);
</expression-component>
<bpm:rules rulesDefinition="rule.drl" cepMode="true" initialFacts-ref="dto" entryPoint="XMLDTO stream" />
<choice doc:name="Choice">
<when expression="#[flowVars.emc == 'KeyValueMatched']">
<set-payload doc:name="Set Payload" value="#['KeyValueMatched! You are with us on 8084. ' + flowVars['name'] + '. Today is ' + server.dateTime.format('dd/MM/yy') + '.' ]" />
</when>
<otherwise>
<set-payload doc:name="Set Payload" value="#['Nothing! You are with us on 8084. ' + flowVars['name'] + '. Today is ' + server.dateTime.format('dd/MM/yy') + '.' ]" />
</otherwise>
</choice>
</flow>
</mule>
You need to:
import org.mule.MessageExchangePattern
Otherwise your Drools MVEL script will have no idea what MessageExchangePattern.ONE_WAY is.

Issue with XSLT Transformation using WSO2 ESB

I struggling with XSLT transformer mediator using XSLT mediator in wso2 esb 4.8.1.
The xslt is :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:ns="http://ep.service.ims.com"
xmlns:ax21="http://ep.service.ims.com/xsd"
exclude-result-prefixes="ns fn">
<xsl:param name="amount"/>
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//ns:getResponse" />
</xsl:template>
<xsl:template match="ns:getResponse" xmlns:ns="http://ep.service.ims.com">
<ep:credit xmlns:ep="http://ep.service.ims.com" xmlns:xsd="http://ep.service.ims.com/xsd">
<ep:info>
<xsd:amount>
<xsl:value-of select="$amount"/>
</xsd:amount>
<xsd:personInfo>
<xsd:address>
<xsl:value-of select="ns:return/ax21:address"/>
</xsd:address>
<xsd:id>
<xsl:value-of select="ns:return/ax21:id"/>
</xsd:id>
<xsd:name>
<xsl:value-of select="ns:return/ax21:name"/>
</xsd:name>
</xsd:personInfo>
</ep:info>
</ep:credit>
</xsl:template>
</xsl:stylesheet>
and the request XML is :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getResponse xmlns:ns="http://ep.service.ims.com">
<ns:return xsi:type="ax23:PersonInfo" xmlns:ax23="http://ep.service.ims.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax23:address>IMS Heath, Omega C, India, bnag</ax23:address>
<ax23:id>100</ax23:id>
<ax23:name>WSO2</ax23:name>
</ns:return>
</ns:getResponse>
</soapenv:Body>
</soapenv:Envelope>
I tried the XSLT transformation in eclipse and some online tool like (http://xslt.online-toolz.com/tools/xslt-transformation.php ) and it is working fine. However when I am trying the same in WSO2 ESB, I am facing following exception.....
org.apache.synapse.mediators.transform.XSLTMediator} -
Fatal error occurred in stylesheet parsing :
net.sf.saxon.trans.XPathException:
The supplied file does not appear to be a stylesheet Value {name ='null', keyValue ='xslt1'}
{org.apache.synapse.mediators.transform.XSLTMediator}
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:220)
org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
TID: [0] [ESB] [2014-10-08 13:53:20,705] ERROR
{org.apache.synapse.mediators.transform.XSLTMediator} -
Unable to perform XSLT transformation using :
Value {name ='null', keyValue ='xslt1'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1]
reason : Error creating XSLT transformer using : Value {name ='null', keyValue ='xslt1'}
{org.apache.synapse.mediators.transform.XSLTMediator}
org.apache.synapse.SynapseException: Error creating XSLT transformer using : Value {name ='null', keyValue ='xslt1'} at
org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:313)
Caused by: javax.xml.transform.TransformerConfigurationException:
Failed to compile stylesheet. 1 error detected.
The synapse proxy xml is:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CreditProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="full">
<property name="sequence" value="inSequence - request for CreditProxy"/>
</log>
<property xmlns:pep="http://com.ims.proxy" name="ORG_ID" expression="//pep:credit/pep:id"/>
<property xmlns:pep="http://com.ims.proxy" name="ORG_AMOUNT" expression="//pep:credit/pep:amount"/>
<enrich>
<source type="inline" clone="true">
<pep:get xmlns:pep="http://ep.service.ims.com">
<pep:id>?</pep:id>
</pep:get>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" property="ORG_ID"/>
<target xmlns:pep="http://ep.service.ims.com" xpath="//pep:get/pep:id"/>
</enrich>
<log level="full">
<property name="sequence" value="inSequence - request for PersonInfoService"/>
</log>
<property name="STATE" value="PERSON_INFO_REQUEST"/>
<send>
<endpoint key="PersonInfoEpr"/>
</send>
</inSequence>
<outSequence>
<switch source="get-property('STATE')">
<case regex="PERSON_INFO_REQUEST">
<log level="full">
<property name="sequence" value="outSequence - STATE 01 - response from PersonInfoService"/>
</log>
<xslt key="xslt">
<property name="amount" expression="get-property('ORG_AMOUNT')"/>
</xslt>
<log level="full">
<property name="sequence" value="outSequence - STATE 01 - request for CreditService"/>
</log>
<property name="STATE" value="CREDIT_REQUEST"/>
<send>
<endpoint key="CreditEpr"/>
</send>
</case>
<case regex="CREDIT_REQUEST">
<log level="full">
<property name="sequence" value="outSequence - STATE 02 - response from CreditService"/>
</log>
<send/>
</case>
</switch>
</outSequence>
</target>
<publishWSDL uri="file:resources/CreditProxy.wsdl"/>
</proxy>
What may be the cause of the exception if the XSLT transformation is working fine in other tool ?
The key in the proxy is correct. I might have pasted the wrong XML proxy,
Here is the proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreditProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="sequence" value="inSequence - request for CreditProxy"/>
</log>
<property xmlns:pep="http://com.ims.proxy"
name="ORG_ID"
expression="//pep:credit/pep:id"/>
<property xmlns:pep="http://com.ims.proxy"
name="ORG_AMOUNT"
expression="//pep:credit/pep:amount"/>
<enrich>
<source type="inline" clone="true">
<pep:get xmlns:pep="http://ep.service.ims.com">
<pep:id>?</pep:id>
</pep:get>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="ORG_ID"/>
<target xmlns:pep="http://ep.service.ims.com" xpath="//pep:get/pep:id"/>
</enrich>
<log level="full">
<property name="sequence" value="inSequence - request for PersonInfoService"/>
</log>
<property name="STATE" value="PERSON_INFO_REQUEST"/>
<send>
<endpoint key="PersonInfoEpr"/>
</send>
</inSequence>
<outSequence>
<switch source="get-property('STATE')">
<case regex="PERSON_INFO_REQUEST">
<log level="full">
<property name="sequence"
value="outSequence - STATE 01 - response from PersonInfoService"/>
</log>
<xslt key="xslt1">
<property name="amount" expression="get-property('ORG_AMOUNT')"/>
</xslt>
<log level="full">
<property name="sequence"
value="outSequence - STATE 01 - request for CreditService"/>
</log>
<property name="STATE" value="CREDIT_REQUEST"/>
<send>
<endpoint key="CreditEpr"/>
</send>
</case>
<case regex="CREDIT_REQUEST">
<log level="full">
<property name="sequence"
value="outSequence - STATE 02 - response from CreditService"/>
</log>
<send/>
</case>
</switch>
</outSequence>
</target>
<publishWSDL uri="file:resources/creditproxy/CreditProxy.wsdl"/>
<description/>
</proxy>
Local entry:
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="xslt1" src="file:resources/creditproxy/personToCredit.xslt"></localEntry>
There was a problem with the local entry. Finally, I was able to fix this issue by adding a local entry like this in the synapse config
<localEntry key="xslt99">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ax21="http://ep.service.ims.com/xsd"
xmlns:ns="http://ep.service.ims.com"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
version="1.0"
exclude-result-prefixes="ns fn">
<xsl:param name="amount"/>
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//ns:getResponse"/>
</xsl:template>
<xsl:template match="ns:getResponse">
<ep:credit xmlns:ep="http://ep.service.ims.com" xmlns:xsd="http://ep.service.ims.com/xsd">
<ep:info>
<xsd:amount>
<xsl:value-of select="$amount"/>
</xsd:amount>
<xsd:personInfo>
<xsd:address>
<xsl:value-of select="ns:return/ax21:address"/>
</xsd:address>
<xsd:id>
<xsl:value-of select="ns:return/ax21:id"/>
</xsd:id>
<xsd:name>
<xsl:value-of select="ns:return/ax21:name"/>
</xsd:name>
</xsd:personInfo>
</ep:info>
</ep:credit>
</xsl:template>
</xsl:stylesheet>
<description/>
</localEntry>
Initially I was trying to add the local entries like this
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="xslt1" src="file:resources/creditproxy/personToCredit.xslt"></localEntry>
But still I don't know how to specify a xslt file in local entry.?

Sending an simple E-mail using WSO2 ESB

I am trying to send an e-mail to a specific address using WSO2 ESB.
I configured my axis2.xml by applying following settings to mailto transport sender.
<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">myusername#gmail.com</parameter>
<parameter name="mail.smtp.password">mypassword</parameter>
<parameter name="mail.smtp.from">myusername#gmail.com</parameter>
</transportSender>
This is my fragment of the sequence which is responsible for sending mail.
<log level="custom">
<property name="Mail status" value="===============enter the mail============="/>
</log>
<property name="messageType" value="text/html" scope="axis2"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<property name="Subject" value="File Received" scope="transport"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<address uri="mailto:myreciveemail#gmail.com"/>
</endpoint>
</send>
<log level="custom">
<property name="flag" value="=====After======="/>
</log>
I am pretty much sure that other parts of my proxy service are working just fine.
But the problem is when I triggered the proxy service, it is going through all parts of the sequence without throwing an error but not sending the mail
This is my console output relevant to the fragment of sequence I stated earlier.
[2013-01-29 17:07:15,552] INFO - LogMediator Mail status = ===============enter
the mail=============
[2013-01-29 17:07:15,552] INFO - LogMediator To: , WSAction: urn:mediate, SOAPA
ction: urn:mediate, MessageID: urn:uuid:a12fd64c-f5c5-4b22-b092-e15af960a3d2, Di
rection: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envel
ope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<geo:getZipCode xmlns:geo="http://geo.wso2">
<geo:longitude>1</geo:longitude>
<geo:latitude>3</geo:latitude>
</geo:getZipCode>
</soapenv:Body></soapenv:Envelope>
[2013-01-29 17:07:15,567] INFO - LogMediator flag = =====After=======
Guys please any one knows what's the issue is????
Try to use
<parameter name="mail.smtp.user">myusername</parameter>
without #gmail.com
For those of you who are trying to send an email using the configuration stated in the question via wso2 esb, apart from all that you will need to include a axis2-transport-mail-1.0.0.jar under wso2esb-5.0.0\repository\axis2\client\lib. This jar contains the classes necessary for axis2 to send out an email. Hope this helps someone.

Categories

Resources