如何集成wso2 DSS服务器和wso2 ESB

时间:2013-03-07 09:55:01

标签: wso2 wso2esb wso2dss

我目前的情况是我有一个从数据服务公开的Web服务,当我给它用户名时,它返回用户的电子邮件地址。现在我想在ESB中使用此Web服务,并在属性中从此Web服务获取电子邮件ID,并使用LOG mediator在控制台中显示它。 我现在应该怎么做以及如何做?

抱歉这个愚蠢的问题,但我是wso2 esb的最新成员。所以请帮助我。

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

2 个答案:

答案 0 :(得分:1)

你只需使用你的wso2dss tryit服务在那个请求端代码中复制到payloadfactory insted中的“?”保持$ 1,$ 2 ..这样并按下面的顺序传递下面的参数命令顺序播放至关重要这个回应的作用我认为这对你有帮助

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

答案 1 :(得分:0)

由于您已实现Dataservice,因此将其作为端点URL提供给您的代理,该代理可以在wso2esb中创建。当您向代理发送请求时,在结果中,您将收到数据服务的响应。只需使用“level = full”进行日志,您将看到完整的响应。使用属性介体并执行xpath以选择所需的值。 样本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>

这是关于如何创建代理的esb示例指南;

http://docs.wso2.org/wiki/display/ESB460/Proxy+Service+Samples