如何在mule流中使用Web服务?

时间:2015-05-27 09:51:05

标签: web-services soap cxf mule jax-ws

我开始使用Mule流程。我正在尝试使用web服务。 但是我跑步时遇到了一些错误。

  

XML解析器报告错误:prolog中不允许使用内容

这是我的代码

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8095" doc:name="HTTP Listener Configuration"/>
    <ws:consumer-config name="Web_Service_Consumer" wsdlLocation="MSCRMDiscoveryService_WSDL.wsdl" service="DiscoveryService" port="CustomBinding_IDiscoveryService" serviceAddress="https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc" doc:name="Web Service Consumer"/>
    <data-mapper:config name="Xml_ExecuteResponse__To_Xml_Execute_" transformationGraphPath="xml_executeresponse__to_xml_execute_.grf" doc:name="Xml_ExecuteResponse__To_Xml_Execute_"/>
    <data-mapper:config name="Xml_ExecuteResponse__To_Xml_Execute__1" transformationGraphPath="xml_executeresponse__to_xml_execute__1.grf" doc:name="Xml_ExecuteResponse__To_Xml_Execute__1"/>
    <flow name="mscrmdiscoveryservice-consumerFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="*" doc:name="HTTP"/>
        <data-mapper:transform config-ref="Xml_ExecuteResponse__To_Xml_Execute_" doc:name="Xml&lt;ExecuteResponse&gt; To Xml&lt;Execute&gt;"/>
        <ws:consumer config-ref="Web_Service_Consumer" operation="Execute" doc:name="Web Service Consumer"/>
        <data-mapper:transform config-ref="Xml_ExecuteResponse__To_Xml_Execute__1" doc:name="Xml&lt;ExecuteResponse&gt; To Xml&lt;Execute&gt;"/>
    </flow>
</mule>

wsdl文件

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWorldService" targetNamespace="http://example.org/">
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org/" elementFormDefault="unqualified" targetNamespace="http://example.org/" version="1.0">
<xs:element name="sayHi" type="tns:sayHi"/>
<xs:element name="sayHiResponse" type="tns:sayHiResponse"/>
<xs:complexType name="sayHi">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHiResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="sayHi">
    <wsdl:part element="tns:sayHi" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="sayHiResponse">
    <wsdl:part element="tns:sayHiResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="HelloWorld">
    <wsdl:operation name="sayHi">
      <wsdl:input message="tns:sayHi" name="sayHi">
    </wsdl:input>
      <wsdl:output message="tns:sayHiResponse" name="sayHiResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="HelloWorldServiceSoapBinding" type="tns:HelloWorld">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHi">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="sayHi">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="sayHiResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="HelloWorldService">
    <wsdl:port binding="tns:HelloWorldServiceSoapBinding" name="HelloWorldPort">
      <soap:address location="http://localhost:8085/hello"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

从您分享的流程中,很难确定错误的确切位置...可能是您的XML结构错误。
还不清楚Datamapper在消费外部Web服务中的使用
从Mule流中使用现有Web服务的最简单方法是使用set payload或XSLT转换器为外部服务准备/构建soap请求,然后通过HTTP出站或HTTP请求组件调度它。