有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法从Mule接收HTTP响应

我正在创建一个基本的服务组件,该组件将URL作为http入站端点的输入。mule配置文件中的代码片段如下:

    <service name="follow">
        <inbound>
            <http:inbound-endpoint address="http://localhost:8765/follow/" synchronous="true"/>
        </inbound>
        <component class="org.mule.application.mytwitter.Follow" />
    </service>

从Java组件类调用的函数是:

    public Object onCall(MuleEventContext eventContext) throws Exception {
        MuleMessage msg = eventContext.getMessage();
        String str = msg.getStringProperty("http.request", null);

        msg.setPayload(str);
        msg.setStringProperty("http.status","200");
        msg.setStringProperty("Content-Type","text/html");
        System.out.println("Reached here:" + str);
        return msg;
    }

我希望通过CURL点击服务来接收HTTP响应(有效负载),如下所示:

curl -vv "http://localhost:8765/follow/"

但我没有收到任何有效载荷:

> * About to connect() to localhost port 8765 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8765 (#0)
> GET /follow/ HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: localhost:8765
> Accept: */*
> 
    < HTTP/1.1 200 OK
< Content-Type: text/plain
< Date: Tue, 27 Dec 2011 03:14:00 IST
< Server: Mule Core/2.1.2
< Expires: Tue, 27 Dec 2011 03:14:00 IST
< Content-Length: 0
< Connection: close
< 
* Closing connection #0

我错过什么了吗?正在调用组件类中的函数,并在控制台中打印输出


共 (1) 个答案

  1. # 1 楼答案

    没关系,伙计们。我想出了一个办法,现在效果很好。对于入站端点,有一个名为同步响应的属性。将其设置为true可使其同步工作。我认为Mule 2.1.2或某些系统设置可能存在一些问题