xml - UPnP 和 SOAP 到路由器

标签 xml bash curl soap upnp

我正在尝试在我的路由器上发出操作请求。

这里是关于服务的规范:

<?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 - UPnP 和 SOAP 到路由器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59120494/

相关文章:

bash FFMPEG - ".mp4 no such file or directory"

python - pycurl 无信号和超时 <= 999ms

python - Marketo API 和 Python,发布请求失败

java - 解码时出现 JAXB 意外元素

sql - 根据存在情况更新元素或将元素插入到 xml 列中

bash - 如何以编程方式绘制来自文件的连续数据集的图表?

Swift - 将 URLRequest 转换为 cURL

c++ - XML 文件中 Haar 级联正面人脸检测的特征向量大小是多少?

python - 在python中使用ElementTree删除特定的xml标签

bash - 对 Bash 重定向的细粒度控制