2013-02-21 8 views
0

Я использую поток мула, указанный ниже, для простого запроса веб-службы. Запрос успешно завершается, и с помощью wirehark я вижу, что похоже на правильный ответ.Исключение ответа на обработку файлов для запроса веб-службы

Я не видел исключения, пока не включил конечную точку выходного файла (чтобы захватить ответ на файл). Даже при этом исключении (включенном внизу), когда я смотрю в выходной файл, который сгенерирован, я вижу свои данные, хотя во многих случаях это только часть данных.

В чем причина этого исключения?

Это поток:

<flow name="TestAuditorClient_CheckerFlow1" doc:name="TestAuditorClient_CheckerFlow1"> 
    <quartz:inbound-endpoint jobName="gen" repeatInterval="10000" responseTimeout="10000" 
     doc:name="Quartz"> <quartz:event-generator-job /> </quartz:inbound-endpoint> 
    <component class="wsdl.Payload" doc:name="Java"/> 
    <cxf:jaxws-client operation="listTest" 
     clientClass="server.TestService_Service" port="TestServicePort" 
     wsdlLocation="http://192.168.66.7:8080/TestAuditorWebApp/TestService?wsdl" 
     enableMuleSoapHeaders="true" doc:name="SOAPY" /> 
    <outbound-endpoint 
     address="http://192.168.66.7:8080/TestAuditorWebApp/TestService" 
     doc:name="HTTP" mimeType="text/xml" /> 
    <logger message="Received HTTP Response #[payload]" level="INFO" 
     doc:name="Logger" /> 
    <file:outbound-endpoint path="C:\tmp" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].txt" 
     responseTimeout="10000" doc:name="Output File" /> 
</flow> 

Это исключение:

INFO 2013-02-21 15:38:09,753 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: soap payload:  [email protected] 
INFO 2013-02-21 15:38:09,769 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest 
INFO 2013-02-21 15:38:09,769 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse 
INFO 2013-02-21 15:38:09,769 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest 
INFO 2013-02-21 15:38:09,769 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'HTTP_HTTPS.dispatcher.479670620'. Object is: HttpClientMessageDispatcher 
INFO 2013-02-21 15:38:09,784 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'HTTP_HTTPS.dispatcher.479670620'. Object is: HttpClientMessageDispatcher 
INFO 2013-02-21 15:38:09,878 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Received HTTP Response [email protected] 
INFO 2013-02-21 15:38:09,878 [[test_auditor_client4].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.784931034'. Object is: FileMessageDispatcher 
INFO 2013-02-21 15:38:09,878 [[test_auditor_client4].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.784931034'. Object is: FileMessageDispatcher 
INFO 2013-02-21 15:38:09,894 [[test_auditor_client4].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\tmp\21-02-13_1361479089894.txt 
WARN 2013-02-21 15:38:09,894 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://server/}TestService#{http://server/}listTest has thrown exception, unwinding now 
java.lang.RuntimeException: Couldn't parse stream. 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1181) 
    at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) 
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:799) 
    at org.mule.module.cxf.transport.MuleUniversalConduit.dispatchMuleMessage(MuleUniversalConduit.java:280) 
    at org.mule.module.cxf.transport.MuleUniversalConduit$2.handleMessage(MuleUniversalConduit.java:194) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) 
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) 
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88) 
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
    at $Proxy33.listTest(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithProxy(CxfOutboundMessageProcessor.java:187) 
    at org.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.java:129) 
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27) 
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43) 
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43) 
    at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:93) 
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:66) 
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27) 
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43) 
    at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105) 
    at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55) 
    at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118) 
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:186) 
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:179) 
    at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:20) 
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:34) 
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:18) 
    at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:58) 
    at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:48) 
    at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:54) 
    at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:44) 
    at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44) 
    at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52) 
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:32) 
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:17) 
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:113) 
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:34) 
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:178) 
    at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43) 
    at org.mule.work.WorkerContext.run(WorkerContext.java:311) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: com.ctc.wstx.exc.WstxIOException: Attempted read on closed stream. 
    at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:536) 
    at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:585) 
    at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:610) 
    at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:316) 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1179) 
    ... 50 more 
Caused by: java.io.IOException: Attempted read on closed stream. 
    at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183) 
    at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107) 
    at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:63) 
    at java.io.FilterInputStream.read(Unknown Source) 
    at java.io.PushbackInputStream.read(Unknown Source) 
    at com.ctc.wstx.io.BaseReader.readBytes(BaseReader.java:155) 
    at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:368) 
    at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:111) 
    at com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250) 
    at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133) 
    at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:531) 
    ... 54 more 
ERROR 2013-02-21 15:38:09,972 [[test_auditor_client4].TestAuditorClient_CheckerFlow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
******************************************************************************** 
Message    : Attempted read on closed stream.. 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. Attempted read on closed stream. (java.io.IOException) 
    org.apache.commons.httpclient.AutoCloseInputStream:183 (null) 
2. Attempted read on closed stream. (com.ctc.wstx.exc.WstxIOException) 
    com.ctc.wstx.stax.WstxInputFactory:536 (null) 
3. Couldn't parse stream. (java.lang.RuntimeException) 
    org.apache.cxf.staxutils.StaxUtils:1181 (null) 
4. Couldn't parse stream. (javax.xml.ws.soap.SOAPFaultException) 
    org.apache.cxf.jaxws.JaxWsClientProxy:156 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/ws/soap/SOAPFaultException.html) 
5. Attempted read on closed stream.. 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: 
java.io.IOException: Attempted read on closed stream. 
    at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183) 
    at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107) 
    at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:63) 
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) 
******************************************************************************** 

