2012-11-08 3 views
1

HTTP 아웃 바운드 흐름 (POJO는 아웃 바운드 Jaxws 클라이언트의 출력)에서 jaxws-client를 사용하여 노새 통신에서 다음 XML을 사용하고 있습니다.노새 ESB CXF 예외 처리

com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1 : 받는다는에 WSDL2Java의 플러그인을 사용하여 확인 생성 WS 코드

는, 생성 된 코드는 클래스가 WS에서 오는 예외 클래스가

다음 WS 사용 excpetion를 handeling 때 위의 오류를 받고 있어요

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: [email protected] 
INFO 2012-11-08 11:08:13,010 [[cxf].TCP_C_L.receiver.02] org.mule.api.processor.LoggerMessageProcessor: [email protected] 

이 예외가 발생한 후 우리는 SOAPFault에있어 때 반드시 HTTP 응답에 대한 .TisException

은 500입니다

<catch-exception-strategy> 
      <logger message="#[payload]" level="INFO" doc:name="Logger" /> 
      <transformer ref="ByteArrayToString" /> 
      <append-string-transformer message="&#xD;&#xA;" /> 
      <logger message="#[payload]" level="INFO" doc:name="Logger" /> 
     </catch-exception-strategy> 

확실히 아파치 낙타와 같은 예외를 처리해야합니다. 예외를 지정해야하고 노새가 XML 구성에 의해 처리 될 콘솔에서 위의 예외를 발생시키지 않아야합니다.

잭스 - WS 클라이언트 아웃 바운드에서 수신 메시지의 종류는, 내가 뮬 ESB는 WS 예외를 이해하게 관리 할 수있는 방법

[email protected]

입니다 나는 이것을 시도했다

그리고 그것도 잘 작동하지 않았다.

조언 해 주실 수 있습니까?

퓨즈 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> 

가 어떻게 뮬 ESB에서 동일 할 수 있습니다. 첫 번째 서브 흐름 usernameToken1 내가 아파치 낙타에 배포 웹 서비스를 호출

<?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="&#xD;&#xA;" /> 

     <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="&#xD;&#xA;" /> <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="&#xD;&#xA;" /> 
      <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> 

, 난 그냥 제기 된 예외 클래스 위의 질문에서 언급. 친절

나 귀하의 의견을 알려

,

+0

당신은뿐만 아니라 흐름 구성을 공유 할 수 있을까요? – genjosanzo

+0

답장을 보내 주시면 플로우 구성을 추가 했습니까? – user1724562

+0

좋아요, 올바르게 이해한다면 catch-exception-strategy에서 예외를 잡아두고 거기에있는 클라이언트에게 다시 보낼 비누를 crete 하시겠습니까? – genjosanzo

답변

2

당신이 겪고있는 문제는 페이로드 예외 전략 블록에 도달하는 시간, 메시지가 이미 잭스 - WS 클라이언트에 의해 소비 된 당신이 잡아 수 없다는 것입니다 더 이상.

jaxws 클라이언트를 아웃 바운드 종단점 (오른쪽) 외부에 배치하면됩니다. 아웃 바운드 종점 다음에는 Soap Message가 있습니다. 단순히 http 상태를 확인하여 예외인지 여부를 확인할 수 있습니다. 상태가 오류 인 경우 메시지를 문자열로 변환하여 변수에 저장할 수 있습니다. 메시지가 돌아 오는 길에 클라이언트에 도달하면 Soap 메시지를 해석하고 예외 전략 블록에 의해 처리 될 것이라는 예외를 throw합니다. 예외 내에서는 비누 오류를 저장하는 변수를 읽고 원하는대로 수행 할 수 있습니다.

나는 그것이 매우 성가신 해결책이라는 것을 알고 있지만, 내가 생각할 수있는 유일한 해결책이다.앞서 말했던 문제는 HTTP가 서비스에서 스트림을 수신하고, 스트림을 언 마샬링하고 예외를 던지기 전에 jaxws 클라이언트가 사용한다는 것입니다. 비누 오류를 보존하는 유일한 방법은 Mule이 매번 입력을 직렬화하는 경우입니다. 이는 매우 비쌀 수 있습니다.

HTH, 에바