简体   繁体   English

gSOAP 错误 400 HTTP 错误请求

[英]gSOAP Error 400 HTTP Bad Request

I am getting an error when i make a call like :当我拨打以下电话时出现错误:

soap_call___ns1__Sumar(soap,NULL,NULL,&oper,&resp)

Error 400 fault al source [no subcode] "HTTP Error: 400 Bad Request" Detail: [no detail]错误 400 错误源[无子代码]“HTTP 错误:400 错误请求”详细信息:[无详细信息]

ASMX Service was published on IIS, on local network at the same PC. ASMX 服务发布在 IIS 上,位于同一台 PC 的本地网络上。 I can consume the service from ac# client without problems but when i try to consume the service via gSOAP client it show the error.我可以毫无问题地从 ac# 客户端使用该服务,但是当我尝试通过 gSOAP 客户端使用该服务时,它会显示错误。

Im using gSOAP 2.8.29, i think there was no problem building the files with wsdl2h and soapcpp2 tools.我使用 gSOAP 2.8.29,我认为使用 wsdl2h 和 soapcpp2 工具构建文件没有问题。 Here is my code.这是我的代码。

Please, if someone know the cause of this error help me.请,如果有人知道此错误的原因,请帮助我。 Thanks all.谢谢大家。

gSOAP Client gSOAP客户端

#include "stdio.h"

#include "WCdataSoap.nsmap" 
#include "soapH.h" 

int main()
{
  struct soap *soap = soap_new(); 
  struct _ns1__SumarResponse sum;
  struct _ns1__Sumar oper;
  oper.a = 2;
  oper.b = 2;
  printf("a = %d\n", oper.a);
  printf("b = %d\n", oper.b);

  if (soap_call___ns1__Sumar(soap, NULL, NULL, &oper, &sum) == SOAP_OK)
    printf("Sum = %d\n", sum);
  else
    soap_print_fault(soap, stderr);

  soap_destroy(soap); 
  soap_end(soap); 
  soap_free(soap); 

}

soapClientC.c肥皂客户端C.c

#if defined(__BORLANDC__)
#pragma option push -w-8060
#pragma option push -w-8004
#endif
#include "soapH.h"
#ifdef __cplusplus
extern "C" {
#endif

SOAP_SOURCE_STAMP("@(#) soapClient.c ver 2.8.29 2016-04-20 02:44:39 GMT")


SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns1__Sumar(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct _ns1__Sumar *ns1__Sumar, struct _ns1__SumarResponse *ns1__SumarResponse)
{   struct __ns1__Sumar soap_tmp___ns1__Sumar;
    if (soap_endpoint == NULL)
        soap_endpoint = "http://localhost/MyService/WCdata.asmx";
    if (soap_action == NULL)
        soap_action = "http://localhost/MyService/Sumar";
    soap_tmp___ns1__Sumar.ns1__Sumar = ns1__Sumar;
    soap_begin(soap);
    soap->encodingStyle = NULL;
    soap_serializeheader(soap);
    soap_serialize___ns1__Sumar(soap, &soap_tmp___ns1__Sumar);
    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__Sumar(soap, &soap_tmp___ns1__Sumar, "-ns1:Sumar", 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__Sumar(soap, &soap_tmp___ns1__Sumar, "-ns1:Sumar", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap)
     || soap_end_send(soap))
        return soap_closesock(soap);
    if (!ns1__SumarResponse)
        return soap_closesock(soap);
    soap_default__ns1__SumarResponse(soap, ns1__SumarResponse);
    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__SumarResponse(soap, ns1__SumarResponse, "ns1:SumarResponse", 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);
}

#ifdef __cplusplus
}
#endif

#if defined(__BORLANDC__)
#pragma option pop
#pragma option pop
#endif

soapH.h肥皂H.h

#ifndef soapH_H
#define soapH_H
#include "soapStub.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WITH_NOIDREF
SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
#endif
SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);

SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap);

