Dynamic Endpoint in WSO2

风格不统一 提交于 2019-12-13 07:11:04

问题


I have an issue, Firstly, I make a Service that will give the result a specific endpoint. After I get the specific endpoint, I want to call that Service. But I don't know how to do it. I try the template Endpoint, but still cannot be used in Mediator. I have seen the documentation in : http://wso2.org/project/esb/java/4.0.0/docs/templates.html , and it said that "using Endpoint Template is a generalized form of endpoint configuration used in ESB. Unlike sequence templates , endpoint templates are always parameterized using '$' prefixed values (ie:- NOT xpath expressions)"

Here is My code for the Template :

<template xmlns="http://ws.apache.org/ns/synapse" name="TemplateEndPoint">
   <endpoint name="$name">
      <address uri="$uri">
         <suspendOnFailure>
            <progressionFactor>1.0</progressionFactor>
         </suspendOnFailure>
         <markForSuspension>
            <retriesBeforeSuspension>0</retriesBeforeSuspension>
            <retryDelay>0</retryDelay>
         </markForSuspension>
      </address>
   </endpoint>
</template>

And here is the code for the proxy:

<send>
  <endpoint template="TemplateEndPoint">
    <parameter name="uri" value="http://localhost:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask" />
    <parameter name="name" value="Testing" />
  </endpoint>
</send>

when I hard-code it in the proxy, It accept the code, but when I look back in design / source view, it will be back to . How Can I solve this problem?


回答1:


I think you are looking for this. You can set the To parameter with header mediator

<header name="To" expression="fn:concat('mailto:', get-property('email'))"/>

You can have a look at this link as well




回答2:


When you make a first call to the service, which sends the endpoint details, use the xslt mediator/enrich mediator to pick that endpoint details..Then use the header mediator and set "To" value for that endpoint




回答3:


It seems that setting the To header only works if the service utilises the listener of the desired transport as well as the sender. So if you are trying to do a dynamic mailto endpoint on a service that only listens on http it tries to route the mailto through the http transport and it doesn't work.

As a work around to this I set the endpoint address to the address of the servers email account (this also provides an audit trail of emails sent) and set either the CC or the BCC property at the transport level. e.g:

<property name="mailAddress" expression="/xpath/to/email/address" scope="default"/>

then

<property name="CC" expression="get-property('mailAddress')" scope="transport" />

or

<property name="BCC" expression="get-property('mailAddress')" scope="transport" />

you could grab the email address directly in the CC property, but doing it this way allows you to perform validation on the address property.



来源:https://stackoverflow.com/questions/8815994/dynamic-endpoint-in-wso2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!