我是使用 gsoap 的新手。我仅使用 c++ 取得了 4 个小成功,但是受到我当前项目的限制,无法设置源代码生成选项来创建纯 ANSI C(不是 c++)。我似乎无法成功调用该服务,错误返回为 0xC0000005 并给出以下代码片段,任何人都可以就我应该做的不同提出建议:
片段包括
1.客户端函数定义,
2.ns7结构def,
3.简单调用应用程序:
谢谢,
这是客户端调用:
#include "soapH.h"
#include "addressByAccount_ExtWS_BPELSOAP.nsmap"
SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns1__accountsBPEL(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct _ns7__accounts *ns7__accounts, struct _ns9__accountsResponse *ns9__accountsResponse)
{
struct __ns1__accountsBPEL soap_tmp___ns1__accountsBPEL;
if (!soap_endpoint)
soap_endpoint = "http://cctest3-v.physio-control.com:8080/ccx/addressByAccount-ExtWS-BPEL";
if (!soap_action)
soap_action = "http://www.physio-control.com/addressByAccount-ExtWS-BPEL/1.0/accounts";
soap->encodingStyle = NULL;
soap_tmp___ns1__accountsBPEL.ns7__accounts = ns7__accounts;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___ns1__accountsBPEL(soap, &soap_tmp___ns1__accountsBPEL);
if (soap_begin_count(soap))
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__accountsBPEL(soap, &soap_tmp___ns1__accountsBPEL, "-ns1:accountsBPEL", 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_endpoint, soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___ns1__accountsBPEL(soap, &soap_tmp___ns1__accountsBPEL, "-ns1:accountsBPEL", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
if (!ns9__accountsResponse)
return soap_closesock(soap);
soap_default__ns9__accountsResponse(soap, ns9__accountsResponse);
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__ns9__accountsResponse(soap, ns9__accountsResponse, "ns9:accountsResponse", "");
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);
}
这是ns7结构:
struct _ns7__accounts
{
int __sizeaccountNumber; /* sequence of elements <accountNumber> */
char **accountNumber; /* required element of type xsd:string */
char *requestIDTrackingForESB; /* optional attribute of type xsd:string */
};
这是一个使用客户端调用的简单应用程序调用服务:
struct _ns7__accounts in, *pIn;
struct _ns9__accountsResponse out, *pOut;
int main(void)
{
struct soap *soap = soap_new();
//used to populate char ** in pIn
char *pNumber=malloc(sizeof("00000201"));
strcpy(pNumber, "00000201");
pOut = &out;
pIn = ∈
pIn->__sizeaccountNumber = sizeof("00000201");
pIn->accountNumber = &pNumber;
pIn->requestIDTrackingForESB = malloc(sizeof(""));
strcpy(pIn->requestIDTrackingForESB,"");
if (soap_call___ns1__accountsBPEL(soap, "", "", pIn, pOut)== SOAP_OK)
{
printf("Soap OK...");
}
else
{
printf(pIn->requestIDTrackingForESB);
soap_print_fault(soap, stderr);
}
soap_end(soap);
soap_free(soap);
return 0;
}