我有这个小代码
serviceName = new javax.xml.namespace.QName(uri,routine);
portName = new javax.xml.namespace.QName(uri,port);
try{
url = new java.net.URL(wsdlURL);
}
catch(java.net.MalformedURLException muwe){
muwe.printStackTrace();
}
java.net.Authenticator.setDefault(new java.net.Authenticator() {
@Override
protected java.net.PasswordAuthentication getPasswordAuthentication() {
return new java.net.PasswordAuthentication(
user,
pwd.toCharArray());
}
});
service = javax.xml.ws.Service.create(url,serviceName);
request="";
request+="<?xml version='1.0' encoding='UTF-8' standalone='no'?>";
request+=......//xml request
dispatch = service.createDispatch(portName,javax.xml.soap.SOAPMessage.class,javax.xml.ws.Service.Mode.MESSAGE);
content = new java.io.StringReader(request);
input = new javax.xml.transform.stream.StreamSource(content);
message = javax.xml.soap.MessageFactory.newInstance(javax.xml.soap.SOAPConstants.SOAP_1_1_PROTOCOL).createMessage();
message.getSOAPPart().setContent(input);
headers = message.getMimeHeaders();
headers.addHeader("SOAPAction",soap_azione);
message.saveChanges();
response = dispatch.invoke(message);
但我没有找到一种方法来拉HTTPConduit
来设置正确的超时。
我已经尝试过:
dispatch.getRequestContext().put("javax.xml.ws.client.receiveTimeout", rectime);
dispatch.getRequestContext().put("javax.xml.ws.client.connectionTimeout", conntime);
这个:
dispatch.getRequestContext().put("com.sun.xml.internal.ws.request.timeout", rectime);
dispatch.getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", conntime);
和最后一个:
dispatch.getRequestContext().put("com.sun.xml.ws.request.timeout", rectime);
dispatch.getRequestContext().put("com.sun.xml.ws.connect.timeout", conntime);
但我没有得到理想的行为。
如何从之前的代码中获取HTTPConduit
?
在示例中总是有一个接口,但我的请求没有这种形状。
谢谢。
最诚挚的问候。