Mule ESB 代理 Web 服务

发布于 2024-12-24 18:48:07 字数 4874 浏览 0 评论 0原文

目前,我们正在尝试使用 Mule ESB 构建一个代理,该代理提供内部 Web 服务,然后使用内部服务的提供参数访问外部 Soap 服务。一旦我得到了,我将改变肥皂的含量和布局。然后第三步,结果必须由Mule计算。

但在进行步骤 2 和 3 之前,我们首先从代理开始。目前我正在查看 http://www.mulesoft.org/documentation/显示/MULE3USER/代理+Web+服务 但是提供的 WSProxyService 不起作用。该代码似乎适用于 Mule 2.2。我尝试重新创建它,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd">

    <spring:bean name="WSProxyService" class="org.mule.module.cxf.WSProxyService">
        <spring:property name="wsdlFile" value="resources/tisclientws.wsdl"/>
    </spring:bean>

  <flow name="HttpProxyService">
      <http:inbound-endpoint address="http://localhost:8090/tis/proxy" exchange-pattern="request-response"/>
      <component>
        <spring-object bean="WSProxyService" />
      </component>
      <http:outbound-endpoint address="ADDRESSHERE/tisclientws.asmx" exchange-pattern="request-response"/>
  </flow>
</mule>

但这给出了错误

Exception stack is:
1. Service not set, this service has not been initialized properly. (org.mule.api.lifecycle.InitialisationException)
  org.mule.module.cxf.WSProxyService:254 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/InitialisationException.html)

有人能帮助我吗?我尝试了各种方法但没有任何运气。

最后但并非最不重要的一点是,我还查看了 http:// www.mulesoft.org/documentation/display/MULE3USER/Consuming+Web+Services+with+CXF 但问题是有多个参数,并且没有来自提供的内部服务的内部 WSDL。


感谢您的回复,很有帮助。经过一番尝试和错误后,我得到了它......有点......

目前代理给了我一个本地 WSDL (按预期工作)。然而,经过仔细检查,WSDL 的 SOAP 1.2 部分保持不变,并且仍然指向原始位置。更糟糕的是,调用 SOAP 1.1 部分时会出现错误(而原始版本工作正常)。

所以我正朝着正确的方向前进。现在只是为了解决这些问题。

除此之外,也许有人可以指出我正确的方向。假设我想获取外部服务的输出,只计算所有时间,然后以 XML 形式将其返回给本地服务。这属于定制变压器类别吗?

我使用了以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
          http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.2/mule-cxf.xsd
          http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd">
    <flow name="test">
        <http:inbound-endpoint address="http://localhost:8090/tis/proxy" exchange-pattern="request-response"/>      
        <cxf:proxy-service
           wsdlLocation="services/tisclientws.wsdl" 
           service="tisclientws"
           namespace="NAMESPACEHERE"
           validationEnabled="true"
           enableMuleSoapHeaders="false"
        />
        <http:outbound-endpoint address="EXTERNALURL/tisclientws.asmx" exchange-pattern="request-response"/>
    </flow>
</mule>

从 SOAP 1.1 收到的错误:

 <faultstring>Schema validation error on message from client: tag name "icTables" is not allowed. Possible tag names are: &lt;iiBSNNummer>.</faultstring>

禁用验证后,错误更改为:

 <faultcode>soap:Server</faultcode>
         <faultstring>Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=EXTERNALADDRESS/tisclientws.asmx, connector=HttpConnector
{
  name=connector.http.mule.default
  lifecycle=start
  this=17b79a6
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=&lt;none>
}
,  name='endpoint.EXTERNALADDRESS.tisclientws.asmx', mep=REQUEST_RESPONSE, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: DepthXMLStreamReader</faultstring>

Currently we are trying to build a proxy with Mule ESB that provides an internal webservice and then goes to an external soap service with the provides parameters of the internal one. Once I got that, I'll alter the soap content and lay-out. Then the third step the results have to be calculated by Mule.

