【问题标题】:how to integrate wso2 DSS server and wso2 ESB如何集成 wso2 DSS 服务器和 wso2 ESB
【发布时间】:2013-03-07 09:55:01
【问题描述】:

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

很抱歉这个愚蠢的问题,但我是 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')"/>

【问题讨论】:

    标签: wso2 wso2esb wso2dss


    【解决方案1】:

    你只需在请求端使用你的 wso2dss tryit 服务,将代码复制到“?”的 payloadfactory 中,保持 $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>
    

    【讨论】:

      【解决方案2】:

      既然您已经实现了 Dataservice,请将其作为端点 url 提供给您的代理,该代理可以在 wso2esb 中创建。当您向代理发送请求时,您将收到数据服务的响应。只需使用“level=full”做一个日志,您就会看到完整的响应。使用属性调解器并执行 xpath 来选择您需要的值。 示例配置:

       <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

      【讨论】:

      • 我还有一个问题。我在名为 Recipient 的属性中捕获了一个名称。现在我希望将其传递给 Payload 工厂。如何做到这一点?
      • 我的代码是:ws.apache.org/ns/synapse" name="receiveSeq"> org.apache.synapse/xsd " xmlns:ax2337="email.samples/xsd" name="收件人" 表达式="//ax2337:recipient"/>
      • get-property('Recipient')
      • 是这样的; $1 和 args 您需要按顺序增加参数,例如, $1,$2..
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      相关资源
      最近更新 更多