#ifndef SOAP_TYPE_byte_DEFINED
#define SOAP_TYPE_byte_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);

#ifndef soap_write_byte
#define soap_write_byte(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || soap_put_byte(soap, data, "byte", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);

#ifndef soap_read_byte
#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !soap_get_byte(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef SOAP_TYPE_int_DEFINED
#define SOAP_TYPE_int_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);

#ifndef soap_write_int
#define soap_write_int(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || soap_put_int(soap, data, "int", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);

#ifndef soap_read_int
#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !soap_get_int(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_SOAP_ENV__Fault_DEFINED
#define SOAP_TYPE_SOAP_ENV__Fault_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);

#ifndef soap_write_SOAP_ENV__Fault
#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Fault(soap, data), 0) || soap_put_SOAP_ENV__Fault(soap, data, "SOAP-ENV:Fault", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);

#ifndef soap_read_SOAP_ENV__Fault
#define soap_read_SOAP_ENV__Fault(soap, data) ( ((data) ? (soap_default_SOAP_ENV__Fault(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get_SOAP_ENV__Fault(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_SOAP_ENV__Reason_DEFINED
#define SOAP_TYPE_SOAP_ENV__Reason_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);

#ifndef soap_write_SOAP_ENV__Reason
#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Reason(soap, data), 0) || soap_put_SOAP_ENV__Reason(soap, data, "SOAP-ENV:Reason", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);

#ifndef soap_read_SOAP_ENV__Reason
#define soap_read_SOAP_ENV__Reason(soap, data) ( ((data) ? (soap_default_SOAP_ENV__Reason(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get_SOAP_ENV__Reason(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_SOAP_ENV__Detail_DEFINED
#define SOAP_TYPE_SOAP_ENV__Detail_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);

#ifndef soap_write_SOAP_ENV__Detail
#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Detail(soap, data), 0) || soap_put_SOAP_ENV__Detail(soap, data, "SOAP-ENV:Detail", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);

#ifndef soap_read_SOAP_ENV__Detail
#define soap_read_SOAP_ENV__Detail(soap, data) ( ((data) ? (soap_default_SOAP_ENV__Detail(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get_SOAP_ENV__Detail(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_SOAP_ENV__Code_DEFINED
#define SOAP_TYPE_SOAP_ENV__Code_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);

#ifndef soap_write_SOAP_ENV__Code
#define soap_write_SOAP_ENV__Code(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Code(soap, data), 0) || soap_put_SOAP_ENV__Code(soap, data, "SOAP-ENV:Code", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);

#ifndef soap_read_SOAP_ENV__Code
#define soap_read_SOAP_ENV__Code(soap, data) ( ((data) ? (soap_default_SOAP_ENV__Code(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get_SOAP_ENV__Code(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_SOAP_ENV__Header_DEFINED
#define SOAP_TYPE_SOAP_ENV__Header_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);

#ifndef soap_write_SOAP_ENV__Header
#define soap_write_SOAP_ENV__Header(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Header(soap, data), 0) || soap_put_SOAP_ENV__Header(soap, data, "SOAP-ENV:Header", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);

#ifndef soap_read_SOAP_ENV__Header
#define soap_read_SOAP_ENV__Header(soap, data) ( ((data) ? (soap_default_SOAP_ENV__Header(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get_SOAP_ENV__Header(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#endif

