C++调用webservice问题
//保存xml形式的字符串
char *psXML=NULL; // 用来保存xml的字符串,可以放到函数参数里传递出去
TiXmlPrinter printer;
xmlDocument->Accept(&printer);
psXML = new char[512];
memset(psXML,0x0,sizeof(psXML));
memcpy(psXML,printer.CStr(),printer.Size());
psXML[printer.Size()] = '\0';
soap_init1(soap, SOAP_IO_KEEPALIVE);
input=(_ns1__ZYST02_USCOREIFS002*)malloc(sizeof(_ns1__ZYST02_USCOREIFS002)+1);
input -> IS_USCOREINPUT = (ns1__ZSYST02_USCOREIFS002_USCOREIN *)psXML;
printf("工艺规程传输的参数为:\n");
printf("IS_USCOREINPUT=%s\n",input->IS_USCOREINPUT);
printf("以上工艺规程传输的参数为!\n");
printf("webservice地址为:!%s\n",webservice);
////调用服务
if(soap_call___ns1__ZYST02_USCOREIFS002(soap,NULL,"",input,&result)==SOAP_OK)//一到调用就报错
{
char sapid [255];
char itemid [255];
char* fh_item_id = NULL;
tag_t* fh_item_tag = NULLTAG;
char* fh_type_name = NULL;
writeXML( log_file, (const char *)result.ES_USCOREOUTPUT);
printf("SAP返回值为:%s\n", result.ES_USCOREOUTPUT);
}
else
{
writeXML( log_file, "调用SAPWebService接口失败!");
printf("调用SAPWebService接口失败");
}
我跟踪了下这个调用方法:
SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns1__ZYST02_USCOREIFS002(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct _ns1__ZYST02_USCOREIFS002 *ns1__ZYST02_USCOREIFS002, struct _ns1__ZYST02_USCOREIFS002Response *ns1__ZYST02_USCOREIFS002Response)
{ struct __ns1__ZYST02_USCOREIFS002 soap_tmp___ns1__ZYST02_USCOREIFS002;
printf("1:\n");
if (soap_endpoint == NULL)
soap_endpoint = "http://sapdev01.stfm.com:8010/sap/bc/srt/rfc/sap/zyst02_ifs002/200/zyst02_ifs002/lp01";
if (soap_action == NULL)
soap_action = "urn:sap-com:document:sap:rfc:functions:ZYST02_IFS002:ZYST02_IFS002Request";
printf("2:\n");
soap_begin(soap);
printf("3:\n");
soap->encodingStyle = NULL;
printf("4:\n");
soap_tmp___ns1__ZYST02_USCOREIFS002.ns1__ZYST02_USCOREIFS002 = ns1__ZYST02_USCOREIFS002;
printf("5:\n");
soap_serializeheader(soap);//这句报错!
printf("6:\n");
soap_serialize___ns1__ZYST02_USCOREIFS002(soap, &soap_tmp___ns1__ZYST02_USCOREIFS002);
printf("7:\n");
if (soap_begin_count(soap))
printf("8:\n");
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___ns1__ZYST02_USCOREIFS002(soap, &soap_tmp___ns1__ZYST02_USCOREIFS002, "-ns1:ZYST02_IFS002", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_url(soap, soap_endpoint, NULL), soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___ns1__ZYST02_USCOREIFS002(soap, &soap_tmp___ns1__ZYST02_USCOREIFS002, "-ns1:ZYST02_IFS002", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
if (!ns1__ZYST02_USCOREIFS002Response)
return soap_closesock(soap);
soap_default__ns1__ZYST02_USCOREIFS002Response(soap, ns1__ZYST02_USCOREIFS002Response);
if (soap_begin_recv(soap)
|| soap_envelope_begin_in(soap)
|| soap_recv_header(soap)
|| soap_body_begin_in(soap))
return soap_closesock(soap);
soap_get__ns1__ZYST02_USCOREIFS002Response(soap, ns1__ZYST02_USCOREIFS002Response, "ns1:ZYST02_IFS002Response", NULL);
if (soap->error)
return soap_recv_fault(soap, 0);
if (soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
return soap_closesock(soap);
return soap_closesock(soap);
}
由于是在别的软件上做的二次开发,无法获取错误信息。