2016-12-07 3 views
0

iWie Timeout in Web-Service-Anruf festlegen?

bin mit
SimpleWebServiceOutboundGateway 
    simpleGateway.setSendTimeout(1000); 

einen Web-Service zu nennen, aber einige Zeit Web-Service mehr Zeit in Anspruch nimmt Antwort zu geben, und ich will Timeout einstellen, so dass es Fluss beendet werden soll, wenn Reaktion delay.even ist Nach setSendTimeOut wartet es weiter. Wie kann ich Timeout erreichen?

Antwort

1

Zitiert JavaDocs:

/** 
* Set the timeout for sending reply Messages. 
* @param sendTimeout The send timeout. 
*/ 
public void setSendTimeout(long sendTimeout) { 
    this.messagingTemplate.setSendTimeout(sendTimeout); 
} 

als Teil der AbstractMessageProducingHandler und es ist vollständig an bereits eine Nachricht zu senden, um den Ausgangskanal zusammen. Das ist kein Teil der SOAP-Protokoll-Interaktion.

Sie müssen einen Blick auf die Optionen Ihrer speziellen WebServiceMessageSender. Zum Beispiel hat HttpComponentsMessageSender Optionen wie:

/** 
* Sets the timeout until a connection is established. A value of 0 means <em>never</em> timeout. 
* 
* @param timeout the timeout value in milliseconds 
* @see org.apache.http.params.HttpConnectionParams#setConnectionTimeout(org.apache.http.params.HttpParams, int) 
*/ 
public void setConnectionTimeout(int timeout) { 
    if (timeout < 0) { 
     throw new IllegalArgumentException("timeout must be a non-negative value"); 
    } 
    org.apache.http.params.HttpConnectionParams.setConnectionTimeout(getHttpClient().getParams(), timeout); 
} 

/** 
* Set the socket read timeout for the underlying HttpClient. A value of 0 means <em>never</em> timeout. 
* 
* @param timeout the timeout value in milliseconds 
* @see org.apache.http.params.HttpConnectionParams#setSoTimeout(org.apache.http.params.HttpParams, int) 
*/ 
public void setReadTimeout(int timeout) { 
0

durch Konfigurationsdatei,

<int-http:inbound-gateway request-channel="requestData" **reply-timeout="5000"** 
     supported-methods="GET" path="/{oft}/users/{userId}" 
     payload-expression="#pathVariables.userId" reply-channel="responseChannel" > 
     <int-http:header name="outputfile" expression="#pathVariables.oft"/> 
    </int-http:inbound-gateway> 
Verwandte Themen