• 一封没有发出的求救信


    同样的程序在Win下能跑,在Linux下就会出错
    以下为错误信息:

    Traceback (most recent call last):
    File "/root/cron/send.py", line 27, in <module>
    send()
    File "/root/cron/send.py", line 23, in send
    message_client(p, txt_message)
    File "/root/cron/send.py", line 10, in message_client
    proxy = WSDL.Proxy('http://webservice.dodoca.com:8080/NOSmsPlatform/services/BusinessService?wsdl')
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/WSDL.py", line 67, in __init__
    self.wsdl = reader.loadFromString(str(wsdlsource))
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/WSDLTools.py", line 47, in loadFromString
    return self.loadFromStream(StringIO(data))
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/WSDLTools.py", line 28, in loadFromStream
    document = DOM.loadDocument(stream)
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/Utility.py", line 602, in loadDocument
    return xml.dom.minidom.parse(data)
    File "/opt/python/lib/python2.5/xml/dom/minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
    File "/opt/python/lib/python2.5/xml/dom/expatbuilder.py", line 928, in parse
    result = builder.parseFile(file)
    File "/opt/python/lib/python2.5/xml/dom/expatbuilder.py", line 207, in parseFile
    parser.Parse(buffer, 0)
    xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 5

    以下为简单的代码:

    #!/usr/bin/env python
    #
    coding=utf-8

    from SOAPpy import WSDL

    def message_client(dest_mobile='1380013800', msg=''):
    account = '*******'
    password = '******'
    proxy = WSDL.Proxy('http://webservice.dodoca.com:8080/NOSmsPlatform/services/BusinessService?wsdl')
    index = proxy.sendBatchMessage(account, password, dest_mobile, msg)
    return index

    def send():
    fp = file('phone.txt')
    phone_list = [p for p in fp.read().split(';') if (len(p) == 11)]
    fp.close()

    txt_message = u"hello"

    for p in set(phone_list):
    message_client(p, txt_message)
    print p

    if __name__ == '__main__':
    send()


    使用的库有SOAPpy-0.12.0,fpconst-0.7.2,两个平台下都是安装的同一版本,
    写到这里我才想到可能是Python的版本不一样,遇到这种问题,直觉上的解决思路应该是比较两个平台下所有用到的语言版本,库的版本的不同。结果一查,Win下的Python是2.5.2,Linux下Python的版本是2.5.4,把Linux下的Python换成2.5.2,程序运行正确。

    需要这种问题,我居然会觉得毫无解决办法,看来我的思维能力还有待大大的提高。

  • 相关阅读:
    XML 学习(二)
    maven运用,在eclipse中将maven本地仓库加入,创建maven项目
    windows提权
    windows文件权限问题
    更换tomcat版本遇到问题解决方法
    服务器安装vmware遇到的问题
    windows远程账户禁用/允许/隐藏
    使用maven下载jar包
    编写WebService 并发布到IIS中
    一些有趣的javascript小测试
  • 原文地址:https://www.cnblogs.com/crafter/p/2262941.html
Copyright © 2020-2023  润新知