项目中使用Python 2.2.3,装好了fsconst + SOAPpy后,创建了测试代码
def OpenProxy(url):
    from SOAPpy import WSDL
    proxy 
= WSDL.Proxy(url)
    proxy.soapproxy.config.dumpHeadersIn 
= 1
    proxy.soapproxy.config.dumpHeadersOut 
= 1
    proxy.soapproxy.config.dumpSOAPIn 
= 1
    proxy.soapproxy.config.dumpSOAPOut 
= 1
    proxy.soapproxy.config.debug 
= 9
    
return proxy
    
proxy 
= OpenProxy("http://localhost:1137/Web/Test/Service.asmx?WSDL")
proxy.Test(
345)
    
    写ASP.net服务器,vs中创建一个简单的Test方法:
   
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo 
= WsiProfiles.BasicProfile1_1)]
[SoapDocumentService(Use
=System.Web.Services.Description.SoapBindingUse.Encoded)]
public class Service : System.Web.Services.WebService
{

    
public Service()
    
{
    }


    [WebMethod]
    
public string HelloWorld()
    
{
        
return "Hello World";
    }


    [WebMethod(CacheDuration
=0)]
    
public int Test(int a)
    
{
        
return a + 1;
    }


}


     [SoapDocumentService(Use=System.Web.Services.Description.SoapBindingUse.Encoded)]是出现问题的地方:
   在未添加之前,Test 返回的结果总是 1 ,a 的值未设置。python 的传递的参数未正确解析。看了python调试信息,把 proxy.Test(123)改成了proxy.Test(a=123),重新调用,xml请求的字段对了,但是 .net服务返回还是0。
   在http://mail.python.org/pipermail/xml-sig/2004-November/010733.html看到一些信息,按照上面的说明,加了[SoapDocumentService(Use=System.Web.Services.Description.SoapBindingUse.Encoded)],结果正确了,却不懂为什么。
   第一天是用SOAP,问题还真多!
 posted on 2007-03-23 23:42  thh  阅读(1593)  评论(0编辑  收藏  举报