提问者:小点点

Anypoint Studio错误,尽管一切正常


我在Mule Soft中创建了endpoint,其中包含来自3个独立API(2个REST和1个SOAP)的数据,但尽管工作正常,它仍返回错误:

ERROR 2021-12-22 00:24:23,483 [[MuleRuntime].uber.04: [projekt_isi].Found_course_response.BLOCKING @3d5f454f] [processor: Found_course_response/processors/6; event: 1dd95df0-62b5-11ec-902a-d481d75d7926] org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher: Could not close XMLEventWriter

因为这个请求需要很长时间,我猜是这个错误导致的,但是我在互联网上发现的是,XML转换的问题应该已经解决了。你遇到过这样的问题吗?特别是因为我得到了正确的JSON响应,其中包含来自REST API的JSON响应以及来自SOAPAPI的转换XML响应。

以下是Flow的样子:

编辑:根据要求,这里是整个错误:

ERROR 2021-12-22 00:24:14,556 [[MuleRuntime].uber.05: [projekt_isi].Found_course_response.BLOCKING @3d5f454f] [processor: Found_course_response/processors/6; event: 1c280470-62b5-11ec-902a-d481d75d7926] org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher: Could not close XMLEventWriter
javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
    at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1589) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1618) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1444) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:247) ~[woodstox-core-6.2.6.jar:6.2.6]
    at org.codehaus.stax2.ri.Stax2EventWriterImpl.close(Stax2EventWriterImpl.java:183) ~[stax2-api-4.2.1.jar:4.2.1]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher$CustomXMLEventWriter.close(AttachmentResponseEnricher.java:288) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher.processXmlStream(AttachmentResponseEnricher.java:158) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher.enrich(AttachmentResponseEnricher.java:97) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.SoapResponseGenerator.generate(SoapResponseGenerator.java:57) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.client.AbstractSoapCxfClient.consume(AbstractSoapCxfClient.java:131) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.extension.ws.internal.connection.WscSoapClient.consume(WscSoapClient.java:56) ~[mule-wsc-connector-1.6.6-mule-plugin.jar:?]
    at org.mule.extension.ws.internal.ConsumeOperation.consume(ConsumeOperation.java:92) ~[mule-wsc-connector-1.6.6-mule-plugin.jar:?]
    at org.mule.extension.ws.internal.ConsumeOperation$consume$MethodComponentExecutor.execute(Unknown Source) ~[?:?]
    at org.mule.runtime.module.extension.internal.runtime.execution.GeneratedMethodComponentExecutor.execute(GeneratedMethodComponentExecutor.java:98) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.execution.CompletableMethodOperationExecutor.doExecute(CompletableMethodOperationExecutor.java:29) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.execution.AbstractCompletableMethodOperationExecutor.execute(AbstractCompletableMethodOperationExecutor.java:63) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeCommand(DefaultExecutionMediator.java:232) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeWithInterceptors(DefaultExecutionMediator.java:216) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$execute$1(DefaultExecutionMediator.java:135) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$new$0(DefaultExecutionMediator.java:72) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.withExecutionTemplate(DefaultExecutionMediator.java:316) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.execute(DefaultExecutionMediator.java:134) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.executeOperation(ComponentMessageProcessor.java:588) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.prepareAndExecuteOperation(ComponentMessageProcessor.java:811) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$onEventSynchronous$16(ComponentMessageProcessor.java:490) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.onEventSynchronous(ComponentMessageProcessor.java:497) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$null$6(ComponentMessageProcessor.java:405) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:482) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:496) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:477) [mule-core-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:472) [mule-core-4.4.0-20211026.jar:4.4.0-20211026]
    at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:127) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:351) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_282]
    at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:113) [mule-service-scheduler-1.4.0/:?]
    at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54) [mule-service-scheduler-1.4.0/:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_282]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_282]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