ответ

0

То, что происходит в том, что результатом взаимодействия HTTP исходящего сначала обрабатывается то, что после того, как исходящую конечной точки перед тем, как передается обратно клиенту CXF. В это время потоковая полезная нагрузка была потреблена, и CXF больше не справляется с этим.

Вы можете попробовать следующее:

<flow name="TestAuditorClient_CheckerFlow1" doc:name="TestAuditorClient_CheckerFlow1"> 
    <quartz:inbound-endpoint jobName="gen" repeatInterval="10000" responseTimeout="10000" 
     doc:name="Quartz"> <quartz:event-generator-job /> </quartz:inbound-endpoint> 
    <component class="wsdl.Payload" doc:name="Java"/> 
    <http:outbound-endpoint 
     address="http://192.168.66.7:8080/TestAuditorWebApp/TestService" 
     doc:name="HTTP" mimeType="text/xml"> 
     <cxf:jaxws-client operation="listTest" 
      clientClass="server.TestService_Service" port="TestServicePort" 
      wsdlLocation="http://192.168.66.7:8080/TestAuditorWebApp/TestService?wsdl" 
      enableMuleSoapHeaders="true" doc:name="SOAPY" /> 
    </http:outbound-endpoint> 
    <logger message="Received HTTP Response #[payload]" level="INFO" 
     doc:name="Logger" /> 
    <file:outbound-endpoint path="C:\tmp" 
     outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].txt" 
     responseTimeout="10000" doc:name="Output File" /> 
</flow> 

Идея заключается в том, чтобы локализовать CXF взаимодействие в HTTP конечной точке.

Обратите внимание, что я изменил общую исходящую конечную точку на HTTP-версию, это не обязательно, но по крайней мере вы получите лучшую поддержку доступных свойств.

Также обратите внимание, что полезной нагрузкой сообщения в потоке после взаимодействия CXF будет объект ответа, а не сообщение SOAP. Вам нужно будет решить стратегию сериализации (например, JAXB), чтобы сохранить ее в файле.

+0

Спасибо, Дэвид. Я попробую сегодня утром. –

+0

Я пробовал поток, который вы предлагаете, ошибка, которую я вижу сейчас: ERROR 2013-02-22 09: 29: 41,918 [[test_auditor_client4] .connector.file.mule.default.dispatcher.01] org .mule.exception.DefaultMessagingExceptionStrategy: Сообщение: указан недопустимый тип возвращаемого значения "класса java.io.InputStream" для трансформатора "JAXBMarshallerTransformer" код: MULE_ERROR-266 –

+0

Root стека исключений трассировки: org.mule.api.transformer .TransformerException: для преобразователя «JAXBMarshallerTransformer» \t был указан недопустимый тип возврата «класс java.io.InputStream» на org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer.doTransform (JAXBMarshallerTransformer.java:122) \t на org.mule.transformer.AbstractTransformer.transform (AbstractTransformer.java:411) \t в org.mule.DefaultMuleMessage.getPayload (DefaultMuleMessage.java:362) + еще 3 (установить уровень регистрации отладки или '-Dmule.verbose.exceptions = true' для всего) –

0

Теперь, когда Давид взял время, чтобы направить меня в правильном направлении, я выложу ответ на благо тех, кто пытается это в будущем:

Рабочий поток:

<flow name="TestAuditorClient_CheckerFlow1" doc:name="TestAuditorClient_CheckerFlow1"> 
    <quartz:inbound-endpoint jobName="gen" 
     repeatInterval="10000" responseTimeout="10000" doc:name="Quartz"> 
     <quartz:event-generator-job /> 
    </quartz:inbound-endpoint> 
    <component class="wsdl.Payload" doc:name="Java" /> 
    <http:outbound-endpoint 
     address="http://192.168.66.7:8080/TestAuditorWebApp/TestService" 
     doc:name="HTTP" mimeType="text/xml"> 
     <cxf:jaxws-client operation="listTest" 
      clientClass="server.TestService_Service" port="TestServicePort" 
      wsdlLocation="http://192.168.66.7:8080/TestAuditorWebApp/TestService?wsdl" 
      enableMuleSoapHeaders="true" doc:name="SOAPY" /> 
    </http:outbound-endpoint> 
    <logger message="Received HTTP Response #[payload]" level="INFO" 
     doc:name="Logger" /> 
    <component class="wsdl.Payload" doc:name="Java"/> 
    <file:outbound-endpoint path="C:\tmp" 
     outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].txt" 
     responseTimeout="10000" doc:name="Output File" /> 
</flow> 

Обратите внимание, что я использую класс wsdl.Payload как до HTTP-запроса, так и после запроса. Этот единственный класс используется для генерации запроса и для обработки ответа.

Это тот класс:

package wsdl; 

import server.ListTest; 
import server.ListTestResponse; 

public class Payload { 

    public ListTest request() { 
    System.out.println("request response"); 
    return new ListTest(); 
} 

public String response(ListTestResponse listTestResponse) { 
    System.out.println("process response"); 
    StringBuilder sb = new StringBuilder(); 

    List<Test> testList = listTestResponse.getReturn(); 
    Iterator<Test> testIt = testList.iterator(); 
    while(testIt.hasNext()) { 
     Test test = testIt.next(); 
     sb.append(test.getName()).append(" ").append(test.getDescription()).append(", "); 
    } 
    return sb.toString(); 
} 
} 

Вуаля, теперь поток мул работает точно так же, как я предполагал.

 Смежные вопросы

  • Нет связанных вопросов^_^