SOAPpy Error

今天准备用SOAPpy来写一个最简单的soap client,代码如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from SOAPpy import WSDL
WSDLfile = "/path/to/webservice"

wsdlObject = WSDL.Proxy(WSDLfile)

print 'Available methods:'
for method in wsdlObject.methods.keys() :
    print method
    ci = wsdlObject.methods[method]
    # you can also use ci.inparams
    for param in ci.outparams :
        # list of the function and type 
        # depending of the wsdl...
        print param.name.ljust(20) , param.type
    print

运行的时候出现了这个问题:

gsoap Error 500

解决了Error 200之后又遇到了Error 500:

Error 500 fault: SOAP-ENV:Server[no subcode]

通过tcpdump分析得到,gsoap强制加入了一个SOAP-ENV:mustUnderstand=“1"属性,而web service方不能解析该属性。

解决办法,

1
2
// set mustUnderstand to 0
soap.mustUnderstand=0;

修改soapC.cpp, 注释掉soap->mustUnderstand=1这一行:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
{
  (void)soap; (void)tag; (void)id; (void)type;
  if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type))
    return soap->error;
  //soap->mustUnderstand = 1;
  if (soap_out_PointerTons1__AuthenticationInfo(soap, "ns1:AuthenticationInfo", -1, &a->ns1__AuthenticationInfo_, ""))
    return soap->error;
  return soap_element_end_out(soap, tag);
}