我是Mule的新手,想做一件“简单”的事情:
My Flow看起来真的像这样:
<?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是:
<?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传输来调用服务。
我使用cxf从wsdl生成客户端代码。
有人可以给我一些建议,如何做到这一点?
我正在使用最新版本的mule(CE版)。
提前感谢您的帮助。
答案 0 :(得分:1)
问题在于您没有在event-generator-job
中指定有效负载,因此生成NullPayload
,这可能会很快停止流程(无需发送)。
要么event-generator-job
生成要用于CXF调用的对象。
或者,假设MessageWs
转换器的工作是为CXF调用创建有效负载,让event-generator-job
生成虚拟有效负载并让变换器用实际有效负载擦除它:
<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" ...
答案 1 :(得分:0)
您还可以使用Mule poll通过配置频率属性来安排流量。这里供您参考: - https://developer.mulesoft.com/docs/display/current/Poll+Reference