동일한 입력을하는 경우에는이 작업을 어렵지 않습니다. 이것은 다른 회선에서 각 공급 업체의 결과를 출력합니다
public class Test {
public static void main(String[] args) throws AxisFault,Exception {
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
String [] vendors = {"http://example.com/vendor1/services/GETWeatherHttpSoap12Endpoint", "http://example.com/vendor2/services/GETWeatherHttpSoap12Endpoint"}; // Array of all vendors
for (String vendor : vendors) {
EndpointReference targetEPR = new EndpointReference(vendor);
options.setTo(targetEPR);
QName opGetExchange = new QName("http://ws.apache.org/axis2", "getWeather");
// preparing the parameters
String country = "USA";
Object[] opGetExchangeArgs = new Object[] {country};
// preparing the return type
Class[] returnTypes = new Class[] { String.class };
// invoking the service passing in the arguments and getting the response
Object[] response = serviceClient.invokeBlocking(opGetExchange, opGetExchangeArgs, returnTypes);
// obtaining the data from the response
String result = (String) response[0];
System.out.println("Vendor: " + result);
}
}
}
:
당신이, 축 자바 API를 사용하는 가정, 당신은 뭔가를 할 수 있습니다.
안녕하세요, webservice 중 하나가 실패하면 결과에 어떤 영향이 있습니까? 나머지 결과가 표시되거나 전체 요청이 실패 함을 의미합니까? 다른 벤더가 제공하는 다른 메소드를 호출 할 때 타임 아웃을 사용할 수 있습니까? 그래서 시간이 걸리면 다른 결과를 표시 할 수 있습니까? –
예. 하나의 웹 서비스가 실패하면 예외가 발생합니다. 당신은 특별히 공급 업체를위한 예외를 잡아서 에러 메시지를 표시해야 할 것입니다. 속도를 높이려면 스레드를 사용하여 병렬로 실행하는 것을 고려한 다음 공통 끝점에 결과를 커밋하십시오. –
감사합니다. 스레드를 사용하여 예제를 자세히 작성하십시오. –