0
我尝试建立wsdl客户端jre5
与JAX-WS RI 2.1.3
它的我的第一个expirience。我genereted班,wsdl2java
工具从cxf
并写了包装类各地的客户的样子:jaxws异常/错误处理
public class RequestHelper {
private DataLoadService service = new DataLoadService();
private DataLoadServiceSoap client;
private static String token;
//....my constructor....
public void sendData(data){
try{
if (tokenIsExpired()){
renewToken();
}
client.sendData(data, this.token);
}catch(SOAPFaultException e){
//...work with e
}
}
}
我不明白我怎么能在sendData
方法来处理异常。
我的意思是,例如,在HTTP中我们有status codes
,我们可以读取状态码并确定从服务器获得哪种类型的错误以及我们如何处理它们。
在我的情况下,我有令牌过期时间的问题。有时候,sendData
请求会长时间传送到服务器。并且当请求已经在服务器上时,令牌不再有效,然后我收到带有短信“令牌过期”的异常。我想赶上单独这种类型的异常,财产以后这样的:
public class RequestHelper {
private DataLoadService service = new DataLoadService();
private DataLoadServiceSoap client;
private static String token;
//....my constructor....
public void sendData(data){
try{
if (tokenIsExpired()){
renewToken();
}
client.sendData(data, this.token);
}catch(SOAPFaultException e){
//...work with e
}catch(TokenExpiredException e){
renewToken();
client.sendData(data, this.token);
}
}
}
我怎么能与JAX-WS RI 2.1.3
图书馆实现这一目标?
UPD:
} catch (SOAPFaultException e) {
SOAPFault f = e.getFault();
f.getFaultString() //yes here we have error description with "Token"
//but with locals dependency, this is not safe handle exception by this value
f.getFaultCode() //here simply string "soap:Receiver", do not know how i can recognize only "token exceptions"
}
请看到我的更新,我没有访问服务器端代码。谢谢你的建议 – Mrusful