UPnP 架构的 SOAP 实现

SOAP implementation of UPnP architecture

我正在尝试实施 UPnP AV 控制点。我完成了架构的描述阶段。为了从浏览操作中获取服务器的内容,我使用如下 CURL 命令。

curl -o response.xml -H "Host: 192.168.1.47:2869" -H "Content-Type: text/xml; Charset="UTF-8"" -H "SOAPAction: "http://192.168.1.47:2869/upnphost/udhisapi.dll?content=uuid:67240e36-10e0-45f6-9c4b-e18cdd53360e"" -d @request.xml -X POST http://192.168.1.47:2869/upnphost/udhisapi.dll?control=uuid:99261858-3c45-41b5-87fd-3f30b4700005+urn:upnp-org:serviceId:ContentDirectory

SOAPAction下的URL是服务器的服务描述url。 POST后面的URL是服务器的控件URL。

我的request.xml如下:

   <?xml version = "1.0" encoding="utf-8"?>
   <s:Envelope
        xmlns:s = "http://schemas.xmlsoap.org/soap/envelope">
        s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding">
        <s:Body>
           <u:Browse xmlns:u="urn:schemas-upnp-org:Service:ContentDirectory:1">
                   <ObjectID>"0"</ObjectID>
                   <BrowseFlag>"BrowseDirectChildren"</BrowseFlag>
                   <Filter>"*"</Filter>
                   <StartingIndex>0</StartingIndex>
                   <RequestedCount>3</RequestedCount>
                   <SortCriteria>""</SortCriteria>

           </u:Browse>
    </s:Body>
    </s:Envelope>

`

我收到的回复 XML 不包含我需要的正文内容。响应 xml 是:

    <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
       <s:Fault>
           <faultcode>s:Client</faultcode>
           <faultstring>UPnPError</faultstring>
           <detail>
              <UPnPError>
                  <errorCode>401</errorCode>
                   <errorDescription>Invalid Action</errorDescription>
              </UPnPError>
           </detail>
    </s:Fault>
    </s:Body>
    </s:Envelope>

如何获取服务器的内容。

Soapaction 应该是您要调用的操作的完整指定标识符。您正在向服务描述发送 URL。以下应该更好用:

SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"

你的xml也可能无效,尖括号似乎不匹配。我还会检查 Browse 参数值的引用:我相信 none 应该被引用。