对于休息电话,这有效 -
#include "json.h"
#include <string.h>
#include "jsonStub.h"
struct Namespace namespaces[] = { {NULL, NULL} };
int main()
{
struct soap *ctx = soap_new1(SOAP_XML_NOTYPE);
soap_init(ctx);
struct value *request = new_value(ctx);
struct value response;
ctx->sendfd = 1;
ctx->http_extra_header = "userName:abcd\r\npassword:xyz";
*string_of(value_at(value_at(request, "add"), "i")) = "10";
*string_of(value_at(value_at(request, "add"), "j")) = "20";
json_write(ctx, request);
printf("\n");
if (json_call(ctx, "endpoint",request, &response))
{
printf( "json call failed " );
soap_print_fault(ctx, stderr);
printf("\n%d", ctx->error);
printf("\n1: SOAP faultcode = %s\n", *soap_faultcode(ctx));
printf("2: SOAP faultstring = %s\n", *soap_faultstring(ctx));
printf("3: SOAP faultdetail = %s\n\n", *soap_faultdetail(ctx));
soap_print_fault_location(ctx, stderr);
}
else
{
printf("Success !!!");
json_write(ctx, &response);
}
soap_destroy(ctx);
soap_end(ctx);
soap_free(ctx);
return 0;
}