UPnP 和 SOAP 到路由器
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>
我正在尝试在我的路由器上发出操作请求。
这里是关于服务的规范:
<?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>