在Mule Flows中使用SOAP配置HTTP端点

时间:2012-04-06 06:49:11

标签: soap cxf mule

我正在尝试使用Mule Flows在Mule中配置现有的SOAP Web服务。我有一个带有请求/响应的HTTP端点和一个SOAP组件,比如服务A.

Simple SOAP flow 我想配置此设置以使简单的流程起作用。我已经设置了我的HTTP端点和SOAP服务。流程文件如下所示。

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

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <flow name="demoflowFlow1" doc:name="demoflowFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <cxf:jaxws-service port="8082" serviceClass="com.myapp.serviceA.ServiceAImplService" doc:name="SOAP"/>
    </flow>
</mule>

这不起作用。我的服务很简单,它接受一个字符串并返回一个字符串。

@WebService(targetNamespace = "http://service.demo.myapp.com/", endpointInterface = "com.myapp.demo.service.IServiceA", portName = "ServiceAImplPort", serviceName = "ServiceAImplService")
public class ServiceAImpl implements IServiceA {
    public String hello(String user) {
        return "at service A: " + user;
    }
}

我正在使用HTTP入站网址http://localhost:8081/调用我的流程{我不确定这里会发生什么!}并获取:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>No such operation: (HTTP GET PATH_INFO: /)</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

Mule流作为Mule Studio中的应用程序运行,该服务作为Springource工具套件的SOAP Web服务运行。

我做错了什么?

http://localhost:8080/ServiceA/services/ServiceAImplPort?wsdl

的原始WSDL
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ServiceAImplService" targetNamespace="http://service.demo.myapp.com/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://service.demo.myapp.com/" schemaLocation="http://localhost:8080/ServiceA/services/ServiceAImplPort?xsd=serviceaimpl_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="helloResponse">
<wsdl:part element="tns:helloResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="hello">
<wsdl:part element="tns:hello" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="IServiceA">
<wsdl:operation name="hello">
<wsdl:input message="tns:hello" name="hello"></wsdl:input>
<wsdl:output message="tns:helloResponse" name="helloResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceAImplServiceSoapBinding" type="tns:IServiceA">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="hello">
<soap:operation soapAction="urn:Hello" style="document"/>
<wsdl:input name="hello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="helloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServiceAImplService">
<wsdl:port binding="tns:ServiceAImplServiceSoapBinding" name="ServiceAImplPort">
<soap:address location="http://localhost:8080/ServiceA/services/ServiceAImplPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

仅供参考,我可以毫无问题地从SpringSource工具套件运行Web服务。现在,如何使用GET请求从HTTP入站URL调用Web服务? [我假设像这样的简单Web服务需要GET请求。]

2 个答案:

答案 0 :(得分:2)

我认为您忘记了方法中的@WebMethod注释。这基本上就是你的错误所说的:没有操作。

Here是一个很好的例子,你可以做到这一点。

@WebService(targetNamespace = "http://service.demo.myapp.com/", endpointInterface = "com.myapp.demo.service.IServiceA", portName = "ServiceAImplPort", serviceName = "ServiceAImplService")
public class ServiceAImpl implements IServiceA {
    @WebMethod
    @WebResult(name="result")
    public String hello(@WebParam(name="user")String user) {
        return "at service A: " + user;
    }
}

答案 1 :(得分:0)

这很容易......我猜com.myapp.serviceA.ServiceAImplService是你的服务实现类,而IServiceA.java是你的服务类...为什么不试试这个: -

Mule Config

你的wsdl有什么问题....为什么&lt; wsdl:service name =“ServiceAImplService”&gt; ServiceAImplService ...而应该是 IServiceA .... ServiceAImplService 是我猜的Web服务实现类,应该保持在mule flow中