Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用Hystrix包装SOAP调用(WebServiceGatewaySupport)_Java_Rest_Soap_Hystrix_Circuit Breaker - Fatal编程技术网

Java 用Hystrix包装SOAP调用(WebServiceGatewaySupport)

Java 用Hystrix包装SOAP调用(WebServiceGatewaySupport),java,rest,soap,hystrix,circuit-breaker,Java,Rest,Soap,Hystrix,Circuit Breaker,我试图找到一个将hystrix与SOAP调用结合使用的示例,我所能找到的所有示例都与REST相同 从hystrix文档来看,这似乎是可能的,如果你能给我指出一个有帮助的例子的话 另外,如果有更好的方法在REST和SOAP调用之间建立一致的断路器(可能可扩展到EJB)。您可以通过创建一个扩展HystrixCommand的内部类,然后重写run()方法来实现这一点 公共类webServiceClient扩展了WebServiceGatewaySupport{ 公共响应调用SOAP(请求){ Soap

我试图找到一个将hystrix与SOAP调用结合使用的示例,我所能找到的所有示例都与REST相同

从hystrix文档来看,这似乎是可能的,如果你能给我指出一个有帮助的例子的话


另外,如果有更好的方法在REST和SOAP调用之间建立一致的断路器(可能可扩展到EJB)。

您可以通过创建一个扩展HystrixCommand的内部类,然后重写run()方法来实现这一点

公共类webServiceClient扩展了WebServiceGatewaySupport{
公共响应调用SOAP(请求){
SoapCommand sfc=新的SoapCommand(getWebServiceTemplate(),请求,
soapRequestHeaderModifier,配置);
返回sfc.execute();
}
类SoapCommand扩展了HystrixCommand{
公共SoapCommand(){
super(HystrixCommandGroupKey.Factory.asKey(“示例”);
}
@凌驾
受保护的响应运行(){
返回(响应)webServiceTemplate.marshalSendAndReceive(configuration.getUri(),
请求,soapRequestHeaderModifier);
}
//这里是回退方法
}
}

public class webServiceClient extends WebServiceGatewaySupport {
public Response callsoap(Request request) {
    SoapCommand sfc = new SoapCommand(getWebServiceTemplate(), request, 
            soapRequestHeaderModifier, configuration);
    return  sfc.execute();
}

class SoapCommand extends HystrixCommand<Response>{
    public SoapCommand() {
        super(HystrixCommandGroupKey.Factory.asKey("example"));
    }
    @Override
    protected Response run() {
        return (Response) webServiceTemplate.marshalSendAndReceive(configuration.getUri(), 
                request, soapRequestHeaderModifier);
    }
    //fallback method goes here
}