cbbbing 2018-12-06 02:13 采纳率: 0%
浏览 1909

javax.xml.ws.Service如何设置超时时间

javax.xml.ws.Service如何设置超时时间?

创建GeneralWeb实力的时候直接进行服务连接
有时候服务器没有响应了,程序就吊在这里没有响应

我需要设置连接超时时间和请求数据超时时间,请问如何设置?

 @WebServiceClient(name = "GeneralWeb", targetNamespace = "xxx", wsdlLocation = "xxx.wsdl")
public class GeneralWeb
extends Service
{

private final static URL GENERALWEB_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.goodcol.webservice.oa.GeneralWeb.class.getName());

static {
    URL url = null;
    try {
        URL baseUrl;
        baseUrl = com.goodcol.webservice.oa.GeneralWeb.class.getResource(".");
        //url = new URL(baseUrl, "http://10.100.201.125:7003/defaultroot/xfservices/GeneralWeb?wsdl");
        url = new URL(baseUrl, PropertiesContent.get("pcoaurl"));
    } catch (MalformedURLException e) {
        logger.warning("Failed to create URL for the wsdl Location: "+PropertiesContent.get("pcoaurl")+", retrying as a local file");
        logger.warning(e.getMessage());
    }
    GENERALWEB_WSDL_LOCATION = url;
}

public GeneralWeb(URL wsdlLocation, QName serviceName) {
    super(wsdlLocation, serviceName);
}

public GeneralWeb() {
    super(GENERALWEB_WSDL_LOCATION, new QName("http://com.whir.service/GeneralWeb", "GeneralWeb"));
}

@WebEndpoint(name  = "GeneralWebHttpPort")
public GeneralWebPortType getGeneralWebHttpPort() {
    return super.getPort(new QName("http://com.whir.service/GeneralWeb", "GeneralWebHttpPort"),     GeneralWebPortType.class);
}

 @WebEndpoint(name = "GeneralWebHttpPort")
public GeneralWebPortType getGeneralWebHttpPort(WebServiceFeature... features) {
    return super.getPort(new QName("http://com.whir.service/GeneralWeb", "GeneralWebHttpPort"), GeneralWebPortType.class, features);
}

}
求大神指点。。。。

  • 写回答

1条回答 默认 最新

  • ainiburuqusi 2018-12-06 03:43
    关注

    可以使用URLConnection的setSoTimeout,具体得可以参考:
    https://blog.csdn.net/samyang1/article/details/79309223
    类似的解决百度多的是。

    评论

报告相同问题?

悬赏问题

  • ¥20 C# TCP服务端,客户端退出后,不断有数据进来
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?