![](/img/trans.png)
[英]Is it possible to map a port using UPnP, with SOAP, to bind to a local port where my http server is listening?
[英]UPnP and SOAP to router
我正在嘗試在我的路由器上發出操作請求。
這是關於服務的規范:
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-wifialliance-org:device:WFADevice:1</deviceType>
<friendlyName>WFADevice</friendlyName>
<manufacturer>Broadcom Corporation</manufacturer>
<manufacturerURL>http://www.broadcom.com</manufacturerURL>
<modelDescription>Wireless Device</modelDescription>
<modelName>WPS</modelName>
<modelNumber>X1</modelNumber>
<serialNumber>0000001</serialNumber>
<UDN>uuid:9b317afe-7404-5ecd-d051-fd3d1733cbee</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-wifialliance-org:service:WFAWLANConfig:1</serviceType>
<serviceId>urn:wifialliance-org:serviceId:WFAWLANConfig1</serviceId>
<SCPDURL>/x_wfawlanconfig.xml</SCPDURL>
<controlURL>/control?WFAWLANConfig</controlURL>
<eventSubURL>/event?WFAWLANConfig</eventSubURL>
</service>
</serviceList>
</device>
</root>
我試圖發出請求的其中一項操作稱為GetDeviceInfo
:
<action>
<name>GetDeviceInfo</name>
<argumentList>
<argument>
<name>NewDeviceInfo</name>
<direction>out</direction>
<relatedStateVariable>DeviceInfo</relatedStateVariable>
</argument>
</argumentList>
</action>
這是我提出請求的方式:
$ curl 'http://192.168.0.1:1900/control?WFAWLANConfig' \
-X 'POST' \
-H 'Content-Type: text/xml; charset="utf-8"' \
-H 'SOAPAction: "urn:schemas-wifialliance-org:service:WFAWLANConfig:1#GetDeviceInfo"' \
-d '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="schemas.xmlsoap.org/soap/encoding">
<s:Body>
</s:Body>
</s:Envelope>'
我得到:
HTTP1.1 400 Bad Request Content-Type: text/xml <title>400 Bad Request</title><body>400 Bad Request</body>
由於我對 SOAP 和 UPnP 不是很熟悉,您能幫我提供有效的請求嗎?
我自己想出來了,我所要做的就是在<s:Body>
中添加以下行:
<u:GetDeviceInfo xmlns:u="urn:schemas-upnp-org:service:serviceType:v"> </u:GetDeviceInfo>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.