#ifndef SOAP_TYPE___ns1__Sumar_DEFINED
#define SOAP_TYPE___ns1__Sumar_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default___ns1__Sumar(struct soap*, struct __ns1__Sumar *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize___ns1__Sumar(struct soap*, const struct __ns1__Sumar *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out___ns1__Sumar(struct soap*, const char*, int, const struct __ns1__Sumar *, const char*);
SOAP_FMAC3 struct __ns1__Sumar * SOAP_FMAC4 soap_in___ns1__Sumar(struct soap*, const char*, struct __ns1__Sumar *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put___ns1__Sumar(struct soap*, const struct __ns1__Sumar *, const char*, const char*);

#ifndef soap_write___ns1__Sumar
#define soap_write___ns1__Sumar(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize___ns1__Sumar(soap, data), 0) || soap_put___ns1__Sumar(soap, data, "-ns1:Sumar", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct __ns1__Sumar * SOAP_FMAC4 soap_get___ns1__Sumar(struct soap*, struct __ns1__Sumar *, const char*, const char*);

#ifndef soap_read___ns1__Sumar
#define soap_read___ns1__Sumar(soap, data) ( ((data) ? (soap_default___ns1__Sumar(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get___ns1__Sumar(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef SOAP_TYPE__ns1__SumarResponse_DEFINED
#define SOAP_TYPE__ns1__SumarResponse_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default__ns1__SumarResponse(struct soap*, struct _ns1__SumarResponse *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__ns1__SumarResponse(struct soap*, const struct _ns1__SumarResponse *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns1__SumarResponse(struct soap*, const char*, int, const struct _ns1__SumarResponse *, const char*);
SOAP_FMAC3 struct _ns1__SumarResponse * SOAP_FMAC4 soap_in__ns1__SumarResponse(struct soap*, const char*, struct _ns1__SumarResponse *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put__ns1__SumarResponse(struct soap*, const struct _ns1__SumarResponse *, const char*, const char*);

#ifndef soap_write__ns1__SumarResponse
#define soap_write__ns1__SumarResponse(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize__ns1__SumarResponse(soap, data), 0) || soap_put__ns1__SumarResponse(soap, data, "ns1:SumarResponse", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct _ns1__SumarResponse * SOAP_FMAC4 soap_get__ns1__SumarResponse(struct soap*, struct _ns1__SumarResponse *, const char*, const char*);

#ifndef soap_read__ns1__SumarResponse
#define soap_read__ns1__SumarResponse(soap, data) ( ((data) ? (soap_default__ns1__SumarResponse(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get__ns1__SumarResponse(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef SOAP_TYPE__ns1__Sumar_DEFINED
#define SOAP_TYPE__ns1__Sumar_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default__ns1__Sumar(struct soap*, struct _ns1__Sumar *);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__ns1__Sumar(struct soap*, const struct _ns1__Sumar *);
SOAP_FMAC3 int SOAP_FMAC4 soap_out__ns1__Sumar(struct soap*, const char*, int, const struct _ns1__Sumar *, const char*);
SOAP_FMAC3 struct _ns1__Sumar * SOAP_FMAC4 soap_in__ns1__Sumar(struct soap*, const char*, struct _ns1__Sumar *, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put__ns1__Sumar(struct soap*, const struct _ns1__Sumar *, const char*, const char*);

#ifndef soap_write__ns1__Sumar
#define soap_write__ns1__Sumar(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize__ns1__Sumar(soap, data), 0) || soap_put__ns1__Sumar(soap, data, "ns1:Sumar", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 struct _ns1__Sumar * SOAP_FMAC4 soap_get__ns1__Sumar(struct soap*, struct _ns1__Sumar *, const char*, const char*);

#ifndef soap_read__ns1__Sumar
#define soap_read__ns1__Sumar(soap, data) ( ((data) ? (soap_default__ns1__Sumar(soap, (data)), 0) : 0) || soap_begin_recv(soap) || !soap_get__ns1__Sumar(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason_DEFINED
#define SOAP_TYPE_PointerToSOAP_ENV__Reason_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail_DEFINED
#define SOAP_TYPE_PointerToSOAP_ENV__Detail_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
#endif

#endif

#ifndef WITH_NOGLOBAL

#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code_DEFINED
#define SOAP_TYPE_PointerToSOAP_ENV__Code_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
#endif

#endif

#ifndef SOAP_TYPE_PointerTo_ns1__SumarResponse_DEFINED
#define SOAP_TYPE_PointerTo_ns1__SumarResponse_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns1__SumarResponse(struct soap*, struct _ns1__SumarResponse *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns1__SumarResponse(struct soap*, const char *, int, struct _ns1__SumarResponse *const*, const char *);
SOAP_FMAC3 struct _ns1__SumarResponse ** SOAP_FMAC4 soap_in_PointerTo_ns1__SumarResponse(struct soap*, const char*, struct _ns1__SumarResponse **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns1__SumarResponse(struct soap*, struct _ns1__SumarResponse *const*, const char*, const char*);
SOAP_FMAC3 struct _ns1__SumarResponse ** SOAP_FMAC4 soap_get_PointerTo_ns1__SumarResponse(struct soap*, struct _ns1__SumarResponse **, const char*, const char*);
#endif

#ifndef SOAP_TYPE_PointerTo_ns1__Sumar_DEFINED
#define SOAP_TYPE_PointerTo_ns1__Sumar_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTo_ns1__Sumar(struct soap*, struct _ns1__Sumar *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTo_ns1__Sumar(struct soap*, const char *, int, struct _ns1__Sumar *const*, const char *);
SOAP_FMAC3 struct _ns1__Sumar ** SOAP_FMAC4 soap_in_PointerTo_ns1__Sumar(struct soap*, const char*, struct _ns1__Sumar **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTo_ns1__Sumar(struct soap*, struct _ns1__Sumar *const*, const char*, const char*);
SOAP_FMAC3 struct _ns1__Sumar ** SOAP_FMAC4 soap_get_PointerTo_ns1__Sumar(struct soap*, struct _ns1__Sumar **, const char*, const char*);
#endif

#ifndef SOAP_TYPE__XML_DEFINED
#define SOAP_TYPE__XML_DEFINED
#endif

#ifndef SOAP_TYPE__QName_DEFINED
#define SOAP_TYPE__QName_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default__QName(struct soap*, char **);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__QName(struct soap*, char *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);

#ifndef soap_write__QName
#define soap_write__QName(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || soap_put__QName(soap, data, "QName", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);

#ifndef soap_read__QName
#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !soap_get__QName(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifndef SOAP_TYPE_string_DEFINED
#define SOAP_TYPE_string_DEFINED
SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);

#ifndef soap_write_string
#define soap_write_string(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || soap_put_string(soap, data, "string", NULL) || soap_end_send(soap), (soap)->error )
#endif

SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);

#ifndef soap_read_string
#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !soap_get_string(soap, (data), NULL, NULL) || soap_end_recv(soap), (soap)->error )
#endif

#endif

#ifdef __cplusplus
}
#endif

#endif

And Finally my ASMX file最后是我的 ASMX 文件

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace MyService
{
    /// <summary>
    /// Summary description for WCdata
    /// </summary>
    [WebService(Namespace = "http://localhost/MyService/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WCdata : System.Web.Services.WebService
    {

        [WebMethod]
        public int Sumar(int a, int b)
        {
            return (a + b);
        }
    }
}

Finally i solve the problem.最后我解决了这个问题。 There was some things that i had to do and i explain it now.有些事情我必须做,我现在解释一下。

Before start the post sorry if my english is not perfect.在开始这篇文章之前,如果我的英语不完美,请见谅。

First of all, you must take care of the compiler you are using.首先,您必须注意您正在使用的编译器。 There is some problems with compilers and you should try to have only one installed in your SO and set in Global Path Variable.编译器存在一些问题,您应该尝试只在 SO 中安装一个并在全局路径变量中设置。

Maybe you should have to turn off your firewall and stop to use some proxys if you are using one in order to discard this possible error.也许您应该关闭防火墙并停止使用某些代理(如果您正在使用代理)以放弃这个可能的错误。

Then please make sure that all the generate files process with gsoap tools (wsdl2h, soapcpp2) be ok.然后请确保所有使用 gsoap 工具(wsdl2h、soapcpp2)生成的文件都正常。

If you done all the steps and you have the error:如果您完成了所有步骤并且出现错误:

"stdsoap2.c undefined reference to wctomb_s" “stdsoap2.c 未定义对 wctomb_s 的引用”

you have to edit the stdsoap2.c file at line 12626 and 12839, comment the code你必须在第 12626 和 12839 行编辑 stdsoap2.c 文件,注释代码

    //m = 0;
    //wctomb_s(&m, buf, sizeof(buf), (wchar_t)(c & 0x7FFFFFFF));

and add the line code并添加行代码

m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF));

result :结果 :

m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF));
//m = 0;
//wctomb_s(&m, buf, sizeof(buf), (wchar_t)(c & 0x7FFFFFFF));