ERROR 2021-12-22 00:24:23,483 [[MuleRuntime].uber.04: [projekt_isi].Found_course_response.BLOCKING @3d5f454f] [processor: Found_course_response/processors/6; event: 1dd95df0-62b5-11ec-902a-d481d75d7926] org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher: Could not close XMLEventWriter
javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
    at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1589) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1618) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1444) ~[woodstox-core-6.2.6.jar:6.2.6]
    at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:247) ~[woodstox-core-6.2.6.jar:6.2.6]
    at org.codehaus.stax2.ri.Stax2EventWriterImpl.close(Stax2EventWriterImpl.java:183) ~[stax2-api-4.2.1.jar:4.2.1]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher$CustomXMLEventWriter.close(AttachmentResponseEnricher.java:288) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher.processXmlStream(AttachmentResponseEnricher.java:158) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.attachment.AttachmentResponseEnricher.enrich(AttachmentResponseEnricher.java:97) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.generator.SoapResponseGenerator.generate(SoapResponseGenerator.java:57) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.soap.internal.client.AbstractSoapCxfClient.consume(AbstractSoapCxfClient.java:131) ~[mule-soap-engine-1.6.4.jar:?]
    at org.mule.extension.ws.internal.connection.WscSoapClient.consume(WscSoapClient.java:56) ~[mule-wsc-connector-1.6.6-mule-plugin.jar:?]
    at org.mule.extension.ws.internal.ConsumeOperation.consume(ConsumeOperation.java:92) ~[mule-wsc-connector-1.6.6-mule-plugin.jar:?]
    at org.mule.extension.ws.internal.ConsumeOperation$consume$MethodComponentExecutor.execute(Unknown Source) ~[?:?]
    at org.mule.runtime.module.extension.internal.runtime.execution.GeneratedMethodComponentExecutor.execute(GeneratedMethodComponentExecutor.java:98) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.execution.CompletableMethodOperationExecutor.doExecute(CompletableMethodOperationExecutor.java:29) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.execution.AbstractCompletableMethodOperationExecutor.execute(AbstractCompletableMethodOperationExecutor.java:63) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeCommand(DefaultExecutionMediator.java:232) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeWithInterceptors(DefaultExecutionMediator.java:216) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$execute$1(DefaultExecutionMediator.java:135) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$new$0(DefaultExecutionMediator.java:72) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.withExecutionTemplate(DefaultExecutionMediator.java:316) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.execute(DefaultExecutionMediator.java:134) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.executeOperation(ComponentMessageProcessor.java:588) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.prepareAndExecuteOperation(ComponentMessageProcessor.java:811) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$onEventSynchronous$16(ComponentMessageProcessor.java:490) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.onEventSynchronous(ComponentMessageProcessor.java:497) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$null$6(ComponentMessageProcessor.java:405) ~[mule-module-extensions-support-4.4.0-20211026.jar:4.4.0-20211026]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:482) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:496) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:477) [mule-core-4.4.0-20211026.jar:4.4.0-20211026]
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:472) [mule-core-4.4.0-20211026.jar:4.4.0-20211026]
    at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:127) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:351) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27) [reactor-core-3.2.22.RELEASE.jar:3.2.22.RELEASE]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_282]
    at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:113) [mule-service-scheduler-1.4.0/:?]
    at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54) [mule-service-scheduler-1.4.0/:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_282]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_282]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]

这是XML:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:wsc="http://www.mulesoft.org/schema/mule/wsc"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/wsc http://www.mulesoft.org/schema/mule/wsc/current/mule-wsc.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP_Listener_config" doc:id="70a95691-a977-48ff-8439-79a5d2fc7bb7" >
        <http:listener-connection host="0.0.0.0" port="88" />
    </http:listener-config>
    <wsc:config name="Web_Service_Consumer_Config" doc:name="Web Service Consumer Config" doc:id="0a403287-6d01-45e1-bb5f-47ffcc7a5f71" >
        <wsc:connection wsdlLocation="https://www.dataaccess.com/webservicesserver/NumberConversion.wso?wsdl" service="NumberConversion" port="NumberConversionSoap" address="https://www.dataaccess.com/webservicesserver/NumberConversion.wso">
            <wsc:web-service-security actor="http://schemas.xmlsoap.org/soap/actor/next" />
        </wsc:connection>
    </wsc:config>
    <http:request-config name="First_REST_API" doc:name="HTTP Request configuration" doc:id="84f17cc0-eb86-4c2a-b122-7d5f22781423" basePath="https://random-data-api.com/api/number/random_number?size=1" >
        <http:request-connection protocol="HTTPS" />
    </http:request-config>
    <http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="93a99571-d4d7-43c3-9505-26f2a56e97b3">
        <http:request-connection protocol="HTTPS" />
    </http:request-config>
    <http:request-config name="HTTP_Request_configuration1" doc:name="HTTP Request configuration" doc:id="282ae316-cee6-4305-ae58-283858258ec6">
        <http:request-connection protocol="HTTPS" host="random-data-api.com"/>
    </http:request-config>
    <http:request-config name="Local_REST_API_Config" doc:name="HTTP Request configuration" doc:id="6cf97fb4-f770-44fb-b450-4ccccf29db1a" >
        <http:request-connection host="localhost" port="1234" />
    </http:request-config>
    <http:listener-config name="HTTP_Listener_config1" doc:name="HTTP Listener config" doc:id="0a9a912a-50df-4963-b17a-f61f53aaa656" >
        <http:listener-connection host="0.0.0.0" port="82" readTimeout="3000"/>
    </http:listener-config>
    <flow name="get_Price_text" doc:id="b4f797c1-ef45-4af5-942f-7c020f3faa31" >
        <http:listener doc:name="Listener" doc:id="0143fc37-b5c0-45f9-9338-e901cdbfc43c" config-ref="HTTP_Listener_config" path="/api/courses/find/"/>
        <http:request method="GET" doc:name="Call REST API" doc:id="a8fd827c-8648-4d4e-8db4-7107ae1b0be4" path="/api/number/random_number?size=1" config-ref="HTTP_Request_configuration1"/>
        <set-variable value="#[output application/java
