当前位置: 首页 > 知识库问答 >
问题:

无效的mime类型与DataWeave

萧鹏云
2023-03-14

我正在尝试在Mule ESB(企业版)中创建一个流,该流从WMQ 7.5(xml有效负载)中的队列接收消息,使用DataWeave将其转换(出于我的目的,将其转换为与旧文件相同的新xml文件),然后将其放回另一个队列。我的流程如下:

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

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <wmq:connector (MQ configuration is here, it is not the problem) />
    <flow name="dataweaveFlow">
        <wmq:inbound-endpoint queue="I0" connector-ref="WMQ" doc:name="WMQ">
            <wmq:transaction action="ALWAYS_BEGIN"/>
        </wmq:inbound-endpoint>
        <set-variable variableName="MULE_REPLYTO_STOP" value="true" doc:name="Variable"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:input-payload doc:sample="empty_1.xml"/>
            <dw:set-payload><![CDATA[%dw 1.0
%input payload application/xml
%output application/xml
---
payload]]></dw:set-payload>
        </dw:transform-message>

        <wmq:outbound-endpoint queue="O0" connector-ref="WMQ" doc:name="WMQ">
            <wmq:transaction action="ALWAYS_JOIN"/>
        </wmq:outbound-endpoint>
    </flow>
</mule>

我的 DataWeave 配置如下所示: 输入:

<?xml version='1.0' encoding='windows-1252'?>
<empty/>

转型:

  %dw 1.0
%input payload application/xml
%output application/xml
---
payload

现在,当我运行此流程并将一条消息放在队列中时,Mule 无法处理该消息并不断抛出异常,说:“无效的 mime 类型应用程序/xml”,异常堆栈为 1。无效的 mime type application/xml (com.mulesoft.weave.mule.exception.InvalidMimeTypeException) com.mulesoft.weave.mule.WeaveMessageProcessor:165 (null) 2.Invalid mime type application/xml (com.mulesoft.weave.mule.exception.InvalidMimeTypeException).消息有效负载的类型为: 字符串 (org.mule.api.MessagingException) org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)

无论如何,我对Mule(当然还有DataWeave)还比较陌生,如果能得到帮助,我将不胜感激!如果需要更多的细节,请告诉我。

共有3个答案

万俟穆冉
2023-03-14

在Dataweave之前向XML添加一个Transformer对象,这将把您的消息转换为正确的格式。

西门胜涝
2023-03-14

经过Mule支持人员和我之间的长时间对话,这被发现是一个错误。截至我的票,目前正在由工程团队处理。当您的主流处理策略设置为同步而不是排队异步时,就会发生这种情况。

尝试通过点击您的主流程来测试这一点,并将处理策略设置为< code>queued asynchronous。

请注意,您将无法将 WMQ 事务性与排队异步处理策略一起使用,因此我对此错误感到沮丧。

方夜洛
2023-03-14

在报告错误后,发现WMQ,DataWeave和同步处理策略的组合抛出了这个奇怪的异常。补丁已经可用,它将在未来版本的 ESB 上修复,但现在您可以联系支持人员并询问有关 SE-3167 的信息。祝你好运!

 类似资料:
  • 以下是我的服务代码: 和我的客户代码: 如何在FaignClient中设置?

  • MIME(多用途Internet邮件扩展)类型告诉浏览器如何处理某些类型的文件。 当文件发送到您网站访问者的浏览器时,它也会发送该文件的MIME类型。 MIME类型告诉浏览器文件类型以及如何将文件提供给用户。 例如,如果将.js文件发送到浏览器,则还会发送application/JavaScript MIME类型以告知浏览器.js文件是JavaScript文件,浏览器会相应地处理该文件。 大多数M

  • 最初设计MIME(多用途Internet邮件扩展)媒体类型,以便电子邮件可以包括除纯文本之外的信息。 MIME媒体类型表示以下内容 - 消息的不同部分(如文本和附件)如何组合到消息中。 指定消息的每个部分的方式。 编码不同项目以进行传输的方式,以便即使设计为仅使用ASCII文本的软件也可以处理该消息。 现在MIME类型不只是用于电子邮件; 它们已经被Web服务器采用,作为告诉Web浏览器向他们发送

  • 我正在尝试使用共享意图共享一个文件。如果我将“text/平原”设置为mime类型,它会像文本而不是文本文件一样读取内容,那么共享菜单中给出的选项是Whatsapp、Line等。 有人知道如何配置共享意图,使共享选项仅是能够发送<代码>的程序吗。txt文件(Gmail、Dropbox等,但不是Whatsapp等)?谢谢

  • 这个问题很简单,但似乎在网上找不到。我正在尝试制作一个程序,根据文件类型将给我扩展名。

  • mimeType String - 要发送的缓冲区的mimeType data Buffer - 实际的Buffer内容