But before we reach step 2 and 3, lets first start with the proxy. Currently I am looking at http://www.mulesoft.org/documentation/display/MULE3USER/Proxying+Web+Services
However the WSProxyService provided does not work. The code seems to be for Mule 2.2. I tried recreating it which looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd">

    <spring:bean name="WSProxyService" class="org.mule.module.cxf.WSProxyService">
        <spring:property name="wsdlFile" value="resources/tisclientws.wsdl"/>
    </spring:bean>

  <flow name="HttpProxyService">
      <http:inbound-endpoint address="http://localhost:8090/tis/proxy" exchange-pattern="request-response"/>
      <component>
        <spring-object bean="WSProxyService" />
      </component>
      <http:outbound-endpoint address="ADDRESSHERE/tisclientws.asmx" exchange-pattern="request-response"/>
  </flow>
</mule>

This however gives the error

Exception stack is:
1. Service not set, this service has not been initialized properly. (org.mule.api.lifecycle.InitialisationException)
  org.mule.module.cxf.WSProxyService:254 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/InitialisationException.html)

Can anyone help me? I tried various things without any luck.

Last but not least, I also looked at http://www.mulesoft.org/documentation/display/MULE3USER/Consuming+Web+Services+with+CXF but the problem there is multiple parameters and no internal WSDL from the provided internal service.


Thanks for the reply, it helped a lot. After some trial and error, I got it... sort of...

Currently the proxy gives me a local WSDL (working as intended). However upon closer inspection the SOAP 1.2 section of WSDL remains unaltered and still points towards the original location. To make matters worse, the SOAP 1.1 section when invoked, gives an error (while the original version works fine).

So I am heading in the right direction. Now just to fix these problems.

Besides that, maybe somebody can point me in the right direction. Lets say I want to take the output from the external service and only calculate all the hours and throw that back to the local service in an XML-form. Does that fall under the custom transformer category?

I used the following code:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
          http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.2/mule-cxf.xsd
          http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd">
    <flow name="test">
        <http:inbound-endpoint address="http://localhost:8090/tis/proxy" exchange-pattern="request-response"/>      
        <cxf:proxy-service
           wsdlLocation="services/tisclientws.wsdl" 
           service="tisclientws"
           namespace="NAMESPACEHERE"
           validationEnabled="true"
           enableMuleSoapHeaders="false"
        />
        <http:outbound-endpoint address="EXTERNALURL/tisclientws.asmx" exchange-pattern="request-response"/>
    </flow>
</mule>

The error received from SOAP 1.1:

 <faultstring>Schema validation error on message from client: tag name "icTables" is not allowed. Possible tag names are: <iiBSNNummer>.</faultstring>

Upon disabling validation, the error changes to:

 <faultcode>soap:Server</faultcode>
         <faultstring>Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=EXTERNALADDRESS/tisclientws.asmx, connector=HttpConnector
{
  name=connector.http.mule.default
  lifecycle=start
  this=17b79a6
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
}
,  name='endpoint.EXTERNALADDRESS.tisclientws.asmx', mep=REQUEST_RESPONSE, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: DepthXMLStreamReader</faultstring>

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

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

发布评论

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

评论(2

内心激荡 2024-12-31 18:48:07

WSProxyService 是 Mule 2 的遗产,不能与流一起工作,只能与服务一起工作。相反,更喜欢使用:

The WSProxyService is a legacy from Mule 2 and will not work with flows, only services. Instead prefer using either:

征棹 2024-12-31 18:48:07

如果它是代理,那么您可以使用 Web 服务代理模式。

    <pattern:web-service-proxy
        xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
        wsdlLocation="${worker.wsdlLocation}"
        name="WorkerDummy-WSProxyRequestOrder"
        inboundAddress="${worker.inboundAddress}"
        outboundAddress="${worker.outboundAddress}">
    </pattern:web-service-proxy>

If it is a proxy then you may use a Web Service Proxy Pattern.

    <pattern:web-service-proxy
        xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
        wsdlLocation="${worker.wsdlLocation}"
        name="WorkerDummy-WSProxyRequestOrder"
        inboundAddress="${worker.inboundAddress}"
        outboundAddress="${worker.outboundAddress}">
    </pattern:web-service-proxy>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文