我正在尝试测试公司产品中的功能.我们的软件将发出如下SOAP请求:
请求标题
POST /testfunction.php HTTP/1.1
Accept: application/soap+xml, application/xml, text/xml
SOAPAction: "http://www.abc.com/testfunction#test"
Host: soap.abc.com
Content-Length: 461
Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)
请求内容
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.abc.com/testfunction">
<SOAP-ENV:Body>
<ns1:test>
<productID>3</productID>
<productSubID>1</productSubID>
<version>1.0.1</version>
<serialNumber/>
<language>EN</language>
<daysLicensed>0</daysLicensed>
<daysLeft>0</daysLeft>
</ns1:test>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
SOAP服务应该响应:
响应标题
HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Mon, 02 May 2011 13:43:46 GMT
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
X-Powered-By: PHP/5.3.3-1ubuntu9.3
Content-Length: 304
Content-encoding: gzip
Run Code Online (Sandbox Code Playgroud)
响应内容
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.abc.com/testfunction"><SOAP-ENV:Body><ns1:testResponse><result>1000</result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
一开始我以为我可以在web.py中创建一个Web服务,并在有人在http://www.abc.com/testfunction上发出POST请求时返回相同的响应.
import web
url = (
'/testfunction', 'testfunction',
)
class …Run Code Online (Sandbox Code Playgroud) 使用正则表达式计算文档中英文单词的正确方法是什么?
我试过:
words=re.findall('\w+', open('text.txt').read().lower())
len(words)
Run Code Online (Sandbox Code Playgroud)
但似乎我遗漏了几个字(与 gedit 中的字数相比)。我做得对吗?
非常感谢!