&#10;---
&#10;payload.decimal]" doc:name="Set Variable" doc:id="686acb85-627d-43fa-953f-713244b070fb" variableName="price_number"/>
        <ee:transform doc:name="Transform Message" doc:id="3b35fcc5-3dc0-4889-93a3-c65dc38bc6bf">
            <ee:message>
                <ee:set-payload><![CDATA[output application/xml
---
{
            NumberToDollars @(xmlns: "http://www.dataaccess.com/webservicesserver/"): {
                dNum: payload.decimal
}
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <wsc:consume operation="NumberToDollars" doc:name="Consume" doc:id="6e83b178-f444-46fc-bdff-f96000235ff9" config-ref="Web_Service_Consumer_Config"/>
        <set-variable value="#[output application/java
&#10;ns ns0 http://www.dataaccess.com/webservicesserver/
&#10;---
&#10;payload.body.ns0#NumberToDollarsResponse.ns0#NumberToDollarsResult]" doc:name="Set Variable" doc:id="1e6d7716-93a5-4036-828e-6b1655127c85" variableName="price_string"/>
        <ee:transform doc:name="Transform Message" doc:id="7bc88477-1057-4123-bc9e-fb1bcca7b174" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
    price_numeric: vars.price_number[0],
    price_string: vars.price_string
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <set-variable value="#[output application/json
&#10;---
&#10;{
&#10;   price_numeric: vars.price_number[0],
&#10;   price_string: vars.price_string
&#10;}]" doc:name="Set Variable" doc:id="330aac85-6da7-4775-b366-6e3fd79436f2" variableName="price_JSON"/>
    </flow>
    <flow name="projekt_isiFlow" doc:id="7fed68f6-ae9d-4a04-ad71-673b1f3f47fb" >
        <http:listener doc:name="Copy_of_Listener" doc:id="5422cb86-c49b-4fc5-b2fa-48f44abb574d" config-ref="HTTP_Listener_config" path="/api/courses/find/{id}" />
        <set-payload value="#[attributes.uriParams.id]" doc:name="Set Payload" doc:id="5a12884f-b2d3-4979-b9ae-66935b200677" />
        <http:request method="GET" doc:name="Copy_of_Call Custom REST API " doc:id="fc88359a-c925-4a9d-b0ab-508be1fd619e" config-ref="Local_REST_API_Config" path="/api/courses/find/{id}" outputMimeType="application/json">
            <http:body><![CDATA[{}]]></http:body>
            <http:uri-params ><![CDATA[#[output application/java
---
{
 id: payload
}]]]></http:uri-params>
        </http:request>
        <set-variable value='#[output application/json
&#10;---
&#10;{
&#10;   isPublished: payload.isPublished,
&#10;   tags: payload.tags map ( tag , indexOfTag ) -&gt; tag,
&#10;   "_id": payload."_id",
&#10;   dishName: payload.dishName,
&#10;   category: payload.category,
&#10;   author: payload.author,
&#10;   ingredients: payload.ingredients map ( ingredient , indexOfIngredient ) -&gt; {
&#10;       "_id": ingredient."_id",
&#10;       quantity: ingredient.quantity,
&#10;       unit: ingredient.unit,
&#10;       description: ingredient.description
&#10;   },
&#10;   cookingTime: payload.cookingTime,
&#10;   sourceUrl: payload.sourceUrl,
&#10;   imageUrl: payload.imageUrl,
&#10;   price: payload.price,
&#10;   date: payload.date,
&#10;   "__v": payload."__v"
&#10;}]' doc:name="Set Variable" doc:id="7a7fa41c-5e5e-438c-b4f3-fb142c8d83a9" variableName="results" mimeType="application/json"/>
    </flow>
    <flow name="Found_course_response" doc:id="e4042d03-603f-41c5-91a1-e12c2992d75e" >
        <http:listener doc:name="Listener with URI ID" doc:id="b1ecf442-8975-4385-b11b-cac1677613ef" config-ref="HTTP_Listener_config1" path="/api/courses/find/{id}" />
        <set-payload value="#[attributes.uriParams.id]" doc:name="Set payload with URI ID" doc:id="8499152a-c601-488c-8cbd-2a081e38b20f" />
        <http:request method="GET" doc:name="REST API request for Course with ID" doc:id="d17382dd-e848-44fc-b4e4-495991b61325" config-ref="Local_REST_API_Config" path="/api/courses/find/{id}" outputMimeType="application/json">
            <http:body><![CDATA[{}]]></http:body>
            <http:uri-params><![CDATA[#[output application/java
---
{
 id: payload
}]]]></http:uri-params>
        </http:request>
        <set-variable value='#[output application/json
&#10;---
&#10;{
&#10;   isPublished: payload.isPublished,
&#10;   tags: payload.tags map ( tag , indexOfTag ) -&gt; tag,
&#10;   "_id": payload."_id",
&#10;   dishName: payload.dishName,
&#10;   category: payload.category,
&#10;   author: payload.author,
&#10;   ingredients: payload.ingredients map ( ingredient , indexOfIngredient ) -&gt; {
&#10;       "_id": ingredient."_id",
&#10;       quantity: ingredient.quantity,
&#10;       unit: ingredient.unit,
&#10;       description: ingredient.description
&#10;   },
&#10;   cookingTime: payload.cookingTime,
&#10;   sourceUrl: payload.sourceUrl,
&#10;   imageUrl: payload.imageUrl,
&#10;   price: payload.price,
&#10;   date: payload.date,
&#10;   "__v": payload."__v"
&#10;}]' doc:name="Set variable with response JSON" doc:id="f712c7d0-65a8-48ab-a7a4-088ba23c9956" variableName="results" mimeType="application/json" />
        <http:request method="GET" doc:name="Call REST API for random number" doc:id="90a7f6f5-aeba-4b28-a5af-43dcd4b87e16" config-ref="HTTP_Request_configuration1" path="/api/number/random_number?size=1" />
        <set-variable value="#[output application/java
&#10;---
&#10;payload.decimal]" doc:name="Set Variable with REST API response " doc:id="5e409a00-0968-4cc7-a24e-da4efb9b2e03" variableName="price_number"/>
        <ee:transform doc:name="Transform response to XML" doc:id="3a0f5690-a8ca-4e4d-9a8a-71645cf0940f" >
            <ee:message >
                <ee:set-payload ><![CDATA[output application/xml
---
{
            NumberToDollars @(xmlns: "http://www.dataaccess.com/webservicesserver/"): {
                dNum: payload.decimal
}
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <wsc:consume operation="NumberToDollars" doc:name="Call SOAP API with payload for string version of number" doc:id="0a8622d2-98ab-4114-8902-57bcdc2f58ba" config-ref="Web_Service_Consumer_Config" />
        <set-variable value="#[output application/java
&#10;ns ns0 http://www.dataaccess.com/webservicesserver/
&#10;---
&#10;payload.body.ns0#NumberToDollarsResponse.ns0#NumberToDollarsResult]" doc:name="Set Variable with SOAP API response" doc:id="25495ffe-b5ef-49de-a9c0-d4db668a58a6" variableName="price_string"/>
        <ee:transform doc:name="Transform all responses into one JSON" doc:id="10c1c874-782b-4c4c-84d4-bb14bf3e50a7" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
    isPublished: vars.results.isPublished,
    tags: vars.results.tags map ( tag , indexOfTag ) -> tag,
    "_id": vars.results."_id",
    dishName: vars.results.dishName,
    category: vars.results.category,
    author: vars.results.author,
    ingredients: vars.results.ingredients map ( ingredient , indexOfIngredient ) -> {
        "_id": ingredient."_id",
        quantity: ingredient.quantity,
        unit: ingredient.unit,
        description: ingredient.description
    },
    cookingTime: vars.results.cookingTime,
    sourceUrl: vars.results.sourceUrl,
    imageUrl: vars.results.imageUrl,
    price: vars.price_number[0],
    priceText: vars.price_string,   
    date: vars.results.date,
    "__v": vars.results."__v"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
    </flow>
</mule>


共1个答案

匿名用户

尝试将Web服务消费者从当前版本1.6.6升级到最新版本1.6.7。它应该解决该错误消息的打印问题。