1

Mule の Expression Language (MEL) を介してインポートされた Java.lang.string から .length を使用して、長さを見つけ、それを選択演算子で使用しようとしています。私が信じている問題は型の不一致ですが、私が持っているものを変換する方法がわからないので、長さを見つけることができます。

私は Web サービスを公開しており、選択したエンドポイントで POJO の ID を使用しようとしています。本質的な場合は、payload.bookID.length > 10 が必要です。したがって、ID が 10 より大きい場合は、1 つのサービス (Google) にルーティングできます。それ以外の場合は、UPC にルーティングします

現在、私は取得しています

式「payload.bookid.length > 10」の実行に失敗しました (org.mule.api.expression.ExpressionRuntimeException)。メッセージ ペイロードのタイプ: BookLookupService$Book
原因: [エラー: アクセスできませんでした: 長さ; クラス内: java.lang.String] [近く: {... 不明 ....}]

構成ファイルの最初の部分と、関連する Java ファイルが含まれています。フローについてさらに質問がありますが、データマッパーを投稿して人々が使用できるようにする方法がわかりません。誰かがそれについてのヒントもあれば。

ありがとう!

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

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper"
    xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
    xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
    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:spring="http://www.springframework.org/schema/beans" version="EE-3.3.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd 
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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd ">
    <mulexml:namespace-manager
        includeConfigNamespaces="true">
        <mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/>
        <mulexml:namespace prefix="cas" uri="http://case2.com/"/>
        <mulexml:namespace prefix="cas1" uri="http://case2.com/"/>
    </mulexml:namespace-manager>
    <data-mapper:config name="json_to_pojo"
        transformationGraphPath="json_to_pojo.grf" doc:name="DataMapper" />
    <data-mapper:config name="google_out_to_pojo" transformationGraphPath="google_out_to_pojo.grf" doc:name="google_out_to_pojo"/>
    <data-mapper:config name="google_out" transformationGraphPath="google_out.grf" doc:name="google_out"/>

    <flow name="case2Flow1" doc:name="case2Flow1">
        <http:inbound-endpoint exchange-pattern="request-response"
            address="http://localhost:8081/Case2" doc:name="HTTP"></http:inbound-endpoint>
        <cxf:simple-service serviceClass="com.case2.BookLookupService"
            doc:name="SOAP" />
        <component class="com.case2.BookLookupServiceImpl" doc:name="Java" />
        <logger
            message="Incoming payload is: #[payload]
Book ID is : #[payload.bookid]"
            level="INFO" doc:name="Logger" />
        <choice doc:name="Choice">
            <when expression="payload.bookid.length > 10">
                <flow-ref name="googleISBNFlow2" doc:name="Google" />
            </when>
        </choice>
    </flow>

</mule>

ジャワ

package com.case2;

public interface BookLookupService
{
public static class BookLookup
{
    private String bookid;

    public String getBookid()
    {
        return bookid;
    }

    public void setBookid(final String bookid)
    {
        this.bookid = bookid;
    }
}

public static class Book
{
    private String bookid, name, imageurl;

    public String getBookid()
    {
        return bookid;
    }

    public void setBookid(final String bookid)
    {
        this.bookid = bookid;
    }

    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }


    public String getImageURL()
    {
        return imageurl;
    }

    public void setImageURL(final String imageurl)
    {
        this.imageurl = imageurl;
    }

}

Book lookup(final BookLookup bookLookup);
}



package com.case2;

public class BookLookupServiceImpl implements BookLookupService
{
    public Book lookup(final BookLookup bookLookup)
    {
        final Book book = new Book();
        book.setName("LOTR");
        book.setBookid(bookLookup.getBookid());
        return book;
    }
}
4

2 に答える 2

4

getBookid()genjosanzo は、正しい MEL 式が次のとおりであることを除いて、両方の点で正しいです (DataMapper EE サポートへの間違ったアクセスと)。

<when expression="#[message.payload.bookid.length() > 10]">
于 2012-10-22T16:08:58.787 に答える
2

あなたが経験している問題は、 when 式の書き方に関連しているようです。

次のようになります。

<when expression="#[payload.bookid.length() > 10]">

datamapper の質問は EE 機能であるため、MuleSoft に直接連絡することをお勧めします。

于 2012-10-22T14:59:18.953 に答える