转自【http://www.7dtest.com/bbs/viewthread.php?tid=855&extra=page%3D1】
期望模拟的请求:
代码:
POST /yourURL/ HTTP/1.1
Content-Type: text/xml
Content-Length: 443
Cache-Control: no-cache
Pragma: no-cache
Accept: text/html
Connection: keep-alive
<?xml version="1.0" encoding="UTF-8"?><content>something</content>
尝试:使用web_submit_data,参数非要指定Name和Value。想仅Post一个XmlString过去而已:
代码:
web_submit_data("PostXmlRpc",
"Action=http://testServier/yourURL/",
"Method=POST",
"EncType=multipart/form-data",
"RecContentType=text/xml",
ITEMDATA,
"Name=<?xml version",
"Value=/"1.0/" encoding=/"UTF-8/"?><content>something</content>",
ENDITEM,
LAST);
但结果是:
引用:
(RelFrameId=1, Internal ID=1)
-----------------------------7d025e2b16b064e/r/n
Content-Disposition: form-data; name="<?xml version"/r/n
/r/n
"1.0" encoding="UTF-8"?><methodCall xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/exten
sions"><methodName>auth.getFrob</methodName><params><param><value><struct><member><name>gu
id</name><value>e6cae838171c4088945e89766751bdcd</value></member><member><name>c</name><va
lue>4B0D097E</value></member><member><name>appkey</name><value>53C927D1A198A7119AA0F337748
4FE81</value></member></struct></value></param></params></methodCall>/r/n
-----------------------------7d025e2b16b064e--/r/n
红色是web_submit_data自动生成而不需要的部分。
-------------------------------------------------------------------
解决方法:
其实很简单的:
web_add_header("User–Agent", "Apache Agent Xml user");
web_custom_request("XmlRpc", "Method=POST",
"Body=<?xml version=Value=/"1.0/" encoding=/"UTF-8/"?><content>something</content>",
LAST);