Java ファイルでアクセスしたいミュール構成 xml に変数があります。それ、どうやったら出来るの?私は以下の方法を見つけます:
- コンポーネントを使用
- 変圧器を使用
- groovy などのスクリプトを使用する
その変数をJavaファイルに送信したいので、それをJavaファイルのデータベースにインポートします。私の設定は:
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
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="CE-3.3.0"
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/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.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/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd ">
<set-variable variableName="remoteClientAddress"
value="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" />
<message-properties-transformer name="setProperty"
scope="session" doc:name="Message Properties">
<add-message-property key="remoteClientAddress"
value="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" />
</message-properties-transformer>
<flow name="service-cxf-wsdlfirstFlow1" doc:name="service-cxf-wsdlfirstFlow1">
<http:inbound-endpoint host="localhost" port="8085"
path="Weather/Service" exchange-pattern="request-response" doc:name="HTTP">
</http:inbound-endpoint>
<set-variable variableName="remoteClientAddress"
value="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" />
<message-properties-transformer doc:name="myproperty"
scope="session">
<add-message-property key="remoteClientAddress"
value="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" />
</message-properties-transformer>
<component doc:name="classTest" class="org.mule.example.scripting.IpClient" />
<logger
message="#[groovy:message.getInboundProperty('MULE_REMOTE_CLIENT_ADDRESS')]"
level="INFO" doc:name="Logger" />
<cxf:proxy-service payload="envelope" service="Weather"
wsdlLocation="http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl"
namespace="http://ws.cdyne.com/WeatherWS/" validationEnabled="true"
doc:name="SOAP">
</cxf:proxy-service>
<copy-properties propertyName="SOAPAction" doc:name="Property" />
<cxf:proxy-client payload="body"
enableMuleSoapHeaders="true" doc:name="SOAP" />
<outbound-endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
exchange-pattern="request-response" doc:name="Generic">
</outbound-endpoint>
</flow>
私のラバのバージョンは CE 3.3.0 です。コンポーネントを使用してJavaクラスの場所を定義していますが、プロジェクトを実行した後、エラーが発生しました:
ERROR 2013-02-27 11:15:20,129 [[mule-sample_].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : Failed to find entry point for component, the following resolvers tried but failed: [
CallableEntryPointResolver: Object "IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]}" does not implement required interface "interface org.mule.api.lifecycle.Callable"
ReflectionEntryPointResolver: Found too many possible methods on object "org.mule.example.scripting.IpClient" that accept parameters "{class java.lang.String}", Methods matched are "[public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String) throws javax.activation.MimeTypeParseException, public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object) throws org.mule.api.transformer.TransformerException, public void org.mule.transformer.AbstractTransformer.setName(java.lang.String), public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String)]"
AnnotatedEntryPointResolver: Component: IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]} doesn't have any annotated methods, skipping.
MethodHeaderPropertyEntryPointResolver: The required property "method" is not set on the event
]
Code : MULE_ERROR-321
--------------------------------------------------------------------------------
Exception stack is:
1. Failed to find entry point for component, the following resolvers tried but failed: [
CallableEntryPointResolver: Object "IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]}" does not implement required interface "interface org.mule.api.lifecycle.Callable"
ReflectionEntryPointResolver: Found too many possible methods on object "org.mule.example.scripting.IpClient" that accept parameters "{class java.lang.String}", Methods matched are "[public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String) throws javax.activation.MimeTypeParseException, public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object) throws org.mule.api.transformer.TransformerException, public void org.mule.transformer.AbstractTransformer.setName(java.lang.String), public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String)]"
AnnotatedEntryPointResolver: Component: IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]} doesn't have any annotated methods, skipping.
MethodHeaderPropertyEntryPointResolver: The required property "method" is not set on the event
] (org.mule.model.resolvers.EntryPointNotFoundException)
org.mule.model.resolvers.DefaultEntryPointResolverSet:52 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/model/resolvers/EntryPointNotFoundException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.model.resolvers.EntryPointNotFoundException: Failed to find entry point for component, the following resolvers tried but failed: [
CallableEntryPointResolver: Object "IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]}" does not implement required interface "interface org.mule.api.lifecycle.Callable"
ReflectionEntryPointResolver: Found too many possible methods on object "org.mule.example.scripting.IpClient" that accept parameters "{class java.lang.String}", Methods matched are "[public void org.mule.transformer.AbstractTransformer.setMimeType(java.lang.String) throws javax.activation.MimeTypeParseException, public final java.lang.Object org.mule.transformer.AbstractTransformer.transform(java.lang.Object) throws org.mule.api.transformer.TransformerException, public void org.mule.transformer.AbstractTransformer.setName(java.lang.String), public void org.mule.transformer.AbstractTransformer.setEncoding(java.lang.String)]"
AnnotatedEntryPointResolver: Component: IpClient{this=1e68a2b, name='null', ignoreBadInput=false, returnClass=SimpleDataType{type=java.lang.Object, mimeType='*/*'}, sourceTypes=[]} doesn't have any annotated methods, skipping.
MethodHeaderPropertyEntryPointResolver: The required property "method" is not set on the event
]
at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:52)
at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:343)
at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:86)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)