Question

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')"/>
Was it helpful?

Solution 2

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

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top