ESB 4.8.1 with Data Service Hosting feature cannot use boxcarring - wso2

I run the following code in a WSO2 ESB 4.8.1 server with Data service Hosting feature 4.2.4 installed. I did some research on web, the normal response of "begin_boxcar" request should return a session cookie, however it doesn't. I also tried to send the same request to a standalone DSS 3.2.2 server. I did return a session cookie. Anyone can help?
<header name="Action" value="urn:begin_boxcar"></header>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<dat:begin_boxcar></dat:begin_boxcar>
</soapenv:Body>
</soapenv:Envelope>
</format>
</payloadFactory>
<call>
<endpoint key="GS1OrderDS"></endpoint>
</call>
<log level="full">
<property name="==============Set-Cookie===============" expression="get-property('transport','Set-Cookie')"></property>
</log>

You can get the Cookie value from
<property name="setCookieHeader" expression="$trp:Set-Cookie"/>
For the subsequent calls the Cookie can be set by
<property name="Cookie" expression="get-property('setCookieHeader')"
scope="transport"/>
Hope this helps!

Related

SOAP messages are not sent using wso2 ESB REST API

I'm trying to expose SOAP backend as REST API using wso2 ESB. I'm using payload factory to send the soap body message, but it doesn't work.
This is my API resource in wso2 esb code :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/akademik" name="SampleAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/students?symbol={symbol}">
<inSequence>
<log level="custom">
<property expression="$url:symbol" name="symbol"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:sem="http://semogabisa.te.net/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sem:sayHi>
<arg0>$1</arg0>
</sem:sayHi>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$url:symbol"/>
</args>
</payloadFactory>
<header scope="default">
<m:complexHeader xmlns:m="http://org.synapse.example">
<m:property key="Content-Type" value="application/xml"/>
</m:complexHeader>
</header>
<send>
<endpoint>
<address format="soap11" uri="http://localhost:8084/HelloWorld"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
Soap messages are not sent to the backend web service, it says null.
I've test the backend service with SOAPUI with same soap envelope format and it's working
I think you make some mistake on the header mediator. "HelloWorld" back end service didn't need the SOAP header based on your SOAP UI request. so remove the header mediator.
Select Synapse if you want to manipulate SOAP headers. Select Transport if you want to manipulate HTTP headers.
And it's seems back end is SOAP11, SOAP11 type is "text/xml". Your may need set this property.
<property name="messageType" value="text/xml" scope="axis2"/>
When you send message out from ESB, you need set property "messageType", then ESB will formatter the message that match back end required.
You may probably need this property, if you found ESB append some context to your back end URI when send message to back end.
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
Good Tips:
Please open your "synapse.transport.http.wire" as DEBUG, this will output every message in and out from ESB. This log will including HTTP header and body. After you got the wire log, you can compare wire log with your SOAPUI request, then find out which part is wrong.
https://docs.wso2.com/display/ESB481/Setting+Up+Logging

WSO2 ESB - How to get and set cookies in WSDL calls in

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"/>

WSO2 Data Service Server error INCOMPATIBLE_PARAMETERS_ERROR

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.

wso2 esb service endpoint in request

I am getting service endpoint as input SOAP request to WSO2 esb, based
on that need to send payload data to that endpoint and response to
client. Please advise how to send payload to that endpoint. I tried
Header mediator but no luck. Following is the SOAP XML request coming
to ESB which has service endpoint reference, under property element.
<soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body> <resources> <resource>
<properties>
<property name="location" value="http://localhost:8280/services/echo.echoHttpSoap11Endpoint"/>
</properties> </resource> </resources> </soapenv:Body> </soapenv:Envelope>
First retrieve the address value using the expression "//properties/property/#value". Then set the To address of the header mediator and send the message.
<property name="address" expression="//properties/property/#value"/>
<header name="To" expression="get-property('address')"/>
<payloadFactory>
<format>
<p:echoInt xmlns:p="http://echo.services.core.carbon.wso2.org">
<in xmlns="">$1</in>
</p:echoInt>
</format>
<args>
<arg value="1"/>
</args>
</payloadFactory>
<send/>

how to integrate wso2 DSS server and wso2 ESB

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