Then you should'nt have more problems and the second part is in the case you get error 415.那么你不应该有更多的问题,第二部分是在你收到错误 415 的情况下。

If you have error 415, is a conflict error between comunicate client - server so you must be sure if the client side request and server side receive, client side receive and server side response are using the same SOAP protocol version (1.1, 1.2) so you maybe need to change your SOAP namespaces file "xxxxxx.nsmap".如果出现错误 415,则是客户端与服务器之间的通信冲突错误,因此您必须确定客户端请求和服务器端接收、客户端接收和服务器端响应是否使用相同的 SOAP 协议版本(1.1、1.2)所以您可能需要更改 SOAP 名称空间文件“xxxxxx.nsmap”。

SOAP_NMAC struct Namespace namespaces[] = {
        {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/2003/05/soap-envelope", NULL},
        {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/2003/05/soap-encoding", NULL},
        {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
        {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
        {"arr", "http://schemas.microsoft.com/2003/10/Serialization/Arrays", NULL, NULL},
        {"tempuri", "http://tempuri.org/", NULL, NULL},
        {NULL, NULL, NULL, NULL}
    };

look this namespace equals to soap 1.1看这个命名空间等于soap 1.1

"http://schemas.xmlsoap.org/soap/envelope/"
"http://schemas.xmlsoap.org/soap/encoding/"

the other one equals to soap 1.2另一个等于肥皂 1.2

"http://www.w3.org/2003/05/soap-envelope"
"http://www.w3.org/2001/XMLSchema-instance"

to resolve the error 415, u should have to change de order of the namespaces or change the gsoap files compile mode using de -1 command to force use 1.1 version.要解决错误 415,您必须更改命名空间的顺序或使用 de -1 命令更改 gsoap 文件编译模式以强制使用 1.1 版本。 Like this example:像这个例子:

soapcpp2 -CL -I(gsoap /Import path) -1 (file generated wsdl2h).h 

Thats all, after all steps you should finally can consume your service method without problems.就是这样,在所有步骤之后,您应该最终可以毫无问题地使用您的服务方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 POST返回Http 400错误请求 - POST returns Http 400 Bad request DynamoDB Local抛出了http 400错误请求 - DynamoDB Local throws http 400 bad request 将文件发送到WCF时出错:请求失败,HTTP状态为400:错误的请求 - Error while sending file to WCF: The request failed with HTTP status 400: Bad Request Http Web请求远程服务器返回错误:(400)错误的请求。 Twitter时间轴 - Http web request The remote server returned an error: (400) Bad Request. twitter timeline 使用FileUpload控件上传视频文件时,出现类似HTTP错误400的错误-错误的请求 - While uploading an video file using FileUpload control it is giving an error like HTTP Error 400 - Bad Request 尝试将Web引用添加到WCF服务时出现HTTP 400 Bad Request错误 - HTTP 400 Bad Request error attempting to add web reference to WCF Service 大型 WCF Web 服务请求因 (400) HTTP 错误请求而失败 - Large WCF web service request failing with (400) HTTP Bad Request 带有Google数据API的OAuth(.NET)返回HTTP 400:错误的请求 - OAuth with Google data API for .NET returning HTTP 400: Bad Request .NET中使用OpenTSDB HTTP API:400错误请求 - using OpenTSDB HTTP api in .NET : 400 Bad Request .net WCF获取HTTPS 400错误请求但可以正常使用Http - .net WCF GET HTTPS 400 Bad Request but works fine with Http
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM