I'm using the WSO2 ESB and DSS, I have setup a DSS service and have tested this and it works using the following URL
http://10.248.40.85:9764/services/params/op/{Value goes here}
My problem is when calling this from the ESB it doesn't work and throws the incompatible parameters error. The way it is being called is as follows
<log level="custom">
<property name="uri.var.ID" expression="$body/int:User/int:UserID/text()"/>
</log>
<send>
<endpoint>
<http method="get" uri-template="http://10.248.40.85:9764/services/params/op/{uri.var.ID}"/>
</endpoint>
</send>
When logging the uri.var.ID it returns the expected number but when the service tries to call the endpoint it throws the error and says that the current parameters are empty.
The DSS service resource is
<resource method="GET" path="op/{ID}">
<call-query href="query2">
<with-param name="ID" query-param="ID"/>
</call-query>
</resource>
This issue can be occur due to some various reasons. so checklist as below.
Payload from ESB to Dss (Client -> ESB-> DSS) is not in
expected strcuture.
calling wrong port.
you are not calling the correct DSS Service from the ESB.
Solved the problem by using the following
<payloadFactory media-type="xml">
<format>
<p:operation2 xmlns:p="http://ws.wso2.org/dataservice">
<xs:ID xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:ID>
</p:operation2>
</format>
<args>
<arg xmlns:xs="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('uri.var.ID')"/>
</args>
</payloadFactory>
<call>
<endpoint>
<address uri="http://10.248.40.85:9764/services/params/operation2"/>
</endpoint>
</call>
Latest Version of DSS Supports default parameter values in the query param list.
Could you please give a try by adding defaultValue="#{NULL}" in query param list in your data service (dbs) file?
<query id="QUERY-ID" useConfig="DATA-SOURCE-ID">
<sql>-------------SQL QUERY HERE -----</sql>
<result ----------- >
<element ------------ />
</result>
<param defaultValue="#{NULL}" name="PARAM-NAME" ordinal="1" sqlType="INTEGER"/>
</query>
The issue should be you have defined the property uri.var.ID inside the log mediator. Define it outside and check.
Related
I want to implement sequential back-end calls in WSO2 Integration Studio.
After the first back-end call, I want to send a few fields from the response from the first back-end call to the second back-end call.
I tried using payload factory mediator inside a for-each loop after the http back-end call, but it is giving only last object.
Any other way to get it done?
You do not need a foreach loop here. You can implement a Service Chain pattern. You can create a Payload using the PayloadFactory mediator to use in second call which uses the values from the first call's response. Have a look at the following sample.
<api xmlns="http://ws.apache.org/ns/synapse" name="ServiceChaining" context="/servicechain">
<resource methods="GET">
<inSequence>
<call>
<endpoint>
<http uri-template="http://www.mocky.io/v2/5eb1cf1d320000749428f99e"/>
</endpoint>
</call>
<payloadFactory media-type="json">
<format>{"Hello" : {"test1" : "$1", "test3": "$2"}}</format>
<args>
<arg evaluator="json" expression="$.key1"/>
<arg evaluator="json" expression="$.key3"/>
</args>
</payloadFactory>
<call>
<endpoint>
<http method="POST" uri-template="http://www.mocky.io/v2/5185415ba171ea3a00704eed"/>
</endpoint>
</call>
<respond/>
</inSequence>
</resource>
</api>
I have built an API to send a message to multiple REST APIs. To test it out I have mocked three REST APIs using SOAP Ui.
However I could not send the JSON message out using endpoint in the CLONE mediator.
This is a portion of the REST API Configuration:
<clone id="GetOpenTasksReq">
<target>
<sequence>
<log level="full"/>
</sequence>
<endpoint key="OpenTask1EP"/>
</target>
<target>
<sequence>
<log level="full"/>
</sequence>
<endpoint key="OpenTask2EP"/>
</target>
</clone>
This is one of the endpoints'(OpenTask1EP) configuration:
<endpoint name="OpenTask1EP" xmlns="http://ws.apache.org/ns/synapse">
<http method="GET" trace="enable" uri-template="http://localhost:6060/admin-service/api/getuserlists">
<timeout>
<duration>5000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
I have enabled enable wire logs in ESB. From the WSO2 ESB console, all I can see is the message coming to ESB from wire, the one I fired to the ESB using JMeter. On the SOAP Ui mock service I can't see the any sign of incoming request, the Message Log is empty.
Kindly advise. Please do let me know if you need more information. Thanks in advance.
Could you please try this?
<clone continueParent="true" sequential="true">
<target endpoint="EP1">
<sequence>
<log level="full"/>
</sequence>
</target>
<target endpoint="EP2">
<sequence>
<log level="full"/>
</sequence>
</target>
</clone>
You can give your endpoint names instead of EP1 and EP2
In our project we are using WSO2 API Manager v 2.1.0. Our goal is to write a fault sequence that will log some information in custom logfile, example timestamp, name of the API etc. I was able to create a file and write to it, but it does not work as expected. Things I need to have is
Control the file name
Append content to file instead of overwriting it each time
This is the sequence I am using (simplified easier reading):
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="admin--FaultyAPI2:v1.0.0--Fault">
<clone continueParent="true">
<target>
<sequence>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://org.apache.synapse/xsd" name="destination" expression="get-property('To')"/>
<format>
{
"destination_host" : "$1"
}
</format>
<args>
<arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('destination')"/>
</args>
</payloadFactory>
<property name="transport.vfs.ReplyFileName" value="test.txt" scope="transport" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint>
<http uri-template="vfs:file:///home/install/out?transport.vfs.Append=true"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</sequence>
Following documentation I have used transport.vfs.ReplyFileName to specify the file name and ?transport.vfs.Append=true path parameter to tell it to append to file. The problem is that those two things are ignored.
First thing is that the file created is not test.txt but it is the endpoint URI that failed (the one I have setup in API Manager). So if I call /fault endpoint the file created is fault under location specified.
The second thing is that it is not appending to a file, but overwriting it each time the sequence is triggered. It is even worse! It creates actual path /home/install/out?transport.vfs.Append=true on file system and saves the file under this directory.
Those features seems to work under WSO ESB, but not API Manager. Any ideas anyone?
First of all, I have tested this in WSO2 EI, not in API Manager, but it seemed to me, the same problems you described appeared.
Controlling the filename
I've had some issues with this as well. The problem is that when you call the sequence through an API, the filename is not constructed based on the "transport.vfs.ReplyFileName" transport property, but based on the "REST_URL_POSTFIX" axis2 property. You can solve this by setting the "REST_URL_POSTFIX" property to the correct filename or by removing that property.
Appending the content
You are using an http endpoint, but you should use an address endpoint. In that case the path parameter will be recognized.
Example
I think your code should look more like this:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="admin--FaultyAPI2:v1.0.0--Fault" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<clone continueParent="true">
<target>
<sequence>
<payloadFactory media-type="json">
<format>
{
"destination_host" : "$1"
}
</format>
<args>
<arg evaluator="xml" expression="get-property('destination')" xmlns:ns3="http://org.apache.synapse/xsd" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"/>
</args>
</payloadFactory>
<property name="transport.vfs.ReplyFileName" scope="transport" type="STRING" value="test.txt"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="REST_URL_POSTFIX" action="remove" scope="axis2" />
<send>
<endpoint>
<address uri="vfs:file:///home/install/out?transport.vfs.Append=true"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</sequence>
I use WSO2 ESB and want to connect 2 web services together - on a timer pull data from one service and push it to another.
The problem is that one of the services authenticates callers with cookies. You first need to call a GetSession method with the username and password. The response to this call sets a cookie. Then with this cookie you make other calls.
I couldn't find anywhere in the documentation, how can I get a cookie from the result of one call and set it for a subsequent call. Is it at all achievable? If so - how?
Here is my sequence code:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="SampleName" trace="enable">
<payloadFactory media-type="xml">
<format>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<GetSessionWithCredentials xmlns="blabla">
<User>bla</User>
<Password>bla</Password>
</GetSessionWithCredentials>
</Body>
</Envelope>
</format>
</payloadFactory>
<call>
<endpoint key="conf:/Tracker"></endpoint>
</call>
<payloadFactory media-type="xml">
<format>
<GetTrackingList xmlns="blabla"></GetTrackingList>
</format>
</payloadFactory>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Cookie" expression="$trp:Cookie"></property>
<call>
<endpoint key="conf:/Tracker"></endpoint>
</call>
<log level="full"></log>
</sequence>
Thanks a lot
get Cookie header : <property name="Cookie" expression="$trp:Cookie"/>
If you want to get one cookie and it's value, use xpath expression with 'substring' for exemple
set cookie header with value JSESSIONID=1 : <property name="Cookie" value="JSESSIONID=1" scope="transport"/>
My current scenario is that i have a web service exposed from data service which returns me email address of the user when i give it the name of the user. Now i want to use this web service in ESB and get the email id from this web service in a property and show it in console using LOG mediator.
What should i do now and how?
Sorry for this silly question but i am newest member of wso2 esb. So please help me on this.
Now ihave a response like:
<brs:getRecipientKeyResponse xmlns:brs="http://brs.carbon.wso2.org">
<brs:MailRecipient xsi:type="ax2338:MailRecipient" xmlns:ax2338="http://email.samples/xsd" xmlns:ax2337="http://email.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2337:recipient>kevin</ax2337:recipient>
</brs:MailRecipient>
</brs:getRecipientKeyResponse>
Ihave to get the recipient element from this response and put this in payload. My complete sequence for this is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="receiveSeq">
<log>
<property name="getRecipient" value="------------Trying to get data Fom BRS Response----------------------------"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ax2337="http://email.samples/xsd" name="Recipient" expression="//ax2337:recipient"/>
</log>
<payloadFactory>
<format>
<p:GetEmailDetails xmlns:p="http://ws.wso2.org/dataservice">
<xs:name xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:name>
</p:GetEmailDetails>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" xmlns:ax2337="http://email.samples/xsd" expression="//ax2337:recipient"/>
</args>
</payloadFactory>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="getName" expression="get-property('Recipient')"/>
</log>
<send receive="DBSeq">
<endpoint key="emailServiceEP"/>
</send>
</sequence>
<!--this part is not able to get data --->
<property xmlns:ns="http://org.apache.synapse/xsd" name="getName" expression="get-property('Recipient')"/>
u just use the the your wso2dss tryit service in that request side code copy into the payloadfactory insted of " ? " keep the $1 ,$2 ..like this and pass the argument below as per ur above order order is play a vital role for this response i think it will help for u
<payloadFactory>
<format>
<p:insert_emp_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
<xs:ename xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:ename>
<xs:esal xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:esal>
</p:insert_emp_operation>
</format>
<args>
<arg expression="get-property('eno')"/>
<arg expression="get-property('ename')"/>
<arg expression="get-property('esal')"/>
</args>
</payloadFactory>
<send receive="Error_Seq">
<endpoint>
<address uri="http://localhost:9764/services/emp_DataService/" format="soap11"/>
</endpoint>
</send>
Since you have the Dataservice is implemented, give that as endpoint url to your proxy which can be created in wso2esb. When you send request to your proxy,in the outsequence, you will receive the response of your dataservice. Just do a log with "level=full" you will see the full response. Use the property mediator and do an xpath to pick the value which you needed.
Sample conf:
<proxy name="StockQuoteProxy">
<target>
<endpoint>
<address uri="DS endpoint"/>
</endpoint>
<outSequence>
<log level="full">
<property name="email" expression="xpath from the email attribute in the rseponse"/>
</log>
<send/>
</outSequence>
</target>
</proxy>
Here is esb sample guide on how to create proxies;
http://docs.wso2.org/wiki/display/ESB460/Proxy+Service+Samples