http アウトバウンド フロー内で jaxws-client を使用したミュール通信で次の XML を使用しています (POJO はアウトバウンド Jaxws クライアントからの出力です)。
maven で wsdl2java プラグインを使用して WS コードを確実に生成するために、生成されたコードには WS からの例外のクラスがあります。クラスは次のとおりです。
com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException
WS がこの例外を発生させた後に SOAPFault を取得したとき、確かに http 応答は 500 です。
com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException
INFO 2012-11-08 11:08:08,008 [[cxf].TCP_C_L.receiver.02] org.mule.transport.http.HttpClientMessageDispatcher: Received a redirect, but followRedirects=false. Response code: 500 Server Error
ERROR 2012-11-08 11:08:13,008 [[cxf].TCP_C_L.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : error. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: PostMethod
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. error (com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException)
sun.reflect.NativeConstructorAccessorImpl:-2 (null)
2. error. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: PostMethod (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException: error
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2012-11-08 11:08:13,009 [[cxf].TCP_C_L.receiver.02] org.mule.api.processor.LoggerMessageProcessor: org.apache.commons.httpclient.methods.PostMethod@d02649
INFO 2012-11-08 11:08:13,010 [[cxf].TCP_C_L.receiver.02] org.mule.api.processor.LoggerMessageProcessor: org.apache.commons.httpclient.methods.PostMethod@d02649
次を使用して例外を処理すると、上記のエラーが発生します。
<catch-exception-strategy>
<logger message="#[payload]" level="INFO" doc:name="Logger" />
<transformer ref="ByteArrayToString" />
<append-string-transformer message="
" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
</catch-exception-strategy>
確かに、apache camel と同じ例外を処理する必要があります。例外をミュールに指定する必要があります。ミュールは、XML 構成によって処理されるため、コンソールで上記の例外を発生させないでください。
jaxWs-client アウトバウンドからの着信メッセージのタイプは
org.apache.commons.httpclient.methods.PostMethod@d02649
Mule ESB に WS 例外を理解させるにはどうすればよいでしょうか。これを試してみました
それもうまくいきませんでした。
あなたがアドバイスしていただけますか 。
Fuse ESB では、次のようにしました。
<onException>
<exception>com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException</exception>
<handled>
<constant>true</constant>
</handled>
<to uri="log:test" />
<setBody>
<simple>${exception.getFaultInfo}</simple>
</setBody>
<to uri="log:exception" />
<convertBodyTo type="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1.FaultMessage" />
<marshal ref="decExc" />
<convertBodyTo type="String" />
<bean ref="nulladd" />
</onException>
Mule ESB で同じものを作成するにはどうすればよいですか。
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="EE-3.3.0"
xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.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/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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd ">
<spring:beans>
<spring:bean name="samlCallbackHandler"
class="com.mulesoft.mule.example.security.SAMLCallbackHandler" id="samlCallbackHandler" />
</spring:beans>
<sub-flow name="Jaxws" doc:name="Jaxws">
<cxf:jaxws-client operation="ExecuteCommand"
serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface"
doc:name="UsernameToken SOAP client">
<!-- <cxf:ws-security> <cxf:ws-config> <cxf:property key="action" value="UsernameToken
Timestamp" /> <cxf:property key="user" value="joe" /> <cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" /> <cxf:property
key="mustUnderstand" value="false" /> </cxf:ws-config> </cxf:ws-security> -->
</cxf:jaxws-client>
</sub-flow>
<sub-flow name="usernameToken1" doc:name="usernameToken1">
<!-- <cxf:jaxws-client operation="ExecuteCommand" serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface"
doc:name="UsernameToken SOAP client"> <cxf:ws-security> <cxf:ws-config> <cxf:property
key="action" value="UsernameToken Timestamp" /> <cxf:property key="user"
value="joe" /> <cxf:property key="passwordCallbackClass" value="com.mulesoft.mule.example.security.PasswordCallback"
/> <cxf:property key="mustUnderstand" value="false" /> </cxf:ws-config> </cxf:ws-security>
</cxf:jaxws-client> -->
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="8899" path="cxf/services"
doc:name="Invoke NSNusernameToken Web Service">
<cxf:jaxws-client operation="ExecuteCommand"
serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface"
doc:name="UsernameToken SOAP client">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken Timestamp" />
<cxf:property key="user" value="joe" />
<cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" />
<cxf:property key="mustUnderstand" value="false" />
</cxf:ws-config>
</cxf:ws-security>
<cxf:inInterceptors />
<cxf:outInterceptors />
</cxf:jaxws-client>
</http:outbound-endpoint>
<logger message="#[payload]" level="INFO" doc:name="Logger" />
<mulexml:jaxb-object-to-xml-transformer
jaxbContext-ref="xmltoobj" />
<object-to-string-transformer />
<append-string-transformer message="
" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
</sub-flow>
<object-to-string-transformer name="ObjectToString" />
<byte-array-to-string-transformer
name="ByteArrayToString" />
<tcp:connector name="TCP_C_L" validateConnections="false"
receiveBufferSize="102400" sendBufferSize="102400" doc:name="TCP">
<tcp:xml-protocol />
</tcp:connector>
<mulexml:jaxb-context name="myJaxbContext"
packageNames="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1" />
<mulexml:jaxb-context name="xmltoobj"
packageNames="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1" />
<flow name="NSNServiceClient" doc:name="NSN IN Unified Client Service">
<tcp:inbound-endpoint host="localhost" port="51000"
connector-ref="TCP_C_L" />
<transformer ref="ByteArrayToString" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
<mulexml:jaxb-xml-to-object-transformer
jaxbContext-ref="myJaxbContext" />
<flow-ref name="usernameToken1" doc:name="usernameToken1" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
<!-- <default-exception-strategy> <choice>
<when evaluator="groovy" expression='payload.getException().getClass().getName().equals("com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException")'>
<logger message="#[payload]" level="INFO" doc:name="Logger" /> <object-to-string-transformer/>
<append-string-transformer message="
" /> <vm:outbound-endpoint
path="error.notification"/> </when> </choice> </default-exception-strategy> -->
<catch-exception-strategy>
<logger message="#[payload]" level="INFO" doc:name="Logger" />
<transformer ref="ByteArrayToString" />
<append-string-transformer message="
" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
</catch-exception-strategy>
<!-- <auto-transformer returnClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException"/> -->
<!-- <custom-exception-strategy class="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException">
<logger message="#[payload]" level="INFO" doc:name="Logger" /> </custom-exception-strategy> -->
</flow>
<flow name="SecurityClients" doc:name="SecurityClients">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="63080" path="client" doc:name="HTTP Inbound Endpoint" />
<set-payload
value="#[message.inboundProperties['http.query.params']['name']]"
doc:name="Set payload with 'name' query param" />
<set-variable variableName="clientType"
value="#[message.inboundProperties['http.query.params']['clientType']]"
doc:name="Set clientType" />
<choice doc:name="Choice">
<when expression="#[clientType == 'unsecure']">
<processor-chain>
<flow-ref name="unsecure" doc:name="Invoke unsecure sub-flow" />
</processor-chain>
</when>
<!--<when expression="#[clientType == 'usernameToken']"> <processor-chain>
<flow-ref name="usernameToken1" doc:name="usernameToken1" /> </processor-chain>
</when> -->
<when expression="#[clientType == 'usernameTokenSigned']">
<processor-chain>
<flow-ref name="usernameTokenSigned" doc:name="Invoke usernameToken Signed sub-flow" />
</processor-chain>
</when>
<when expression="#[clientType == 'usernameTokenEncrypted']">
<processor-chain>
<flow-ref name="usernameTokenEncrypted" doc:name="Invoke usernameToken Encrypted sub-flow" />
</processor-chain>
</when>
<when expression="#[clientType == 'samlToken']">
<processor-chain>
<flow-ref name="samlToken" doc:name="Invoke samlToken sub-flow" />
</processor-chain>
</when>
<when expression="#[clientType == 'samlTokenSigned']">
<processor-chain>
<flow-ref name="samlTokenSigned" doc:name="Invoke samlToken Signed sub-flow" />
</processor-chain>
</when>
<otherwise>
<processor-chain>
<set-payload value="Client type is not supported"
doc:name="Client type is not supported" />
</processor-chain>
</otherwise>
</choice>
<set-property propertyName="Content-Type" value="text/plain"
doc:name="Set response Content-Type" />
<catch-exception-strategy doc:name="Catch Exception Strategy">
<set-payload value="There has been an Error processing the request"
doc:name="Set Payload" />
<set-property propertyName="Content-Type" value="text/plain"
doc:name="Set response Content-Type" />
</catch-exception-strategy>
</flow>
<sub-flow name="unsecure" doc:name="unsecure">
<cxf:jaxws-client operation="greet"
serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="Unsecure SOAP client"
doc:description="Unsecure SOAP client" />
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="63081" path="services/unsecure" doc:name="Invoke unsecure Web Service" />
</sub-flow>
<!-- <sub-flow name="usernameToken" doc:name="usernameToken"> <cxf:jaxws-client
operation="greet" serviceClass="com.mulesoft.mule.example.security.Greeter"
doc:name="UsernameToken SOAP client"> <cxf:ws-security> <cxf:ws-config> <cxf:property
key="action" value="UsernameToken Timestamp"/> <cxf:property key="user" value="joe"/>
<cxf:property key="passwordCallbackClass" value="com.mulesoft.mule.example.security.PasswordCallback"/>
</cxf:ws-config> </cxf:ws-security> </cxf:jaxws-client> <http:outbound-endpoint
exchange-pattern="request-response" host="localhost" port="63081" path="services/username"
doc:name="Invoke usernameToken Web Service"/> </sub-flow> -->
<sub-flow name="usernameTokenSigned" doc:name="usernameTokenSigned">
<cxf:jaxws-client operation="greet"
serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="UsernameToken Signed SOAP client">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken Signature Timestamp" />
<cxf:property key="signaturePropFile" value="wssecurity.properties" />
<cxf:property key="user" value="joe" />
<cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" />
</cxf:ws-config>
</cxf:ws-security>
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="63081" path="services/signed"
doc:name="Invoke usernameToken Signed Web Service" />
</sub-flow>
<sub-flow name="usernameTokenEncrypted" doc:name="usernameTokenEncrypted">
<cxf:jaxws-client operation="greet"
serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="UsernameToken Encrypted SOAP client">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken Timestamp Encrypt" />
<cxf:property key="encryptionPropFile" value="wssecurity.properties" />
<cxf:property key="user" value="joe" />
<cxf:property key="encryptionUser" value="joe" />
<cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" />
</cxf:ws-config>
</cxf:ws-security>
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="63081" path="services/encrypted"
doc:name="Invoke usernameToken Encrypted Web Service" />
</sub-flow>
<sub-flow name="samlToken" doc:name="samlToken">
<cxf:jaxws-client operation="greet"
serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="SAMLToken SOAP client">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="SAMLTokenUnsigned Timestamp" />
<cxf:property key="samlPropFile" value="saml.properties" />
<cxf:property key="samlCallbackClass"
value="com.mulesoft.mule.example.security.SAMLCallbackHandler" />
</cxf:ws-config>
</cxf:ws-security>
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="63081" path="services/saml" doc:name="Invoke SAMLToken Web Service" />
</sub-flow>
<sub-flow name="samlTokenSigned" doc:name="samlTokenSigned">
<cxf:jaxws-client operation="greet"
serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="SAMLToken Signed SOAP client">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="SAMLTokenSigned" />
<cxf:property key="samlPropFile" value="saml.properties" />
<cxf:property key="signatureKeyIdentifier" value="DirectReference" />
<cxf:property key="user" value="joe" />
<cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" />
<cxf:property key="samlCallbackClass"
value="com.mulesoft.mule.example.security.SAMLCallbackHandler" />
</cxf:ws-config>
</cxf:ws-security>
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response"
host="localhost" port="63081" path="services/signedsaml"
doc:name="Invoke SAMLToken Signed Web Service" />
</sub-flow>
</mule>
最初のサブフロー usernameToken1 は、Apache camel にデプロイした Web サービスを呼び出しています。発生した例外クラスについて上記の質問で言及しました。
フィードバックをお寄せください。