我需要托管SOAP Web服务并为该主Web服务托管代理Web服务... 所以我有以下内容: -
现在我已经创建了暴露的SOAP Web服务并执行了CRUD操作,并且工作正常。现在问题在于代理Web服务..以下是我的代理Web服务配置: -
<flow name="ProxyFlow" doc:name="ProxyFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8086" path="proxy/mainData" doc:name="HTTP" />
<cxf:proxy-service port="MainDataPort" namespace="http://services.test.com/schema/MainData/V1" service="MainDataService" payload="body" wsdlLocation="MainData.wsdl" doc:name="SOAP"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<jms:outbound-endpoint queue="ProxyQueue" connector-ref="Active_MQ" doc:name="JMS" exchange-pattern="request-response"/>
</flow>
<flow name="ClientProxy" doc:name="ClientProxy">
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:ProxyQueue" doc:name="JMS" exchange-pattern="request-response" disableTemporaryReplyToDestinations="true" responseTimeout="90000"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<cxf:proxy-client payload="body" doc:name="SOAP" />
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" method="POST" doc:name="HTTP" />
</flow>
现在您可以看到代理Web服务正在使用JMS队列。当我从SOAPUI触发代理Web服务时..我得到以下异常: -
INFO 2014-09-11 21:16:46,475 [ActiveMQ Session Task-1] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
ERROR 2014-09-11 21:16:46,483 [ActiveMQ Session Task-1] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader (javax.jms.JMSException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader(JMS Code: null) (javax.jms.JMSException)
org.mule.transport.jms.JmsMessageUtils:144 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
2. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader (javax.jms.JMSException) (org.mule.api.transformer.TransformerException)
org.mule.transport.jms.transformers.AbstractJmsTransformer:79 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
javax.jms.JMSException: Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader
at org.mule.transport.jms.JmsMessageUtils.toMessage(JmsMessageUtils.java:144)
at org.mule.transport.jms.transformers.AbstractJmsTransformer.transformToMessage(AbstractJmsTransformer.java:66)
at org.mule.transport.jms.transformers.ObjectToJMSMessage.transformMessage(ObjectToJMSMessage.java:54)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-09-11 21:16:47,522 [ActiveMQ Session Task-2] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException)
org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:81)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:512)
at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:117)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
WARN 2014-09-11 21:16:56,369 [[Dummysimpleclientwebservice].connector.http.mule.default.receiver.03] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://services.vertu.com/schema/MainData/V1}MainDataService has thrown exception, unwinding now
java.lang.NullPointerException
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:147)
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:135)
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:131)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:119)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)
at org.mule.module.cxf.CxfInboundMessageProcessor$1.write(CxfInboundMessageProcessor.java:426)
at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:353)
at org.mule.transport.http.HttpMessageProcessTemplate.sendResponseToClient(HttpMessageProcessTemplate.java:137)
at org.mule.execution.FlowProcessingPhase.sendResponseIfNeccessary(FlowProcessingPhase.java:153)
at org.mule.execution.FlowProcessingPhase.access$000(FlowProcessingPhase.java:29)
at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:78)
at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:63)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
at org.mule.execution.FlowProcessingPhase$1.run(FlowProcessingPhase.java:62)
at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
at org.mule.work.WorkerContext.run(WorkerContext.java:286)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
现在我可以发现主要的web服务是在内部调用的,而数据是在DB中创建的。但我想它无法将响应转换回代理客户端..任何建议..
答案 0 :(得分:0)
尝试以下列方式使用代理客户端。
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" method="POST" doc:name="HTTP" >
<cxf:proxy-client payload="body" doc:name="SOAP" />
</http:outbound-endpoint>
<logger level="INFO" message="#[message.payloadAs(java.lang.String)]" />
HTTP outbound正在以DepthXMLStreamReader的格式重新启动响应。上面的Proxy-client格式应该有所帮助。记录器将读取StreamReader的响应,因此它是可序列化的格式。
希望这有帮助。
答案 1 :(得分:0)
我意识到Http outbound之后的有效负载是流,所以需要将其转换为String,否则将获得异常。
所以,对我有用的解决方案是: -
<logger level="INFO" message="#[message.payloadAs(java.lang.String)]" />
或者我意识到放<byte-array-to-string-transformer>
也会有用