我在cisco CVP环境中工作。我在Netbeans中为GRC webservices创建了一个客户端。我在我的代码中使用该jar文件。首先我遇到的问题是,当我在机器上运行该jar时,它工作得非常好但是当我在CVP容器内加载该jar时它无效。在做了很多搜索后,我发现我必须在CVP tomcat容器中添加几个jar。我在tomcat背书文件夹
中添加了这些jar添加这些jar之后我的问题就解决了。
现在我遇到了另一个问题,我必须在项目中设置连接超时和请求时间。现在再次遇到同样的问题,当我在CVP Tomcat容器之外运行该jar文件时(在窗口cmd上),它工作得非常好,但是当我在CVP Tomcat容器内运行这个jar文件时,它没有反映出来。这是我的代码。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package goldwsclient;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.xml.ws.BindingProvider;
import ma.iam.wsgold.ws.impl.AppBusinessException_Exception;
import ma.iam.wsgold.ws.impl.FidelioDto;
/**
*
* @author Malik
*/
public class GoldWsClient {
final static String REQUEST_TIMEOUT = "com.sun.xml.internal.ws.request.timeout";
final static String CONNECT_TIMEOUT = "com.sun.xml.internal.ws.connect.timeout";
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try {
FidelioDto fd=GoldWsClient.getInfoFidelioByND("234234234234324");
System.out.println(fd.getCodeFidelio()+" This is code");
System.out.println(fd.getQualite()+"This is the qualite");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
public static FidelioDto getInfoFidelioByND(java.lang.String nd) throws AppBusinessException_Exception {
ma.iam.wsgold.ws.impl.FidelioWebServiceImplService service = new ma.iam.wsgold.ws.impl.FidelioWebServiceImplService();
ma.iam.wsgold.ws.impl.FidelioWebServiceImpl port = service.getFidelioWebServiceImplPort();
BindingProvider prov = ((BindingProvider)port);
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
{
@Override
public boolean verify(String hostname, SSLSession session)
{
// ip address of the service URL(like.23.28.244.244)
if (hostname.equals("IP"))
{
return true;
}
return false;
}
});
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "centreAppel_USER");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "azer+654");
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(CONNECT_TIMEOUT, 500);
ctxt.put(REQUEST_TIMEOUT, 500);
return port.getInfoFidelioByND(nd);
}
}