易截截图软件、单文件、免安装、纯绿色、仅160KB

python和dotnet的webservice互访

2007-08-22 22:46
一、用SOAPpy访问dotnet webservice
      dotnet的webservice
      <WebMethod()> _
      Public Function HelloWorld() As String
          Return "Hello World"
      End Function
      <WebMethod()> _
      Public Function HelloWorld2(ByVal s As String) As String
          Return "Hello World2" + s
      End Function
      <WebMethod()> _
      Public Function HelloWorld3(ByVal i As Int16, ByVal j As Int16) As String
          Return "Hello World3" + (i + j).ToString()
      End Function
命名空音后加一句 SoapDocumentService(Use:=SoapBindingUse.Encoded)
访问
>>>from SOAPpy import WSDL
>>> server= WSDL.Proxy("http://192.168.1.3/mywebservice/Service1.asmx?WSDL
")
>>> server.HelloWorld()
'Hello World'
>>> server.HelloWorld('abcdefg')
'Hello World'
>>> server.HelloWorld2('abcdefg')                   
'Hello World2'
>>> server.HelloWorld2(s = 'abcdefg')     #有参数时,需带上参数名
'Hello World2abcdefg'
>>> server.HelloWorld3(i=1,j=2)              #暂未解决
Traceback (most recent call last):
    File "<pyshell#43>", line 1, in -toplevel-
      server.HelloWorld3(i=1,j=2)
    File "c:\python24\Lib\site-packages\SOAPpy\Client.py", line 453, in __call__
  


相关文档:

python decorator

1.常用方法,不带参数
def decator(func):
    def inner_func(*args):
        args = (i * 2 for i in args)
        return func(*args)
    return inner_func
   
@decator
def add(a, ......

Python and RRD

RRD是Round Robin Database的意思,RRDTool是用来管理RRD的一个工具。RRDTool的主页在这里,Wikipedia的页面在这里。RRD其实就是一个时序数据库,使用一个固定大小的环型buffer,适用于存储一些统计性的信息,如CPU负载呀,气温变化呀。我为什么要说这个东西呢,因为XenServer里的性能统计是用的RRD,你可以访问诸如http:// ......

Python 有权重的随机选择, Weighted Random Choice

import random def windex(lst):
    '''an attempt to make a random.choose() function that makes weighted choices
    accepts a list of tuples with the item and probability as a pair'''
    wtotal = sum([x[1] for x in lst])
   ......

Python 3 初探,第 1 部分: Python 3 的新特性

Python 3 是 Guido van Rossum 功能强大的通用编程语言的最新版本。它虽然打破了与 2.x 版本的向后兼容性,但却清理了某些语法方面的问题。本文是系列文章中的第一篇,介绍了影响该语言及向后兼容性的各种变化,并且还提供了新特性的几个例子。
Python 版本 3,也被称为 Python 3000 或 Py3K(仿效 Microsoft® Windows ......

c盘整理 Python脚本

能整理大部分无用文件
#!/usr/bin/python
#syscleaner.py
import os
import os.path
#delete files and directory recursively
def itedel(dir):
print('in dir :'+dir)
for doc in os.listdir(dir):
try:
if(os.path.isdir(doc)):
itedel(dir+'\\'+doc)
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号