- 论坛徽章:
- 0
|
最近在用gsoap进行web service 客户端的开发,现在使用c进行开发,连接用java开发的服务器,现在连接不上,调试了好久,都还是不行,下面我贴下代码,牛人给指导一下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Service.nsmap"
#include "soapH.h"
#define GROUPID "12"
int get_list (const char *server, struct _ns2__GetDeviceList *send,
struct _ns2__GetDeviceList_Rsp *recv);
int
main (int argc, char **argv)
{
int result;
struct _ns2__GetDeviceList list1;
struct _ns2__GetDeviceList_Rsp list2;
const char server[] = "http://192.168.14.48:8080/megaWS/services/Service?wsdl";
// const char server[] = "192.168.14.48:8181";
list1.WSRequest->GroupId = (char *)malloc(10 * sizeof(char));
if(list1.WSRequest->GroupId == NULL)
{
printf("malloc error\n");
exit(1);
}
printf("-------------------start to connect service server!--------------------\r\n");
memcpy ((list1.WSRequest)->GroupId, GROUPID, 2);
printf("--->Groupid is %s\r\n", list1.WSRequest->GroupId);
result = get_list (server, &list1, &list2);
if (result != 0)
{
printf ("get list error:%d\n", __LINE__);
printf ("soap error, errcode=%d\n", result);
}
else
{
printf ("-->get_list successful!\n");
printf("__sizeDeviceItem is :%d\r\n", list2.DeviceInfo->DeviceList->__sizeDeviceItem);
//list2.ns2__GetDeviceList_Req->DeviceInfo->DeviceList->DeviceItem
printf("DeviceId\t\tName\t\tStatus\t\t\n");
printf("%s\t\t%s\t\t%s\t\t\n",
list2.DeviceInfo->DeviceList->DeviceItem->DeviceId,
list2.DeviceInfo->DeviceList->DeviceItem->Name,
list2.DeviceInfo->DeviceList->DeviceItem->Status);
}
return 0;
}
int
get_list (const char *server, struct _ns2__GetDeviceList *send,
struct _ns2__GetDeviceList_Rsp *recv)
{
int result;
struct soap black_soap;
soap_init (&black_soap);
soap_set_namespaces (&black_soap, namespaces);
printf("--->to call the soap_call___ns1__GetDeviceList\r\n");
if(soap_call___ns1__GetDeviceList (&black_soap, server, NULL, send, recv) == SOAP_OK)
{
printf("soap is ok!\r\n");
}
else
{
soap_print_fault(&black_soap, stderr);
}
soap_call___ns1__GetDeviceList (&black_soap, server, NULL, send, recv);
/* if (black_soap.error)
{
printf ("soap error: %d, %s, %s\n", black_soap.error,
*soap_faultcode (&black_soap), *soap_faultstring (&black_soap));
result = black_soap.error;
}*/
printf("the funtion soap_call___ns1__GetDeviceList is return!\r\n");
soap_end (&black_soap);
soap_done (&black_soap);
return result;
}
出现如下错误:
Error 200 fault: SOAP-ENV:Client [no subcode]
"Error 200"
Detail: [no detail]
现在的问题:连接不上服务器 调用soap_call___ns1__GetDeviceList 传入的server不同错误不一样。
const char server[] = "http://192.168.14.48:8080/megaWS/services/Service?wsdl";
const char server[] = "192.168.14.48:8080";
这两种全是错误的
服务器IP 192.168.14.48 port是8080 以何种方式才能正确连接呢?
|
|