2012-07-12 119 views
0

我试图从PLSQL发送一个http请求。它工作正常。发送来自PLSQL的http请求,由Spring Integration接收并答复

HttpRequest := UTL_HTTP.BEGIN_REQUEST (url => v_http_url, METHOD => 'POST'); 
utl_http.set_header(HttpRequest, 'Content-Type', 'text/xml; charset=utf-8'); 
utl_http.set_header(HttpRequest, 'Content-Length', 64); 
utl_http.write_line(HttpRequest, 'some string'); 
Httpresp := utl_http.get_response(HttpRequest); 
utl_http.end_request(HttpRequest); 
utl_http.end_response(Httpresp); 

Spring集成方面:

<int:channel id="inputChannel" /> 
<int:channel id="outputChannel" /> 

<int-http:inbound-gateway request-channel="inputChannel" 
    reply-channel="outputChannel" supported-methods="POST" name="/req" 
    message-converters="MyRequestConverter" 
    request-payload-type="MyRequest"> 
</int-http:inbound-gateway> 

<int:service-activator input-channel="inputChannel" 
    method="getMessage" ref="dbmock"></int:service-activator> 

我创建MyRequestConverter与方法:

MyRequest readInternal(Class<? extends MyRequest > _class, HttpInputMessage message) throws IOException 
void writeInternal(MyRequest request, HttpOutputMessage message) 

我的服务的方法是这样的:

public Object getMessage(@Headers Map<String, Object> headers, @Payload MyRequest payload) 

问题是PLSQL网站呢没有得到回应 - 它无尽的等待。当我评论

Httpresp := utl_http.get_response(HttpRequest) 

PLSQL过程成功执行。此外,我得到了一个例外,那就是java.lang.String没有转换器。

有什么方法可以在反向使用MyRequestConverter?

感谢您的帮助!

+0

我不知道它的问题,但[在DOC给出的实例]的(http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/u_http.htm#i1013177)只有两种'END_RESPONSE'或'END_REQUEST',而不是两者(如果您以前使用过'GET_RESPONSE',则使用'END_RESPONSE')。 – 2012-07-12 08:30:56

+0

我试过只用end_response没有运气。超时发生。 – 2012-07-12 09:26:09

回答

2

您正在将内容长度设置为64,但只发送11个字节。服务器正在等待更多数据。

+0

谢谢!我没有头绪,这很重要。 – 2012-07-12 12:25:23