ule子-安排流以使用Web服务 [英] Mule - Schedule a flow to consume a web service
问题描述
我是Mule的新手,并且想做一件简单"的事情:
I'm new to Mule, and wanted to do one "simple" thing :
- 每隔X秒,调用soap webservice操作并将结果存储在文件中.
我的流程实际上看起来像这样:
My Flow looks actually like this :
<?xml version="1.0" encoding="UTF-8"?>
...
<custom-transformer class="net.cpy.samples.webservices.SampleMessage" name="MessageWs" doc:name="MessageWs"/>
<flow name="csvPublisher" doc:name="csvPublisher">
<quartz:inbound-endpoint jobName="job1" repeatInterval="5000" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job/>
</quartz:inbound-endpoint>
<cxf:jaxws-client operation="getMessages" clientClass="net.cpy.samples.webservices.MessageServiceService" port="MessageServicePort" wsdlLocation="http://localhost:8080/webservices-0.0.1-SNAPSHOT/MessageService?wsdl" enableMuleSoapHeaders="true" doc:name="SOAP Client">
<cxf:inInterceptors/>
<cxf:outInterceptors/>
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/webservices-0.0.1-SNAPSHOT/MessageService" doc:name="HTTP"/>
<file:outbound-endpoint path="/tmp" outputPattern="output.xml" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>
我的示例Web服务的WSDL是:
The WSDL of my sample webservice is :
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="MessageServiceService" targetNamespace="http://webservices.samples.cpy.net/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservices.samples.cpy.net/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema elementFormDefault="unqualified" targetNamespace="http://webservices.samples.cpy.net/" version="1.0" xmlns:tns="http://webservices.samples.cpy.net/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getMessages" type="tns:getMessages"/>
<xs:element name="getMessagesResponse" type="tns:getMessagesResponse"/>
<xs:element name="sampleMessage" type="tns:sampleMessage"/>
<xs:complexType name="getMessages">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getMessagesResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="tns:sampleMessage"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sampleMessage">
<xs:sequence>
<xs:element minOccurs="0" name="content" type="xs:string"/>
<xs:element minOccurs="0" name="date" type="xs:dateTime"/>
<xs:element minOccurs="0" name="id" type="xs:long"/>
<xs:element minOccurs="0" name="signature" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getMessagesResponse">
<wsdl:part element="tns:getMessagesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getMessages">
<wsdl:part element="tns:getMessages" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="MessageService">
<wsdl:operation name="getMessages">
<wsdl:input message="tns:getMessages" name="getMessages">
</wsdl:input>
<wsdl:output message="tns:getMessagesResponse" name="getMessagesResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MessageServiceServiceSoapBinding" type="tns:MessageService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getMessages">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getMessages">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getMessagesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MessageServiceService">
<wsdl:port binding="tns:MessageServiceServiceSoapBinding" name="MessageServicePort">
<soap:address location="http://localhost:8080/webservices-0.0.1-SNAPSHOT/MessageService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
目前,我尝试使用Quartz安排Web服务调用, jaxws-client生成soap请求,并通过http传输来调用该服务.
For the moment, I try to use Quartz to schedule the web services calls, jaxws-client to generate the soap request and http transport to call the service.
我使用cxf从wsdl生成客户端代码.
I use cxf to generate the client code from the wsdl.
有人可以给我一些建议吗?
Can someone give me some advices, on how to do it ?
我正在使用最新版本的m子(CE版).
I'm using the latest version of mule (CE version).
在此先感谢您的帮助.
推荐答案
问题是您尚未在event-generator-job
中指定有效负载,因此生成了NullPayload
,这可能会很快停止流(什么都没有)派发).
On issue is that you haven't specified a payload in the event-generator-job
so a NullPayload
is generated, which probably stops the flow pretty quickly (nothing to dispatch).
每个都有event-generator-job
生成用于CXF调用的对象.
Either have event-generator-job
to generate the objects to use for the CXF invocation.
或者,假设MessageWs
转换器的工作是为CXF调用创建有效负载,让event-generator-job
生成一个虚拟有效负载,然后让转换器使用实际有效负载将其清除:
Or, assuming that the MessageWs
transformer's job is to create the payload for the CXF invocation, have event-generator-job
generate a dummy payload and let the transformer wipe it out with the real payload:
<flow name="csvPublisher" doc:name="csvPublisher">
<quartz:inbound-endpoint jobName="job1" repeatInterval="5000" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job>
<quartz:payload>dummy</quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<transformer ref="MessageWs" />
<cxf:jaxws-client operation="getMessages" ...
这篇关于ule子-安排流以使用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!