我是 Mule 的新手,想做一件“简单”的事情:
- 每 X 秒调用一次soap webservice 操作并将结果存储在一个文件中。
我的 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 版本)。
提前感谢您的帮助。