Spring Integration を介して外部 HTTP URL を呼び出していますが、私の URL は Spring コンテキスト ファイルに完全にハードコーディングされています。
したいこと:
- プログラムからクエリ パラメータを渡します (つまり、a=1&b=2&c=3)
- プログラムから URL 自体を渡します ( i.e http://host/port/xyz
)
現在、私の Spring Integration Context ファイルは次のようになっています。
<int:gateway id="requestGateway"
service-interface="com.bingo.RequestGateway"
default-request-channel="requestChannel"/>
<int:channel id="requestChannel"/>
<int-http:outbound-gateway request-channel="requestChannel"
url="http//host:port/xyz?a=1&b=2&c=3"
http-method="GET"
expected-response-type="java.lang.String"/>
これを呼び出す Java コードは次のとおりです。
public static void main(String args[])
{
ApplicationContext context = new ClassPathXmlApplicationContext(
"spring-integr.xml");
RequestGateway requestGateway = context.getBean("requestGateway",
RequestGateway.class);
String reply = requestGateway.sendMyRequest("");
System.out.println("Replied with: " + reply);
}
また:
public interface RequestGateway {
public String sendMyRequest(String request);
}
http://host:port/xyz
プログラムを介して URL( )、特に params(a=1&b=2&c=3) を渡すにはどうすればよいですか?