使用GSOAP 通过HTTPS调用WEBSERVICE失败,请问是何原因呢?
WEBSERIVE是我自己建的,TOMCAT6配置无误,在浏览器里输入http://localhost:9999/webserviceserve和https://localhost:11111/webserviceserve都能够打开,在VS2008中调用其接用其接口,vs各个环境也配置无误。当soap_endpoint = "http://172.20.55.61:9999/webserviceserve/services/HelloWebService"时,调用成功,代码如下:
void CgsoapssltestDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
HelloWebServiceHttpBindingProxy hi;
_ns1__example example;
_ns1__exampleResponse exampleResponse;
CString str;
string str2="helloworld";
example.in0=&str2;
struct soap mysoap;
soap_init(&mysoap);
if(hi.example(&example,&exampleResponse)==SOAP_OK)
{
str=exampleResponse.out->c_str();
MessageBox(str);
}
else[/color]
{
MessageBox(L"failed:" );
}
}
当soap_endpoint = "https://172.20.55.61:11111/webserviceserve/services/HelloWebService"时,调用失败,代码如下:
void CgsoapssltestDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
HelloWebServiceHttpBindingProxy hi;
_ns1__example example;
_ns1__exampleResponse exampleResponse;
CString str;
string str2="helloworld";
example.in0=&str2;
struct soap mysoap;
soap_ssl_init();
soap_init(&mysoap);
和上段不同的地方是加了如下代码
if ( soap_ssl_client_context(&mysoap,
SOAP_SSL_DEFAULT, /* use SOAP_SSL_DEFAULT in production code */
NULL, /* keyfile: required only when client must authenticate to
server (see SSL docs on how to obtain this file) */
NULL, /* password to read the keyfile */
"client.pem",/* optional cacert file to store trusted certificates */
"d:\\", /* optional capath to directory with trusted certificates */
NULL /* if randfile!=NULL: use a file with random data to seed randomness */
))
{
soap_print_fault(&mysoap,stderr);
MessageBox(L"ERROR: failed to set context!");
}
if(hi.example(&example,&exampleResponse)==SOAP_OK)
{
str=exampleResponse.out->c_str();
MessageBox(str);
}
else
{
MessageBox(L"failed:" );
}
}
请问各位高手,如何才能使SSL调用成功呢