1、在本地起了一个webservice的服务
http://localhost:63081/hello?wsdl
2、在mule创建一个webservice cosumer,用来调用1中的webservice服务。以下是相关配置
<!--外部的ws连接-->
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://localhost:63081/hello?wsdl" service="HelloWorldService" port="HelloWorldPort" serviceAddress="http://localhost:63081/hello" doc:name="Web Service Consumer"/>
<!--mule提供给外部访问的地址-->
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="ws-order" service="TshirtServicePortTypeService" port="TshirtServicePortTypePort" serviceAddress="http://tshirt-service.cloudhub.io/" wsdlLocation="http://tshirt-service.cloudhub.io/?wsdl" doc:name="Web Service Consumer"/>
<!-- 接收HTTP请求,并在Mule内部调用ws服务中具体的方法(传递参数) -->
<flow name="sayHi" >
<http:listener config-ref="HTTP_Listener_Configuration" path="sayHi" doc:name="HTTP">
<http:response-builder statusCode="200"/>
</http:listener>
<custom-transformer class="org.example.ws.proxy.DataTransFormat" doc:name="transformer" mimeType="text/xml"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="sayHi" doc:name="sayHi"/>
<custom-transformer class="org.example.ws.proxy.DataTransFormatForShow" doc:name="transformer" mimeType="application/json"/>
<response>
<echo-component doc:name="Echo"/>
</response>
</flow>
3、直接在浏览器上输入http://localhost:8081/sayHi,返回以下信息
COULD_NOT_READ_XML_STREAM. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor.
4、借用postman请求
返回以下信息
Message part {http://schemas.xmlsoap.org/soap/envelope/}Envelope was not recognized. (Does it exist in service WSDL?).
5、如果借助soapUI工具来请求的话,是会成功返回信息的,证明第1步启动的webservice服务是没有错的
6、在第4中,post的请求参数是确定有传进去的(debug过)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exam="http://example.org/">
<soapenv:Header/>
<soapenv:Body>
<exam:sayHi>
<!--Optional:-->
<arg0>the king in the north</arg0>
</exam:sayHi>
</soapenv:Body>
</soapenv:Envelope>
但是却不知道为何调用webservice失败。请求大神耐心解答。谢谢。
光阴似箭催人老,日月如移越少年。