- 論壇徽章:
- 0
|
最近在用gsoap進(jìn)行web service 客戶端的開(kāi)發(fā),現(xiàn)在使用c進(jìn)行開(kāi)發(fā),連接用java開(kāi)發(fā)的服務(wù)器,現(xiàn)在連接不上,調(diào)試了好久,都還是不行,下面我貼下代碼,牛人給指導(dǎo)一下:
#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;
}
出現(xiàn)如下錯(cuò)誤:
Error 200 fault: SOAP-ENV:Client [no subcode]
"Error 200"
Detail: [no detail]
現(xiàn)在的問(wèn)題:連接不上服務(wù)器 調(diào)用soap_call___ns1__GetDeviceList 傳入的server不同錯(cuò)誤不一樣。
const char server[] = "http://192.168.14.48:8080/megaWS/services/Service?wsdl";
const char server[] = "192.168.14.48:8080";
這兩種全是錯(cuò)誤的
服務(wù)器IP 192.168.14.48 port是8080 以何種方式才能正確連接呢?
|
|