在Mule Flows中使用SOAP配置HTTP端点 [英] Configuring HTTP endpoint with SOAP in Mule Flows

查看:60
本文介绍了在Mule Flows中使用SOAP配置HTTP端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to configure an existing SOAP web service in Mule using Mule Flows. I have an HTTP endpoint with request/response and a SOAP component, say Service A.

我想配置此设置,以简化工作流程.我已经设置了HTTP端点和SOAP服务.流程文件如下所示.

I want to configure this setup for a simple flow to work. I have set my HTTP endpoint and the SOAP service. The flow file is shown below.

    <?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>

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

This is not working. My service is a simple one and it takes in a string and returns a string.

@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入站URL http://localhost:8081/ {我不是确定会发生什么!},然后得到:

I am invoking my flow with the HTTP inbound URL http://localhost:8081/{I am not sure what goes here!} and getting:

<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中的应用程序运行,并且该服务作为Springsource toolsuite中的SOAP Web服务运行.

The Mule flow is running as an application in Mule Studio, and the service is running as a SOAP web service from Springsource toolsuite.

我在做什么错了?

位于 http://localhost:8080/ServiceA/services/ServiceAImplPort?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 toolsuite运行Web服务,而不会出现问题.现在,如何使用GET请求从HTTP入站URL调用Web服务? [我认为像这样的简单Web服务都会接受GET请求.]

FYI, I can run the web service from SpringSource toolsuite without issues. Now, how do I invoke the web service from my HTTP inbound URL with a GET request? [I presume simple web services like these take GET requests.]

推荐答案

我认为您忘记了方法中的@WebMethod批注.这基本上就是您的错误所表达的:无操作.

I think you forgot the @WebMethod annotation at your method. This is basically what your error says: No operation.

此处是一个很好的例子,您如何做到这一点.

Here is a very good example how you can do it.

@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;
    }
}

这篇关于在Mule Flows中使用SOAP配置HTTP端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