how to integrate wso2 DSS server and wso2 ESB - wso2

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

Related

WSO2 API MANAGER - How to get endpoint with mediator

How can i get the endpoint production or sandbox url in customsequence?
Or how can i use two payload factories in the same customsequence using the endpoint saved in the api manager publisher?
For example, i have a custom sequence that made a call in the same endpoint, returning different data:
<payloadFactory description="" media-type="xml">
<format>
<ser:users xmlns:ser="http://service.test.com">
<arg0 xmlns="">$1</arg0>
</ser:users>
</format>
<args>
<arg value="user" />
</args>
</payloadFactory>
<call blocking="true">
<endpoint>
<address format="soap11" uri="http://url_soap?wsdl"/>
</endpoint>
</call>
<property expression="//return/text()" name="token" scope="default" type="STRING" xmlns:x="http://ws.wso2.org/dataservice"/>
Thanks
printscreen urls

Webservice response as HTML instead of SOAP message

I am working on a wso2 scenario in which I send a SOAP message to a webservice and then receive and manipulate the answer. For this purpose I have TWO Webservices. One is placed in a test environment (1) and the another is the live one (2).
I have no access to the webservice code, I'm just a user.
The problem is:
Via SOAPUI
I'm able to use the service from Webservices (1) and (2). No error, everything works fine.
Via WSO2
I'm able to use the service from webservice (1) but when I point to the webservice (2) I get a HTML 403 Forbidden response instead of a SOAP/XML message.
Am I missing something or this could be a misconfiguration of the webservice?
Following my in/out requests:
Sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="pricing" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<smooks config-key="smooks-csv.xml">
<input type="text"/>
<output type="xml"/>
</smooks>
<iterate expression="//product" id="iterateXML" sequential="true"
xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd">
<target>
<sequence>
<payloadFactory media-type="xml">
<format>
<xyz xmlns="http://tempuri.org/">
<safeKey>$6</safeKey>
<storeId>$5</storeId>
<articleId>$1</articleId>
<barcode/>
<sku>$2</sku>
<price>$3</price>
<discount>$4</discount>
</xyz>
</format>
<args>
<arg evaluator="xml" expression="//articleId"/>
<arg evaluator="xml" expression="//sku"/>
<arg evaluator="xml" expression="//price"/>
<arg evaluator="xml" expression="//discount"/>
<arg evaluator="xml" expression="//storeId"/>
<arg evaluator="xml" expression="//key"/>
</args>
</payloadFactory>
<in>
<header name="Action" scope="default" value="http://tempuri.org/xyz"/>
<send>
<endpoint>
<recipientlist>
<endpoint key="PS_PRICING"/>
<endpoint key="fileSave"/>
</recipientlist>
</endpoint>
</send>
<drop/>
</in>
<out>
<send/>
</out>
<log level="full" separator=";">
<property expression="*" name="ResponsePriceUpdate"/>
</log>
</sequence>
</target>
</iterate>
</sequence>
UPDATE:
After testing using TCPMon and TCPTrace I got the following:
Via SOAPUi
If I send the message SOAPUi -> Live Webservice - Works fine! (Picture a)
If I send the message SOAPUi -> TCPMon/TCPTrace -> Live Webservice - 403 Forbidden! (Picture b)
It doesn't make sense at all to me. I'm running out of ideas.
(a)
(b)
For the people who has found this question relevant:
The problem was in the server-side. Server was rejecting some "unknown" sources of incoming traffic.
Maybe add ?wsdl as postfix to the url: http://sample.com/webservice.asmx?wsdl

WSO2 ESB timeout Endpoint error handling

I have a simple proxy in WSO2 ESB, and sometimes backend service
process request for a long time and I catch a timeout on the ESB. I dont want to increase timeout, I just want to handle this error in sequence and send error message back.
But when endpoint is timed out I cant send payloaded message back
ESB log:
ERROR - ClientUtils The system cannot infer the transport information from the /services/restEventReaderSoap URL.
ERROR - Axis2Sender Unexpected error during sending message out org.apache.axis2.AxisFault: The system cannot infer the transport information from the /services/restEventReaderSoap URL.
at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:115)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)`
Proxy config:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="restEventReaderSoap"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://myserver/RestInformation" format="soap11">
<timeout>
<duration>1000</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
<payloadFactory media-type="xml">
<format>
<Send>
<id>$1</id>
</Send>
</format>
<args>
<arg value="Error"/>
</args>
</payloadFactory>
<send/>
</faultSequence>
</target>
</proxy>
Where is my error and what I have to do?
try adding the following in you fault handler :
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
Check that your service url is correctly pointing towards your wso2 server.

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 ESB If Then Else, authenticate or Error

This may be a basic question, I am just getting used to the WSO2 lingo. I have two services that I can deploy independently with WSDLs and pass the proper SOAP request, and return information accordingly. Now I want to combine them into an 'If then, else' statement sort of deal. This would be set up in a sequence of some sort I believe, just not sure how with the filters.
Send in request with authentication request and info request
Do authentication request – continue if passes, 401 on failure
Do info request – get info
Return the info
If you have a sample I could follow or point me to one of the hundreds WSO2 has, I just haven't been able to pull much from them. XML source example for the config could work also. Thanks for the help, and for my ignorance of WSO2 lingo, and workflow.
You can have a look at filter mediator to filter messages based on conditions Entitlement Mediator. You can find samples here as a reference which will be helpful for your use case.
So I ended up with something very similar to this. If someone down the road comes across this and looking for the wso2 configurations.
<proxy name="name"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property xmlns:ns1="ns1"
xmlns:ns="ns"
name="userID"
expression="//ns:AuthenticateRequest/ns:Credentials/ns1:userID"
scope="default"
type="STRING"/>
<property xmlns:ns1="ns1"
xmlns:ns="ns1"
name="password"
expression="//ns:AuthenticateRequest/ns:Credentials/ns1:password"
scope="default"
type="STRING"/>
<log>
<property name="userID" expression="get-property('userID')"/>
<property name="password" expression="get-property('password')"/>
</log>
<header name="Action"
value="http://services.com:port/AuthenticateSecureCredential"/>
<send receive="AuthRecvSequence">
<endpoint>
<address uri="http://server.com:port/DefaultAuthenticationService"/>
</endpoint>
</send>
</inSequence>
</target>
</proxy>
<sequence name="AuthRecvSequence">
<filter xmlns:ns="ns"
source="//ns:AuthenticateSecureCredentialResponse/ns:isAuthenticated"
regex="false">
<then>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/"
value="soap11Env:VersionMismatch"/>
<reason value="Not Authenticated"/>
<role/>
</makefault>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<send/>
<drop/>
</then>
<else>
<payloadFactory>
<format>
<ns:INFO xmlns:ns="ns"
xmlns:ns1="ns1">
<ns:secureCredentials>
<ns1:userID>$1</ns1:userID>
<ns1:password>$2</ns1:password>
</ns:secureCredentials>
</ns:INFORequest>
</format>
<args>
<arg expression="get-property('userID')"/>
<arg expression="get-property('password')"/>
</args>
</payloadFactory>
<header name="Action"
value="http://services.com/GetINFO"/>
<send receive="INFOrRecvSeq">
<endpoint>
<address uri="http://server:port/INFOService"/>
</endpoint>
</send>
</else>
</filter>
</sequence>
<sequence name="INFORecvSeq">
<send/>
</sequence>
<sequence name="main">
<description>The main sequence for the message mediation</description>
</sequence>