WSO2 中的动态端点

发布于 2024-12-26 00:58:24 字数 1297 浏览 1 评论 0原文

我有一个问题,首先,我创建一个服务,该服务将为结果提供特定的端点。获得特定端点后,我想调用该服务。但我不知道该怎么做。我尝试了模板Endpoint,但仍然无法在Mediator中使用。我已经看到文档: http://wso2.org/ project/esb/java/4.0.0/docs/templates.html ,它说“使用端点模板是 ESB 中使用的端点配置的通用形式。与序列模板不同,端点模板始终使用参数化'$' 前缀值(即:- NOT xpath 表达式)”

这是我的模板代码:

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

这是代理的代码:

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

当我在代理中对其进行硬编码时,它接受代码,但是当我查看时返回设计/源视图,它将返回到 .我该如何解决这个问题?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

洛阳烟雨空心柳 2025-01-02 00:58:24

我想你正在寻找这个。 设置 To 参数

您可以使用标头中介器

您可以查看此链接 还有

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

梦里的微风 2025-01-02 00:58:24

当您第一次调用发送端点详细信息的服务时,请使用 xslt 中介/丰富中介来选择该端点详细信息。然后使用标头中介并为该端点设置“To”值

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

梦萦几度 2025-01-02 00:58:24

似乎只有当服务使用所需传输的侦听器以及发送方时,设置 To 标头才有效。因此,如果您尝试在仅侦听 http 的服务上执行动态 mailto 端点,它会尝试通过 http 传输路由 mailto,但它不起作用。

作为解决此问题的方法,我将端点地址设置为服务器电子邮件帐户的地址(这还提供了发送的电子邮件的审核跟踪),并在传输级别设置 CC 或 BCC 属性。例如:

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

那么

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

或者

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

您可以直接在抄送属性中获取电子邮件地址,但这样做可以让您对地址属性执行验证。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文