我正在努力改造我的有效载荷.我有这种情况.
输入有效负载如下所示: -
{
"address": {
"city": "bab",
"company_name": "asdast",
"country_code": "sam",
"location": {
"city": null,
"state": null
}
}}
Run Code Online (Sandbox Code Playgroud)
我使用%output application/json skipNullOn = "everywhere"
它返回我下面的JSON
{
"address": {
"city": "bab",
"company_name": "asdast",
"country_code": "sam",
"location": { }
}}
Run Code Online (Sandbox Code Playgroud)
但是如果位置对象中的所有字段都是空的,我不希望有空的位置对象.我期待这样的事情
{
"address": {
"city": "bab",
"company_name": "asdast",
"country_code": "sam"
}}
Run Code Online (Sandbox Code Playgroud) 我在Mule中有一个默认的catch异常,我正在尝试使用Mule表达式访问异常消息:#[exception]
这似乎不起作用,我猜我正在尝试访问错误的变量?我正在尝试使用logger记录它,并运行一个接收异常消息的自定义组件(作为字符串.)
谢谢,
我试图使用Mule中的DataMapper变换将第三方调用的响应映射到不同的结构.
从第三方开始,我们收到一系列项目(以及其他内容),我想将数组中的单个项目映射到对象(JSON).我收到请求中项目的标识符,该标识符可用作输入参数.
我的问题是,如何根据标识符映射项目的字段?
示例XML响应
<account>
<accountNumber>1234567</accountNumber>
<books>
<book>
<id>1</id>
<title>Sample title1</title>
<availableFrom>21-03-16</availableFrom>
</book>
<book>
<id>2</id>
<title>Sample title2</title>
<availableFrom>21-03-16</availableFrom>
</book>
<book>
<id>3</id>
<title>Sample title3</title>
<availableFrom>21-03-16</availableFrom>
</book>
</books>
</account>
Run Code Online (Sandbox Code Playgroud)
需要成为:
{
"person": {
"accountNumber": 1234567,
"selectedBook": {
"id": 1,
"title": "Sample title1"
},
"otherBooks": [
{
"id": 2,
"title": "Sample title2"
},
{
"id": 3,
"title": "Sample title3"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
所选书籍的ID保存在inputArgument.bookId
.
我可以使用xpath规则为每个字段完成映射,但是,我必须在xpath中对bookId进行硬编码.相反,我需要能够将实际的id替换为所提供的id(并且在inputArgument中可用).
标题的xpath
/account/books/book[child::id=1]/title
Run Code Online (Sandbox Code Playgroud)
我已经尝试添加MEL来替换id和各种其他修复,但似乎没有任何工作.有没有办法替换bookId字段.
注意:由于客户端的限制,我无法使用DataWeave.
我有一个变量 my_variable,其值为动态 URL,例如——
http://stackoverflow.com/questions/ask
Run Code Online (Sandbox Code Playgroud)
我想在这个动态 URL 上做一个子字符串来找到最后一个“/”之后的字符串,即在上面提到的 URL 的情况下,我想得到子字符串“ask”
我如何使用 MEL 来做到这一点?
我正在向mule发送一些参数,它正在通过我发送的8081中的http入站进行监听.
http://localhost:8081/hey?age=manoj
Run Code Online (Sandbox Code Playgroud)
但我不知道我怎么能从消息中得到这个?我知道我可以从消息和有效负载访问它,但是当我尝试这样做时
#[message payload: ['age']]
Run Code Online (Sandbox Code Playgroud)
我收到错误,有效载荷是一个字符串类型,我非常混淆骡子.我想要年龄价值.
这是我的xml,首先我需要检查'RecordsEntries'不应该是'null',然后RecordEntry不应该null
跟随映射代码
<?xml version="1.0" encoding="UTF-8"?>
<Records>
<storenumber />
<calculated>false</calculated>
<subTotal>12</subTotal>
<RecordsEntries>
<RecordEntry>
<deliverycharge>30.0</deliverycharge>
<entryNumber>8</entryNumber>
<Value>true</Value>
</RecordEntry>
<RecordEntry>
<deliverycharge>20.0</deliverycharge>
<entryNumber>7</entryNumber>
<Value>false</Value>
</RecordEntry>
</RecordsEntries>
<RecordsEntries>
<RecordEntry>
<deliverycharge>30.0</deliverycharge>
<entryNumber>8</entryNumber>
<Value>false</Value>
</RecordEntry>
</RecordsEntries>
</Records>
Run Code Online (Sandbox Code Playgroud)
尝试多个场景也使用when
条件检查,但某处缺少括号或正确的格式
orders: {
order: {
StoreID: payload.Records.storenumber,
Total: payload.Records.calculated,
(( payload.Records.RecordsEntries.*RecordEntry ) map {
IndividualEntry: {
Number:$.entryNumber,
DeliverCharge:$.deliverycharge
}
} when ( payload.Records.RecordsEntries != null and payload.Records.RecordsEntries.*RecordEntry !=null))}
}
Run Code Online (Sandbox Code Playgroud)
像失踪一样得到错误)
.通过在第一个循环内直接检查null条件来尝试其他方式得到了错误,例如"无法将数组强制转换为布尔值".请建议.谢谢.
我使用context:property-placeholder通过属性文件加载各种值.我可以使用Spring注入和记录的属性而不会出错,但是当我尝试在MEL表达式中对它们进行求值时,我会收到异常:
<spring:beans>
<spring:bean id="someId" class="com.myClass">
<!-- This works just fine -->
<spring:constructor-arg index="0" value="${myVariable}" />
</spring:bean>
</spring:beans>
<flow name="myFlow">
<!-- exception here -->
<choice>
<when expression="#[${myVariable} == 'setting1']">
<logger message="setting1 selected" level="WARN"/>
</when>
<otherwise>
<logger message="setting1 NOT selected" level="WARN"/>
</otherwise>
</choice>
</flow>
Run Code Online (Sandbox Code Playgroud)
错误是:
org.mule.exception.DefaultMessagingExceptionStrategy: Caught exception in Exception Strategy: null
java.lang.NullPointerException
at org.mule.routing.filters.ExpressionFilter.getFullExpression(ExpressionFilter.java:140)
Run Code Online (Sandbox Code Playgroud)
关于如何在MEL表达式中检查导入属性的值的任何想法?
这是完整的堆栈:
ERROR 2013-06-17 12:36:52,114 [defaultHttpConnector.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: Caught exception in Exception Strategy: null java.lang.NullPointerException at org.mule.routing.filters.ExpressionFilter.getFullExpression(ExpressionFilter.java:140) at org.mule.routing.filters.ExpressionFilter.accept(ExpressionFilter.java:104) at org.mule.routing.ChoiceRouter.selectProcessors(ChoiceRouter.java:35) at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:194) at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99) at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66) at …
我是Mule的新手,请指导我如何使用Mule表达式语言(MEL)在XML结构中插入新标签.需要在下面的XML结构中插入B标签
<Test>
<A>table 1</A>
<C>table 3</C>
</Test>
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我是骡子柔软的新人.我不知道mule studio和mule esb有什么区别.两种软件看起来都一样.mule studio是图形表示,我们也可以通过代码生成.我怎么能区分两者.什么是mule esb的用途.我们可以在哪里使用mule esb.我们如何使用这种骡子esb.我需要mule esb和mule studio之间的确切区别.哪一个最适合整合.
我正在尝试生成并设置一个映射(具有2个键值对)作为后续HTTP调用的有效负载.但是,用于创建Map的MEL表达式不起作用.
<sub-flow name="call-myservice" doc:name="call-myservice">
<set-payload value="#[username :${my.username}, password : ${my.password}]" doc:name="Set Payload"/>
<https:outbound-endpoint exchange-pattern="request-response" host="${myservice.Host}" method="POST" mimeType="application/json" doc:name="My Service call" path="mypath" port="443"/>
</sub-flow>
Run Code Online (Sandbox Code Playgroud)
我按照http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+MEL上的说明进行操作
这暗示 -
MEL provides a streamlined way to access map data.
Rather than constructing a map with a new statement, and then using its put method to populate it, you can simply write the following:
[key1 : value1, key2 : value2, . . .]
Run Code Online (Sandbox Code Playgroud)
但是,它给了我以下例外 -
ERROR 2014-02-28 15:27:51,424 [[services-proxy].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : …
Run Code Online (Sandbox Code Playgroud)